By gjost on
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
I think you can use the t()
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.
--
Drupal services
My Drupal services
works, sort of...
I tried using t() in the chameleon.theme file, but it didn't seem to work. Basically, i just replaced this:
with this:
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:
This works, but now the links are hardcoded. Is there a better way?
Primary links are probably
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.
--
Drupal services
My Drupal services
Very similar question
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.
Solution(?)
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:
Third, in my page template (page.tpl.php), i replaced the primary and secondary links with something like the following:
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...
I did it a different way...
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
make phptemplate use t() function
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
Re: make phptemplate use t() function
> 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
Super
Thanks a lot man, this is the best way for me!
Use t() for Links, Too
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). ;)
language selection
How did you implement the language-selection, is this made in the theme?
Hi, to localize primary
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.
Tried this with localizer installed... no luck
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!
Not sure, but you may need
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.
Cannot choose the language for my menu items
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?
Same Problem
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.
Add t() to the block
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>