diff --git a/po2js.pl b/po2js.pl index 93c10c1..ffe2e20 100755 --- a/po2js.pl +++ b/po2js.pl @@ -82,11 +82,13 @@ my $outfile = $options->{o}; $content .= "// Proxmox Message Catalog: $outfile\n" if $outfile; $content .= <<__EOD; -const __proxmox_i18n_msgcat__ = $json; +__proxmox_i18n_msgcat__ = $json; function fnv31a(text) { - let hval = 0x811c9dc5; - for (const c of text) { + var len = text.length; + var hval = 0x811c9dc5; + for (var i = 0; i < len; i++) { + var c = text.charCodeAt(i); hval ^= c; hval += (hval << 1) + (hval << 4) + (hval << 7) + (hval << 8) + (hval << 24); } @@ -95,8 +97,12 @@ function fnv31a(text) { } function gettext(buf) { - let digest = fnv31a(buf); - return __proxmox_i18n_msgcat__[digest]?.[0] ?? buf; + var digest = fnv31a(buf); + var data = __proxmox_i18n_msgcat__[digest]; + if (!data) { + return buf; + } + return data[0] || buf; } __EOD