mirror of
git://git.proxmox.com/git/proxmox-i18n.git
synced 2024-12-22 21:33:51 +03:00
po2js: generate modern JavaScript
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
86f072cad4
commit
7159a792bb
16
po2js.pl
16
po2js.pl
@ -96,13 +96,11 @@ my $outfile = $options->{o};
|
||||
$content .= "// Proxmox Message Catalog: $outfile\n" if $outfile;
|
||||
|
||||
$content .= <<__EOD;
|
||||
__proxmox_i18n_msgcat__ = $json;
|
||||
const __proxmox_i18n_msgcat__ = $json;
|
||||
|
||||
function fnv31a(text) {
|
||||
var len = text.length;
|
||||
var hval = 0x811c9dc5;
|
||||
for (var i = 0; i < len; i++) {
|
||||
var c = text.charCodeAt(i);
|
||||
let hval = 0x811c9dc5;
|
||||
for (const c of text) {
|
||||
hval ^= c;
|
||||
hval += (hval << 1) + (hval << 4) + (hval << 7) + (hval << 8) + (hval << 24);
|
||||
}
|
||||
@ -111,12 +109,8 @@ function fnv31a(text) {
|
||||
}
|
||||
|
||||
function gettext(buf) {
|
||||
var digest = fnv31a(buf);
|
||||
var data = __proxmox_i18n_msgcat__[digest];
|
||||
if (!data) {
|
||||
return buf;
|
||||
}
|
||||
return data[0] || buf;
|
||||
let digest = fnv31a(buf);
|
||||
return __proxmox_i18n_msgcat__[digest]?.[0] ?? buf;
|
||||
}
|
||||
__EOD
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user