Makes firefox extension's l10n get() behavior similar to webL10n
This commit is contained in:
parent
1c0e1cc591
commit
452e71b4b0
@ -29,12 +29,21 @@
|
|||||||
|
|
||||||
// translate a string
|
// translate a string
|
||||||
function translateString(key, args, fallback) {
|
function translateString(key, args, fallback) {
|
||||||
var data = getL10nData(key);
|
var i = key.lastIndexOf('.');
|
||||||
if (!data && fallback)
|
var name, property;
|
||||||
data = {textContent: fallback};
|
if (i >= 0) {
|
||||||
if (!data)
|
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 '{{' + key + '}}';
|
||||||
return substArguments(data.textContent, args);
|
}
|
||||||
|
return substArguments(value, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
// translate an HTML element
|
// translate an HTML element
|
||||||
|
Loading…
Reference in New Issue
Block a user