Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0
Ce dépôt a été archivé le 2022-05-07. Vous pouvez voir ses fichiers ou le cloner, mais pas ouvrir de ticket ou de demandes d'ajout, ni soumettre de changements.
nyaa-pantsu/public/js/translation.js

36 lignes
992 o
JavaScript
Brut Vue normale Historique

2017-06-04 07:43:41 +02:00
// @source https://github.com/NyaaPantsu/nyaa/tree/dev/public/js
// @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt Expat
function Translations() {
2017-07-16 06:43:09 +02:00
var translations = {};
this.Add = function(tr, val) {
trans = {}
if (val != undefined) {
trans[tr] = val;
} else {
trans = tr
}
Object.assign(translations, trans);
};
this.r = function(string, ...args) {
if ((string != undefined) && (translations[string] != undefined)) {
if (args != undefined) {
return this.format(translations[string], ...args);
}
return translations[string];
}
console.error("No translation string for %s! Please check!", string);
return "";
};
this.format = function(format, ...args) {
return format.replace(/{(\d+)}/g, function(match, number) {
return typeof args[number] != 'undefined'
? args[number]
: match
;
});
};
}
2017-06-04 07:43:41 +02:00
var T = new Translations();
// @license-end