all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Maximiliano Sandoval <m.sandoval@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH proxmox-i18n 1/2] format with proxmox-perltidy
Date: Thu, 31 Jul 2025 13:25:59 +0200	[thread overview]
Message-ID: <20250731112822.297009-1-m.sandoval@proxmox.com> (raw)

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 po2js.pl | 69 ++++++++++++++++++++++++++------------------------------
 1 file changed, 32 insertions(+), 37 deletions(-)

diff --git a/po2js.pl b/po2js.pl
index ee5bbd1..c5268d7 100755
--- a/po2js.pl
+++ b/po2js.pl
@@ -26,14 +26,10 @@ sub fnv31a {
     my $hval = 0x811c9dc5;
 
     foreach my $c (unpack('C*', $string)) {
-	$hval ^= $c;
-	$hval += (
-	    (($hval << 1) ) +
-	    (($hval << 4) ) +
-	    (($hval << 7) ) +
-	    (($hval << 8) ) +
-	    (($hval << 24) ) );
-	$hval = $hval & 0xffffffff;
+        $hval ^= $c;
+        $hval +=
+            ((($hval << 1)) + (($hval << 4)) + (($hval << 7)) + (($hval << 8)) + (($hval << 24)));
+        $hval = $hval & 0xffffffff;
     }
     return $hval & 0x7fffffff;
 }
@@ -41,51 +37,50 @@ sub fnv31a {
 my $catalog = {};
 
 foreach my $filename (@ARGV) {
-    my $href = Locale::PO->load_file_ashash($filename) ||
-	die "unable to load '$filename'\n";
-    
+    my $href = Locale::PO->load_file_ashash($filename)
+        || die "unable to load '$filename'\n";
+
     my $charset;
     my $hpo = $href->{'""'} || die "no header";
     my $header = $hpo->dequote($hpo->msgstr);
     if ($header =~ m|^Content-Type:\s+text/plain;\s+charset=(\S+)$|im) {
-	$charset = $1;
+        $charset = $1;
     } else {
-	die "unable to get charset\n" if !$charset;
+        die "unable to get charset\n" if !$charset;
     }
 
-
     foreach my $k (keys %$href) {
-	my $po = $href->{$k};
-	next if $po->fuzzy(); # skip fuzzy entries
-	my $ref = $po->reference();
+        my $po = $href->{$k};
+        next if $po->fuzzy(); # skip fuzzy entries
+        my $ref = $po->reference();
 
-	# skip unused entries
-	next if !$ref;
+        # skip unused entries
+        next if !$ref;
 
-	# skip entries if t is defined (pve/pmg) and the string is
-	# not used there or in the widget toolkit
-	next if $options->{t} && $ref !~ m/($options->{t}|proxmox)\-/;
-    
-	my $qmsgid = decode($charset, $po->msgid);
-	my $msgid = $po->dequote($qmsgid);
+        # skip entries if t is defined (pve/pmg) and the string is
+        # not used there or in the widget toolkit
+        next if $options->{t} && $ref !~ m/($options->{t}|proxmox)\-/;
 
-	my $qmsgstr = decode($charset, $po->msgstr);
-	my $msgstr = $po->dequote($qmsgstr);
+        my $qmsgid = decode($charset, $po->msgid);
+        my $msgid = $po->dequote($qmsgid);
 
-	next if !length($msgid); # skip header
-	
-	next if !length($msgstr); # skip untranslated entries
+        my $qmsgstr = decode($charset, $po->msgstr);
+        my $msgstr = $po->dequote($qmsgstr);
 
-	my $digest = fnv31a($msgid);
+        next if !length($msgid); # skip header
 
-	die "duplicate digest" if $catalog->{$digest};
+        next if !length($msgstr); # skip untranslated entries
 
-	$catalog->{$digest} = [ $msgstr ];
-	# later, we can add plural forms to the array
+        my $digest = fnv31a($msgid);
+
+        die "duplicate digest" if $catalog->{$digest};
+
+        $catalog->{$digest} = [$msgstr];
+        # later, we can add plural forms to the array
     }
 }
 
-my $json = to_json($catalog, {canonical => 1, utf8 => 1});
+my $json = to_json($catalog, { canonical => 1, utf8 => 1 });
 
 my $version = $options->{v} // ("dev-build " . localtime());
 my $content = "// $version\n"; # write version to the beginning to better avoid stale cache
@@ -120,8 +115,8 @@ function gettext(buf) {
 __EOD
 
 if ($outfile) {
-    open(my $fh, '>', $outfile) ||
-	die "unable to open '$outfile' - $!\n";
+    open(my $fh, '>', $outfile)
+        || die "unable to open '$outfile' - $!\n";
     print $fh $content;
 } else {
     print $content;
-- 
2.47.2



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


             reply	other threads:[~2025-07-31 11:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-31 11:25 Maximiliano Sandoval [this message]
2025-07-31 11:26 ` [pve-devel] [PATCH proxmox-i18n 2/2] po2js: add ngettext support Maximiliano Sandoval
2025-07-31 11:37   ` Maximiliano Sandoval
2025-07-31 12:01 ` [pve-devel] applied: [PATCH proxmox-i18n 1/2] format with proxmox-perltidy Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250731112822.297009-1-m.sandoval@proxmox.com \
    --to=m.sandoval@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal