Merge pull request #4451 from yurydelendik/issue4427

Makes firefox extension's l10n get() behavior similar to webL10n
This commit is contained in:
Brendan Dahl 2014-03-13 17:19:52 -07:00
commit 432af8b36e

View File

@ -29,12 +29,21 @@
// translate a string
function translateString(key, args, fallback) {
var data = getL10nData(key);
if (!data && fallback)
data = {textContent: fallback};
if (!data)
var i = key.lastIndexOf('.');
var name, property;
if (i >= 0) {
name = key.substring(0, i);
property = key.substring(i + 1);
} else {
name = key;
property = 'textContent';
}
var data = getL10nData(name);
var value = (data && data[property]) || fallback;
if (!value) {
return '{{' + key + '}}';
return substArguments(data.textContent, args);
}
return substArguments(value, args);
}
// translate an HTML element