]> git.proxmox.com Git - proxmox-i18n.git/blobdiff - po2js.pl
update German translation
[proxmox-i18n.git] / po2js.pl
index 6323b58821b1ef5555a8e0b720895a2654673da1..ee5bbd14a7f5a270270ead6850c7ee7c8879c8ad 100755 (executable)
--- a/po2js.pl
+++ b/po2js.pl
@@ -2,19 +2,18 @@
 
 use strict;
 use warnings;
-use Getopt::Std;
-use Locale::PO;
-use JSON;
+
 use Encode;
+use Getopt::Long;
+use JSON;
+use Locale::PO;
 
 # current limits:
 # - we do not support plural. forms
 # - no message content support
 
 my $options = {};
-
-getopts('t:o:v:', $options) ||
-    die "unable to parse options\n";
+GetOptions($options, 't=s', 'o=s', 'v=s') or die "unable to parse options\n";
 
 die "no files specified\n" if !scalar(@ARGV);
 
@@ -96,11 +95,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);
     }
@@ -109,8 +110,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