mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-15 00:03:28 +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: {
|
||||
_(id) {
|
||||
return PywbI18N.instance.getText(id);
|
||||
_(id, embeddedVariableStrings=null) {
|
||||
return PywbI18N.instance.getText(id, embeddedVariableStrings);
|
||||
},
|
||||
gotoPeriod: function(newPeriod, onlyZoomToPeriod) {
|
||||
if (this.timelineHighlight) {
|
||||
|
@ -24,7 +24,14 @@ export class PywbI18N {
|
||||
getMonth(id, type='long') {
|
||||
return decodeURIComponent(this.config[PywbI18N.monthIdPrefix[id]+'_'+type]);
|
||||
}
|
||||
getText(id) {
|
||||
return decodeURIComponent(this.config[id] || id);
|
||||
getText(id, embeddedVariableStrings=null) {
|
||||
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