Revert "po2js: generate modern JavaScript"

This reverts commit 7159a792bb.
This commit is contained in:
Thomas Lamprecht 2023-06-09 11:01:42 +02:00
parent 92b3142208
commit 1c77a37fde

View File

@ -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