Accept interpolation of i18next

10.3.x-maintenance
Miguel Angel Mulero Martinez 2018-03-23 11:49:14 +01:00
parent 19d81d89af
commit 4b48751132
3 changed files with 17 additions and 4 deletions

View File

@ -371,7 +371,8 @@
},
"infoVersions": {
"message" : "Running - OS: <strong>$1</strong>, Chrome: <strong>$2</strong>, Configurator: <strong>$3</strong>"
"message" : "Running - OS: <strong>{{operatingSystem}}</strong>, Chrome: <strong>{{chromeVersion}}</strong>, Configurator: <strong>{{configuratorVersion}}</strong>",
"description": "Message that appears in the GUI log panel indicating operating system, Chrome version and Configurator version"
},
"releaseCheckLoaded": {
"message" : "Loaded release information for $1 from GitHub."

View File

@ -39,9 +39,19 @@ i18n.init = function(cb) {
}
i18n.getMessage = function(messageID, parameters) {
var translatedString = i18next.t(messageID + '.message');
if (parameters !== undefined) {
var translatedString;
// Option 1, no parameters or Object as parameters (i18Next type parameters)
if ((parameters === undefined) || ((parameters.constructor !== Array) && (parameters instanceof Object))) {
translatedString = i18next.t(messageID + '.message', parameters);
// Option 2: parameters as $1, $2, etc.
// (deprecated, from the old Chrome i18n
} else {
translatedString = i18next.t(messageID + '.message');
if (parameters.constructor !== Array) {
parameters = [parameters];
}

View File

@ -18,7 +18,9 @@ function startProcess() {
i18n.localizePage();
// alternative - window.navigator.appVersion.match(/Chrome\/([0-9.]*)/)[1];
GUI.log(i18n.getMessage('infoVersions',[GUI.operating_system, window.navigator.appVersion.replace(/.*Chrome\/([0-9.]*).*/, "$1"), getManifestVersion()]));
GUI.log(i18n.getMessage('infoVersions',{operatingSystem: GUI.operating_system,
chromeVersion: window.navigator.appVersion.replace(/.*Chrome\/([0-9.]*).*/, "$1"),
configuratorVersion: getManifestVersion()}));
$('#logo .version').text(getManifestVersion());
updateStatusBarVersion();