Closed (works as designed)
Project:
Easy Breadcrumb
Version:
7.x-2.7
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
22 Aug 2013 at 12:26 UTC
Updated:
2 Aug 2017 at 18:40 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
badrange commentedThis one is made against today's 7.x-2.x
Comment #2
badrange commentedThis one is made against 7.x-2.7
Comment #3
Babou commentedI would add that it only happens if the variable
easy_breadcrumb-home_segment_titleis defined by the admin. If this is the case, then it is not translatable at all.So even if you simply save the admin form without changing its default
Homevalue, then, it's no longer translated. Actually, the simple fact that the variable exists voids the translation.It never goes through the t() function but instead
i18n_string(which I didn't investigate that much).As suggested above, simply changing
i18n_string()intot()solves the problem.I still submit a patch as I don't think it is necessary to check if
i18n_stringexists in order to run thet()function.Comment #4
bart.hanssens commentedAdded tag
Comment #5
bart.hanssens commentedsorry, wrong queue, removing tag
Comment #6
greg boggsPatch looks good to me.
Comment #7
sonemonu commentedHi Guys, I'm back. Thank you so much for your feedbacks about the module!
I think using the "t" function in the approach suggested in the patch is againts a "good practice" the Drupal's official documentation states here: https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/t/7
You should never use t() to translate variables, such as calling
t($text);
, unless the text that the variable holds has been passed through t() elsewhere (e.g., $text is one of several translated literal strings in an array). It is especially important never to call
t($user_text);
, where $user_text is some text that a user entered - doing that can lead to cross-site scripting and other security problems...
Question: Just to be sure, have you tried intalling and enabling the module 'i18n'?
Comment #8
sonemonu commentedPlease try installing and enabling the 'i18n' module, and let us know. Thanks.
Comment #9
Babou commentedi18n is installed and enabled and it doesn't work at all for me unless I use the
t()function.I will try to debug it further when I will have some time.
Comment #10
badrange commentedi18n is also installed here
Comment #11
sonemonu commentedCorrected in 7.x-2.9. Used the function "t" (previous sanitization of the user's text-input through the "check_plain" function).
The 'i18n_string' function do not works as expected and I can't find any documentation regarding its proper usage.
Comment #12
greg boggsComment #13
greg boggsTranslating Variables
"You should never use t() to translate variables". Instead, you want to provide metadata about the variable to indiciate that it can be localized. in hook_variable_info();
See here:
http://drupal.stackexchange.com/questions/9362/is-it-always-bad-to-pass-...
http://api.drupalhelp.net/api/variable/variable.api.php/function/hook_va...
https://drupal.org/node/1113374
The module used to translate variables is called variable_translation which is a submodule of i18n.
Comment #14
nonsieHere's a possible approach using hook_variable_info(). You will need to enable Variable translation (part of i18n), enable front page title as translatable variable and then translate it via admin/config/system/variable/group/easy_breadcrumb.
Comment #15
greg boggsI have tested this patch with locale, variable_realm, variable_store, i18n_variable, variable, i18n and it works as expected. So, I've committed it to the 7.x.2.x-dev branch.
In case someone comes across this issue and doesn't know how to use the translation modules, to test this you must enable the language you want to translate into, then enable URL for language selection and language switcher block. Next you must set the value you wish for the home variable and finally set the translations via the variable UI interface. When you switch languages, the Home crumb should switch languages.
Comment #16
greg boggsComment #18
soumyadas commentedComment #19
greg boggsThanks for the patch ssdas. A working, tested, and well implemented patch is already available in #14. It has not yet been included in the latest stable release.
The main difference between your patch and the one we used is that your patch uses the t() function on user content stored in a Drupal variable.
Comment #21
greg boggsRoger,
You're doing an excellent job on easy breadcrumb! Thanks for getting the tags merged into the 2x branch and jumping on the reports so quickly.
In this commit: http://drupalcode.org/project/easy_breadcrumb.git/commit/2af9cad, you removed the correct variable translations code that Nonsie supplied with the above patch in #14.
Do you need me to re-roll the patch against the latest 2x branch so you can reapply the variable translations code?
Comment #22
sonemonu commentedHey Greg,
Yes, I removed that file because of I did not found any code referencing it (this is probably a mistake of mine, since I do not know how the variables translations feature does works). I've some questions about this, how is that supposed to work? I see you implemented a hook in that file, but such hook should not be referenced by the .module file?
Thanks,
Roger Padilla
Comment #23
greg boggsTranslation of variables is a tough issue. I've had to get help to understand it myself.
See the change from here: http://cgit.drupalcode.org/easy_breadcrumb/commit/?id=7ddd286
Once you set the metadata on the variable to make it translatable, you no longer need custom translation logic in the module file because the Drupal variable translation module uses the metadata on the variable to make the variable available for translation.
~G
Comment #24
sonemonu commentedGregg,
OK, thanks. Just to be sure, then it is not necessary to include/reference the file 'easy_breadcrumb.variable.inc' from the .module or .info? or is it auto-referenced by Drupal?
Roger
Comment #25
greg boggsYou're right, I believe the inc file will need to be included. It looks like the hooks could also live in the .module file according to http://cgit.drupalcode.org/variable/tree/README.txt?id=7.x-2.5
Comment #26
greg boggsThis one seems to have gotten lost in the shuffle. It needs a reroll against the latest release.
Comment #27
Xrobak commentedI've create easy_breadcrumb.variable.inc in module root folder, then open admin/config/regional/i18n/variable/ and turned on ability to translate "Title for the front page segment in the breadcrumb". Then I go to admin/config/user-interface/easy-breadcrumb/ and there is nothing to translate. Also tried admin/config/system/variable/group/easy_breadcrumb but there is no Easy Breadcrumb block at all.
So, what I did wrong? I need to translate my custom text for Easy Breadcrumb but can't do it :( I'm using easy_breadcrumb-7.x-2.12 and drupal 7.39
Comment #28
greg boggsEasy Breadcrumb is currently using t() for translation. So, once you load a page with the crumb on it, you should be able to find it in the translation interface as a string rather than a variable.
Comment #29
Xrobak commentedGreg Boggs, thank you. Now I found it and have to say some things:
1. Breadcrumb title has a string path with that page where you was while doing changes to title in admin/config/user-interface/easy-breadcrumb/. So this make me confused why this breadcrumb title stored in some page path and not home page. So, looks like it better go to website home page and after setup breadcrumb title in overlay.
2. If you use few languages and english is not your primary language, you must setup title in admin/config/user-interface/easy-breadcrumb/ in english language and then translate it as string. In other way you can't translate breadcrumb title to english. I think you need add this information to readme.txt. Thank you!
Comment #30
greg boggsClosing this as works well enough with t();
Comment #31
greg boggs