Add support for updated translation key
This commit is contained in:
parent
f168433db0
commit
2d30393243
@ -50,9 +50,26 @@ define(req, function(Default, Language) {
|
|||||||
var langs = arguments;
|
var langs = arguments;
|
||||||
Object.keys(externalMap).forEach(function (code, i) {
|
Object.keys(externalMap).forEach(function (code, i) {
|
||||||
var translation = langs[i];
|
var translation = langs[i];
|
||||||
|
var updated = {};
|
||||||
|
Object.keys(Default).forEach(function (k) {
|
||||||
|
if (/^updated_[0-9]+_/.test(k) && !translation[k]) {
|
||||||
|
var key = k.split('_').slice(2).join('_');
|
||||||
|
// Make sure we don't already have an update for that key. It should not happen
|
||||||
|
// but if it does, keep the latest version
|
||||||
|
if (updated[key]) {
|
||||||
|
var ek = updated[key];
|
||||||
|
if (parseInt(ek.split('_')[1]) > parseInt(k.split('_')[1])) { return; }
|
||||||
|
}
|
||||||
|
updated[key] = k;
|
||||||
|
}
|
||||||
|
});
|
||||||
Object.keys(Default).forEach(function (k) {
|
Object.keys(Default).forEach(function (k) {
|
||||||
if (/^_/.test(k)) { return; }
|
if (/^_/.test(k)) { return; }
|
||||||
if (!translation[k]) {
|
if (!translation[k] || updated[k]) {
|
||||||
|
if (updated[k]) {
|
||||||
|
missing.push([code, k, 2, 'out.' + updated[k]]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
missing.push([code, k, 1]);
|
missing.push([code, k, 1]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -62,10 +79,6 @@ define(req, function(Default, Language) {
|
|||||||
missing.push([code, k, 0]);
|
missing.push([code, k, 0]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
/*if (typeof(translation._languageName) !== 'string') {
|
|
||||||
var warning = 'key [_languageName] is missing from translation [' + code + ']';
|
|
||||||
missing.push(warning);
|
|
||||||
}*/
|
|
||||||
});
|
});
|
||||||
cb(missing);
|
cb(missing);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -12,7 +12,8 @@ define(function () {
|
|||||||
out.type.poll = 'Encuesta';
|
out.type.poll = 'Encuesta';
|
||||||
out.type.slide = 'Presentación';
|
out.type.slide = 'Presentación';
|
||||||
|
|
||||||
out.common_connectionLost = "<b>Connexión perdida</b><br>El documento está ahora en modo solo lectura hasta que la conexión vuelva.";
|
out.updated_0_common_connectionLost = "<b>Connexión perdida</b><br>El documento está ahora en modo solo lectura hasta que la conexión vuelva.";
|
||||||
|
out.common_connectionLost = out.updated_0_common_connectionLost;
|
||||||
|
|
||||||
out.disconnected = "Desconectado";
|
out.disconnected = "Desconectado";
|
||||||
out.synchronizing = "Sincronización";
|
out.synchronizing = "Sincronización";
|
||||||
|
|||||||
@ -16,7 +16,8 @@ define(function () {
|
|||||||
out.button_newpoll = 'Nouveau sondage';
|
out.button_newpoll = 'Nouveau sondage';
|
||||||
out.button_newslide = 'Nouvelle présentation';
|
out.button_newslide = 'Nouvelle présentation';
|
||||||
|
|
||||||
out.common_connectionLost = "<b>Connexion au serveur perdue</b><br>Vous êtes désormais en mode lecture seule jusqu'au retour de la connexion.";
|
out.updated_0_common_connectionLost = "<b>Connexion au serveur perdue</b><br>Vous êtes désormais en mode lecture seule jusqu'au retour de la connexion.";
|
||||||
|
out.common_connectionLost = out.updated_0_common_connectionLost;
|
||||||
|
|
||||||
out.websocketError = 'Impossible de se connecter au serveur WebSocket...';
|
out.websocketError = 'Impossible de se connecter au serveur WebSocket...';
|
||||||
out.typeError = "Ce document temps-réel n'est pas compatible avec l'application sélectionnée";
|
out.typeError = "Ce document temps-réel n'est pas compatible avec l'application sélectionnée";
|
||||||
|
|||||||
@ -18,8 +18,8 @@ define(function () {
|
|||||||
|
|
||||||
// NOTE: We want to update the 'common_connectionLost' key.
|
// NOTE: We want to update the 'common_connectionLost' key.
|
||||||
// Please do not add a new 'updated_common_connectionLostAndInfo' but change directly the value of 'common_connectionLost'
|
// Please do not add a new 'updated_common_connectionLostAndInfo' but change directly the value of 'common_connectionLost'
|
||||||
out.updated_common_connectionLostAndInfo = "<b>Server Connection Lost</b><br>You're now in read-only mode until the connection is back.";
|
out.updated_0_common_connectionLost = "<b>Server Connection Lost</b><br>You're now in read-only mode until the connection is back.";
|
||||||
out.common_connectionLost = out.updated_common_connectionLostAndInfo;
|
out.common_connectionLost = out.updated_0_common_connectionLost;
|
||||||
|
|
||||||
out.websocketError = 'Unable to connect to the websocket server...';
|
out.websocketError = 'Unable to connect to the websocket server...';
|
||||||
out.typeError = "That realtime document is not compatible with the selected application";
|
out.typeError = "That realtime document is not compatible with the selected application";
|
||||||
|
|||||||
@ -141,22 +141,6 @@ define([
|
|||||||
strungJSON(orig);
|
strungJSON(orig);
|
||||||
});
|
});
|
||||||
|
|
||||||
assert(function () {
|
|
||||||
var todo = function (missing) {
|
|
||||||
if (missing.length !== 0) {
|
|
||||||
missing.forEach(function (msg) {
|
|
||||||
console.log('* ' + msg);
|
|
||||||
});
|
|
||||||
|
|
||||||
// No, this is crappy, it's going to cause tests to fail basically all of the time.
|
|
||||||
//return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Cryptpad.Messages._checkTranslationState(todo);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}, "expected all translation keys in default language to be present in all translations. See console for details.");
|
|
||||||
|
|
||||||
var swap = function (str, dict) {
|
var swap = function (str, dict) {
|
||||||
return str.replace(/\{\{(.*?)\}\}/g, function (all, key) {
|
return str.replace(/\{\{(.*?)\}\}/g, function (all, key) {
|
||||||
return typeof dict[key] !== 'undefined'? dict[key] : all;
|
return typeof dict[key] !== 'undefined'? dict[key] : all;
|
||||||
|
|||||||
@ -21,6 +21,7 @@ define([
|
|||||||
var code = msg[0];
|
var code = msg[0];
|
||||||
var key = msg[1];
|
var key = msg[1];
|
||||||
var needed = msg[2];
|
var needed = msg[2];
|
||||||
|
var value = msg[3] || '""';
|
||||||
|
|
||||||
if (str !== code) {
|
if (str !== code) {
|
||||||
if (str !== "")
|
if (str !== "")
|
||||||
@ -38,10 +39,11 @@ define([
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
res += (need ? '' : '// ') + 'out.' + key + ' = "";';
|
res += (need ? '' : '// ') + 'out.' + key + ' = ' + value + ';';
|
||||||
if (need)
|
if (need === 1) {
|
||||||
{
|
|
||||||
res += ' // ' + JSON.stringify(English[key]);
|
res += ' // ' + JSON.stringify(English[key]);
|
||||||
|
} else if (need === 2) {
|
||||||
|
res += ' // TODO: Key updated --> make sure the updated key "'+ value +'" exists and is translated before that one.';
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}).join('\n')));
|
}).join('\n')));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user