mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-24 06:59:52 +01:00
vue ui i18n: allowed embedded named string variables within translatable strings: e.g. "this {name1} with that {name2}"
This commit is contained in:
parent
ec02333ba4
commit
e6280500ff
File diff suppressed because one or more lines are too long
@ -88,8 +88,8 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
_(id) {
|
_(id, embeddedVariableStrings=null) {
|
||||||
return PywbI18N.instance.getText(id);
|
return PywbI18N.instance.getText(id, embeddedVariableStrings);
|
||||||
},
|
},
|
||||||
gotoPeriod: function(newPeriod, onlyZoomToPeriod) {
|
gotoPeriod: function(newPeriod, onlyZoomToPeriod) {
|
||||||
if (this.timelineHighlight) {
|
if (this.timelineHighlight) {
|
||||||
|
@ -24,7 +24,14 @@ export class PywbI18N {
|
|||||||
getMonth(id, type='long') {
|
getMonth(id, type='long') {
|
||||||
return decodeURIComponent(this.config[PywbI18N.monthIdPrefix[id]+'_'+type]);
|
return decodeURIComponent(this.config[PywbI18N.monthIdPrefix[id]+'_'+type]);
|
||||||
}
|
}
|
||||||
getText(id) {
|
getText(id, embeddedVariableStrings=null) {
|
||||||
return decodeURIComponent(this.config[id] || id);
|
const translated = decodeURIComponent(this.config[id] || id);
|
||||||
|
if (embeddedVariableStrings && id.indexOf('{') >= 0 && id.indexOf('}') >= 0 ) {
|
||||||
|
return translated.replace(/{(\w+)}/, (match, stringId) => embeddedVariableStrings[stringId]);
|
||||||
|
}
|
||||||
|
return translated
|
||||||
|
}
|
||||||
|
_(id, embeddedVariableStrings=null) {
|
||||||
|
return this.getText(id, embeddedVariableStrings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user