Hi.

I wonder how the translation is done...
The My Account and Log out links are correctly translated when I'm in another language, but not the Log in/Create account link.

The My account menu is located in the Primary Links.

I use the i18n module, but not the menu translation (it does not work correctly at this day). Instead I have different menu entries for French and English, but their URL aliases are visible only in one language or the other as the pages are either in French or English.

For some reason, the 2 strings are translated, probably because they are based on core pages, but not the third link, which points to /user/login?destination=node%2F[nid]. I don't know how I can create a URL alias for such a path. Or is there another way to get the string translated?

Thanks

Joel

Comments

collectivo.org’s picture

Update: It works if I change the name of the menu from "Log in/Create account" to "Log in", which is translated "by" the navigation menu... I'd like to get the "create account" name too, if you have a solution. I probably don't understand something in the navigation menu customization..

mattyoung’s picture

Can you go to admin/locale/string/search, search for "Login/Create account" and translate it?

dddave’s picture

Version: 6.x-1.3 » 6.x-1.4

Hi matt,

thanks for this great module. It does just what I was searching for. I tried to translate the "Login/Create account" link with translation table but it doesn't recognise it. Also using the search function at admin/build/translate/search doesn't catch the string.

My guess as a non-code guy is that you are doing something different opposed to the "normal" menu creation process.

mattyoung’s picture

This is a hard bug to find, line 491 of menu.inc:

  if (!$link_translate || ($item['title'] == $item['link_title'])) {

The problem is the menu path 'user/login' defined by core has the title 'Log in'. In my module, my menu link uses link_title = 'Log in/Create account'. This if statement just skip the whole translation because they are not equal. That's why if you change it to "Log in", it worked.

I fixed the bug in dev. Wait for the dev snapshot release to show up and give it a try.

If it works, come back here mark it fixed and I'll make a new release.

BTW, what language are you translating? Would you make a translation for this module? Start with the .pot file in the translation directory, make a .po file and send it back in the issue queue.

Thanks!

dddave’s picture

Is the .dev going to show up on the project page?

If your module needs a German translation I am going to try making one. I am thinking of doing so for a couple of modules I am using quite a while now but never started with it. So this might be a good starter.

mattyoung’s picture

The dev release will show. The release bot run every 12 hours so it'll make a release when it run.

You can also use CVS check out: http://drupal.org/node/500100/cvs-instructions/HEAD

Yes, I can use a German translation.

Thanks!

dddave’s picture

I just destroyed my ankle so I expect to have plenty of time today. :(

dddave’s picture

I am currently trying and think I am on a good way. For the record I got this message when I used the template extractor:

    * The first parameter to t() should be a literal string. There should be no variables, concatenation, constants or other non-literal strings there. At t($item['link_title'],array('!name'=>$name,'!realname'=>$realname)) in accountmenu.module on line 139. Read more at http://drupal.org/node/322732
    * The first parameter to t() should be a literal string. There should be no variables, concatenation, constants or other non-literal strings there. At t($item['link_title'],array('!name'=>$name,'!realname'=>$realname)) in accountmenu.module on line 139. Read more at http://drupal.org/node/322732

For the translation I am goint to use the included pot file. That was just to try the extractor. Never used it before.

dddave’s picture

Status: Active » Fixed

The link is translatable. To be honest: I cannot confirm that your fix did the trick because I fear I somehow messed up the tries with the old version (typo or something). So I hope it was a needed fix and not only me making unneccessary noise.

I will open a new issue for the german translation.

mattyoung’s picture

  * The first parameter to t() should be a literal string. There should be no variables, concatenation, constants or other non-literal strings there. At t($item['link_title'],array('!name'=>$name,'!realname'=>$realname)) in accountmenu.module on line 139. Read more at http://drupal.org/node/322732
    * The first parameter to t() should be a literal string. There should be no variables, concatenation, constants or other non-literal strings there. At t($item['link_title'],array('!name'=>$name,'!realname'=>$realname)) in accountmenu.module on line 139. Read more at http://drupal.org/node/322732

These are expected and in the source code I have comments explaining this. Potx only likes t() argument to be constant. But menu link titles are stored in database and cannot be constant. Core does the same so potx is complaining something that's not really a problem.

To verify the fix is working, set your site language to something other than 'en', like German, logout and make sure the menu 'Log in/Create account' is displayed. Log back in and go to 'admin/build/translate/search', look for 'Log in/Create account'. If the string is found, the fix works. You can go translate that string, log out and see menu in translated text.

FYI, potx cannot extract menu link title strings. So those strings are not in the .pot file. You have the use 'admin/build/translate/search' to find those strings and translate them.

To do the translation for the module, you can run potx itself to get the .pot file (ignore those two warnings). Or use the .pot file in translation directory.

dddave’s picture

Ok. It is really fixed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.