I'm working on a bilingual (English/Japanese) site, and need to find a way to have the primary and secondary links display in the same language as the rest of the interface.

- Is there a config for this, or is it a template hack?

- Would it work to use one of the theme systems (which one?) and insert the text using t("my text here") ? Would localization.module even be aware of that text? If not, what would i use for a flag to determine which language to print?

Thanks in advance for your help...

Comments

killes@www.drop.org’s picture

I think you can use the t() function inside the theme.
--
If you have troubles with a particular contrib project, please consider to file a support request. Thanks.

gjost’s picture

I tried using t() in the chameleon.theme file, but it didn't seem to work. Basically, i just replaced this:

$primary_links = theme_get_setting('primary_links');

with this:

$primary_links = t("primary links text");

The text didn't show up in Administer > Localization > Manage Strings. Am i missing something?

I was able to manually do it by modifying chameleon.theme like this:

$primary_links = "[en]primary links";
if ((function_exists('i18n_get_lang')) && (i18n_get_lang() == 'ja')) {
  $primary_links = "[ja]primary links";
}

This works, but now the links are hardcoded. Is there a better way?

killes@www.drop.org’s picture

Primary links are probably expected to be an array, I am not sure.
--
If you have troubles with a particular contrib project, please consider to file a support request. Thanks.

maui1’s picture

I would like to change the names of some of the primary links eg book > workgroup#1

I have searched a bit in the forums and tried some suggestions such as using locale module but I am not able to see any list under the "manage strings" tab. I am new to Drupal and wonder if I have missed some setting somewhere.

gjost’s picture

Well, i don't know if this is the *best* solution, but here's what i came up with.

First, i switched to PHPTemplate, since it allows the use of PHP code.

Second, i found out how to get a reference to the currently-selected language. I'm using both the Localization and Internationalization (i18n) modules, and the i18n module includes a function that returns the 2-letter ISO code for the current language:

i18n_get_lang()

Third, in my page template (page.tpl.php), i replaced the primary and secondary links with something like the following:

  <?php
  if  (i18n_get_lang()== "en") {
    ?>ENGLISH HTML HERE<?
  }
  elseif (i18n_get_lang() == "ja") {
    ?>JAPANESE HTML HERE<?
  }
?>

This seems to work - text appears in the appropriate language. It would be nicer if i could use the t("") function and have the text appear in the .PO for my site, but no such luck.

Your mileage may vary...

jmlane’s picture

I did it a different way... You can try my method, I think it's much simpler then using PHP logic in your template files: Intergration with PHPtemplate engine.

Jonathan

brauchlik’s picture

Another way to translate primary links is to make php_teplate use the t() function to translate the links. I simply changed one line in phptemplate.engine (in 4.6 it is line 167) from:
$text = $value['text'][$i];
to:
$text = t($value['text'][$i]);

Then I can translate the strings with in "admin/localization/manage strings".

Kurt Brauchli
http://ipath.ch

pfeito’s picture

> Then I can translate the strings with in "admin/localization/manage strings".

How can I do it? I go there, but I dont know how to translate the Primary Links? Can you detail a little more or give an example?

Im sure it must be obvious, but I have just two weeks of experience with drupal...

Thanks,
Pedro Fortuna

kecinzer’s picture

Thanks a lot man, this is the best way for me!

plj’s picture

Note that if you only do what Kurt suggested, you'll get the link texts translated, but not the links themselves; if you have a completely internationalised site, you'll most likely want both. To automatically refer to different URL when the language is switched, you should also change

$link = $value['link'][$i];

to:

$link = t($value['link'][$i]);

After this is done you can just create both link texts and the URLs they're referring to in English, and then go to the manage strings page, and not only translate the link texts, but “translate” the URLs, too!

Demo should appear at www.finncon.org within a week (though I'm not the actual admin of that site). ;)

stoltoguzzi’s picture

How did you implement the language-selection, is this made in the theme?

blueminds’s picture

Hi,

to localize primary links or any other links you need to itterate over the array containg the links and replace title element as is below.

<?php 
if (isset($primary_links)) {
	foreach ($primary_links as $key => $value) {
		$primary_links[$key]['title'] = t($primary_links[$key]['title']); 
	}
	
	print theme('links', $primary_links, array (
		'class' => 'links primary-links'
	));
}
?>
manuel garcia’s picture

Hi divamys,

I tryed puting that in my page.tpl.php instead of print theme('links', $primary_links); , but I stil cannot find the strings to translate them neither through the localizer string translation nor the locale string translation.

I'm I going about doing this the wrong way? Could you describe (idiot proof) how to do this properly please?

Thanks!

Junesun’s picture

Not sure, but you may need to set a language for each of your primary links, if the language field is currently blank then it can't work.
And the strings will show up in "Localization > Manage Strings", best do a specific search for them (exact wording and "Untranslated") because otherwise you're swamped with untranslated stuff from the various modules.

manuel garcia’s picture

Thanks Junesun for the input, I think you are right, however i cannot choose the language for my menu items... I'm I missing something? I do have "Localizer menu" active, so I suppose I should see the administration option in my menu items for choosing what language they are.

Any clues why I am not seeing this?

SnowB1’s picture

I also have the same problem as Manuel. I have installed localizer as well as Localizer Menu. I use the localizer block to switch languages which works as it should, but when I go to edit my menu I do not have a drop down to select the language. As far as I can tell by reading around this dropdown make it easy to switch. Any ideas?

Thanks in advance.

simakas’s picture

Add t() to the block template (../themes/theme/block.tpl.php).
Replace
<h2 class="title"> <?php print $block->subject; ?> </h2>
To
<h2 class="title"> <?php print t($block->subject); ?> </h2>