Closed (fixed)
Project:
Flag
Version:
7.x-2.x-dev
Component:
Flag core
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
2 Oct 2008 at 09:02 UTC
Updated:
31 Jul 2012 at 08:41 UTC
Hi,
Continuing this discussion from #314976: Patch for i18n issues.
Original post:
There's one other internationalization issue not covered by these patches:
flag/flag.module:
+901: Invalid localization code: format_plural(intval($count),$singular,$plural) In format_plural(), the singular and plural strings are literal strings and should not be enclosed within t().
The t() variable should not be used on variables, and the potx module will not be able to extract these strings for translation. It's also not what the t() function was intended for. If you need to translate dynamic variables, then the i18nstrings tt() is a good alternative. The above line of code is within the _flag_format_plural() function, which I couldn't find used anywhere, so this may be a non-issue.
Cheers,
Stella
Comments
Comment #1
stella commentedTo post moofie's comments:
That's not a bug. This is user (administrator) input, so we can't hardcode it.
(It's used in the D5 version to generate messages such as "no votes", "1 vote", "3 votes" in views. It was left in D6 as a reminder that we don't have this functionality yet. I see that people aren't clamoring for this functionality, and, besides, it's a job better suited for Views itself or for "Views Bonus", so maybe it's time to remove it.)
Comment #2
stella commentedAnd finally my response :)
It doesn't matter where the input stored in the $variable originates from, nor does it matter whether it's a trusted or untrusted user who enters it. As long as it's held within a $variable the
t()function can not be used. See this post in the Internationalization group on groups.drupal.org for a discussion on this: http://groups.drupal.org/node/15177Cheers,
Stella
Comment #3
mooffie commentedStella, thanks for the link, that seems like a useful discussion.
(Since the above code will be removed for D6, we're left with only one instance of
t($variable), in flag::get_label().)Comment #4
mitchell commentedI went looking for a D7 issue on which to base these changes, but didn't find anything that's been committed.
Please point this issue to other efforts slated for D7 or other standards for contrib modules. Wish I had more to contribute.
Comment #5
mooffie commentedI'm reclassifying this as "task".
- Calling i18nstrings() (instead of t()) should be very easy.
- We probably also need a way to declare flag options (flag_flag::options()) and link options (hook_flag_link_types()) as translatables. Preferably we should be backward compatible, otherwise we may have to postpone this to Flag 3.0.
Comment #6
skyredwangThis was already committed to 7.x-2.x. Not sure about 6.x-2.x, if there is still need for back-porting, feel free to reopen.