How to allow translation to content type (h1) in node.tpl.php ?

+1
0
-1

Hello,

I am building a multi-language website with TB Methys and I have the following problem: the content type title (h1) does not switch into the right language. It stays in the default content type name. I have i18n and some other translation modules installed and set up and I have translated the content type name in the 3 languages... no change.

I assume I have to add a "if" in the node.tpl.php file but I do not know how to proceed. I have 3 languages. Is somebody can help me to fix this issue?

Here is the code I suppose I have to change:

<?php ?>
nid; ?>" class="article <?php print $classes; ?> clearfix"<?php print $attributes; ?>>
<?php if ($title && !$page): ?>

<?php print render($title_prefix); ?>
<?php if ($title): ?>
>
"><?php print $title; ?>

<?php endif; ?>
<?php print render($title_suffix); ?>

<?php endif; ?>

Thank you beforehand!!!!

+1
0
-1

Hi willbxl,

Instead of modifying node.tpl.php, i suggest you modify the function tb_methys_preprocess_page located at sites/all/themes/tb_methys/inc/preprocess_functions.inc. The code to retrieve content type and assign to title is there. You should open the file and replace the code at line 48th with following code:

$vars['title'] = t($result);

Kind regards,
Will

+1
0
-1

Thank you very much for your help.
Seemed to be the solution but it does not work :(.

I got this:

function tb_methys_preprocess_page(&$vars) {
if (isset($vars['node'])) {
if($vars['node']->type != 'page')
{
$result = db_select('node_type', NULL, array('fetch' => PDO::FETCH_ASSOC))
->fields('node_type', array('name'))
->condition('type', $vars['node']->type)
->execute()->fetchField();
$vars['title'] = t($result);
}
}
}

and unfortunately, no change on the website.