Fix translation for imagery with a '.' in the id

(closes #4112)
This commit is contained in:
Bryan Housel
2017-06-19 23:35:34 -04:00
parent 689bd38048
commit c961788a5b
3 changed files with 11 additions and 4 deletions
+4 -2
View File
@@ -31,12 +31,14 @@ export function rendererBackgroundSource(data) {
source.name = function() {
return t('imagery.' + source.id + '.name', { default: name });
var id_safe = source.id.replace('.', '<TX_DOT>');
return t('imagery.' + id_safe + '.name', { default: name });
};
source.description = function() {
return t('imagery.' + source.id + '.description', { default: description });
var id_safe = source.id.replace('.', '<TX_DOT>');
return t('imagery.' + id_safe + '.description', { default: description });
};
+2 -1
View File
@@ -44,7 +44,8 @@ export function uiAttribution(context) {
}
var terms_text = t('imagery.' + d.id + '.attribution.text',
var id_safe = d.id.replace('.', '<TX_DOT>');
var terms_text = t('imagery.' + id_safe + '.attribution.text',
{ default: d.terms_text || d.id || d.name() }
);
+5 -1
View File
@@ -25,7 +25,11 @@ export function addTranslation(id, value) {
export function t(s, o, loc) {
loc = loc || currentLocale;
var path = s.split('.').reverse();
var path = s
.split('.')
.map(function(s) { return s.replace('<TX_DOT>', '.'); })
.reverse();
var rep = translations[loc];
while (rep !== undefined && path.length) rep = rep[path.pop()];