Closed
Bug 433993
Opened 16 years ago
Closed 16 years ago
___() function on mozilla.com has broken fallback to en-US
Categories
(www.mozilla.org :: General, defect)
www.mozilla.org
General
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: pascalc, Unassigned)
References
Details
the ___($str) function was taken from mozilla-europe.org code and its purpose is to return a localized string for the english string we provide or fall back to English if the string does not exist. It is mainly used in places like headers, footers and the download box like that: echo ___('product'); This fallback mechanism does not work on mozilla.com because templates use the HereDoc syntax and we can only include variables in it, not function calls, so what is done currently is that we just don't have a fallback to English and directly call the variable in the array: $footer = <<<FOOTER <a href="/{$lang}/about/legal.html">{$GLOBALS['__l10n_moz']['Legal Notices']}</a> FOOTER; which generates for locales: <a href="/fr/about/legal.html"></a> instead of: <a href="/fr/about/legal.html">Legal Notices</a> I propose that we create a small class to work around that problem, I think that the following should work: class l10nString { var $str; public function __construct($str) { (!empty($GLOBALS['__l10n_moz'][$str])) ? $this -> str = $GLOBALS['__l10n_moz'][$str] : $this -> str = $str; } } $foo = new l10nString('Legal Notices'); $footer = <<<FOOTER <a href="/{$lang}/about/legal.html">{$foo -> str}</a> FOOTER; Wil, what do you think of it?
Comment 1•16 years ago
|
||
sgarrity pointed this out to me a couple weeks ago and I had a half a patch written for the footer before I realized it wouldn't work. :( I don't think we need to declare a new object for every string though. Why not just add a get() function to l10n_moz?
Reporter | ||
Comment 2•16 years ago
|
||
either that or we use an array instead of a string for the class variable and we just add strings in the array and call them as $foo -> str[0]
Comment 3•16 years ago
|
||
Fix for this is in r14199. We're using {$l10n->get('variable')}. Big-ups to oremj for the idea.
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
Assignee | ||
Updated•12 years ago
|
Component: www.mozilla.org/firefox → www.mozilla.org
Assignee | ||
Updated•12 years ago
|
Component: www.mozilla.org → General
Product: Websites → www.mozilla.org
You need to log in
before you can comment on or make changes to this bug.
Description
•