gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-merchant-backoffice] branch master updated: employ language switc


From: gnunet
Subject: [taler-merchant-backoffice] branch master updated: employ language switch
Date: Thu, 06 Jan 2022 20:18:16 +0100

This is an automated email from the git hooks/post-receive script.

ms pushed a commit to branch master
in repository merchant-backoffice.

The following commit(s) were added to refs/heads/master by this push:
     new 9695020  employ language switch
9695020 is described below

commit 96950208e39fd6a891fa79894de0098db5f80c30
Author: ms <ms@taler.net>
AuthorDate: Thu Jan 6 20:16:27 2022 +0100

    employ language switch
---
 packages/bank/build-bank-translations.sh           | 29 +++++++++
 .../bank/{src/i18n/strings.ts => contrib/po2ts}    | 56 ++++++++---------
 packages/bank/src/components/app.tsx               |  2 +
 .../src/i18n/{taler-anastasis.pot => bank.pot}     | 28 ++++++++-
 .../bank/src/i18n/{taler-anastasis.pot => de.po}   | 37 ++++++++---
 .../bank/src/i18n/{taler-anastasis.pot => en.po}   | 37 ++++++++---
 packages/bank/src/i18n/strings.ts                  | 73 +++++++++++++++-------
 packages/bank/src/pages/home/index.tsx             |  4 +-
 8 files changed, 199 insertions(+), 67 deletions(-)

diff --git a/packages/bank/build-bank-translations.sh 
b/packages/bank/build-bank-translations.sh
new file mode 100755
index 0000000..86a1716
--- /dev/null
+++ b/packages/bank/build-bank-translations.sh
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+set -eu
+
+function build {
+  POTGEN=node_modules/@gnu-taler/pogen/bin/pogen
+  PACKAGE_NAME=$1
+
+  find \( -name "*.ts" -or -name "*.tsx" \) ! -name "*.d.ts" \
+      | xargs node $POTGEN \
+      | msguniq \
+      | msgmerge src/i18n/poheader - \
+      > src/i18n/$PACKAGE_NAME.pot
+  
+  # merge existing translations: fails when NO .po-files were found.
+  for pofile in $(ls src/i18n/*.po 2> /dev/null || true); do 
+    echo merging $pofile; 
+    msgmerge -o $pofile $pofile src/i18n/$PACKAGE_NAME.pot; 
+  done;
+  
+  # generate .ts file containing all translations
+  cat src/i18n/strings-prelude > src/i18n/strings.ts
+  for pofile in $(ls src/i18n/*.po 2> /dev/null || true); do \
+    echo appending $pofile; \
+    ./contrib/po2ts $pofile >> src/i18n/strings.ts; \
+  done; 
+}
+
+build bank
diff --git a/packages/bank/src/i18n/strings.ts b/packages/bank/contrib/po2ts
old mode 100644
new mode 100755
similarity index 50%
copy from packages/bank/src/i18n/strings.ts
copy to packages/bank/contrib/po2ts
index d12e63e..a135da6
--- a/packages/bank/src/i18n/strings.ts
+++ b/packages/bank/contrib/po2ts
@@ -1,6 +1,7 @@
+#!/usr/bin/env node
 /*
  This file is part of GNU Taler
- (C) 2021 Taler Systems S.A.
+ (C) 2020 Taler Systems S.A.
 
  GNU Taler is free software; you can redistribute it and/or modify it under the
  terms of the GNU General Public License as published by the Free Software
@@ -14,31 +15,28 @@
  GNU Taler; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
  */
 
-/*eslint quote-props: ["error", "consistent"]*/
-export const strings: { [s: string]: any } = {};
-
-strings["de"] = {
-  domain: "messages",
-  locale_data: {
-    messages: {
-      "": {
-        domain: "messages",
-        plural_forms: "nplurals=2; plural=(n != 1);",
-        lang: "",
-      },
-    },
-  },
-};
-
-strings["en"] = {
-  domain: "messages",
-  locale_data: {
-    messages: {
-      "": {
-        domain: "messages",
-        plural_forms: "nplurals=2; plural=(n != 1);",
-        lang: "",
-      },
-    },
-  },
-};
+/**
+ * Convert a <lang>.po file into a JavaScript / TypeScript expression.
+ */
+
+const po2json = require("po2json");
+
+const filename = process.argv[2];
+
+if (!filename) {
+  console.error("error: missing filename");
+  process.exit(1);
+}
+
+const m = filename.match(/([a-zA-Z0-9-_]+).po/);
+
+if (!m) {
+  console.error("error: unexpected filename (expected <lang>.po)");
+  process.exit(1);
+}
+
+const lang = m[1];
+const pojson = po2json.parseFileSync(filename, { format: "jed1.x", fuzzy: true 
});
+const s =
+  "strings['" + lang + "'] = " + JSON.stringify(pojson, null, "  ") + ";\n";
+console.log(s);
diff --git a/packages/bank/src/components/app.tsx 
b/packages/bank/src/components/app.tsx
index 5739f3a..36d7b97 100644
--- a/packages/bank/src/components/app.tsx
+++ b/packages/bank/src/components/app.tsx
@@ -2,10 +2,12 @@ import { FunctionalComponent, h } from "preact";
 import { TranslationProvider } from "../context/translation";
 import { BankHome } from "../pages/home/index";
 import { Menu } from "./menu";
+import { LangSelector } from "./menu/LangSelector";
 
 const App: FunctionalComponent = () => {
   return (
     <TranslationProvider>
+      <LangSelector />
       <BankHome />
     </TranslationProvider>
   );
diff --git a/packages/bank/src/i18n/taler-anastasis.pot 
b/packages/bank/src/i18n/bank.pot
similarity index 61%
copy from packages/bank/src/i18n/taler-anastasis.pot
copy to packages/bank/src/i18n/bank.pot
index 7cdbc04..63aa3b6 100644
--- a/packages/bank/src/i18n/taler-anastasis.pot
+++ b/packages/bank/src/i18n/bank.pot
@@ -1,3 +1,28 @@
+#: 
/home/job/merchant-backoffice/packages/bank/src/components/picker/DurationPicker.tsx:55
+#, c-format
+msgid "days"
+msgstr ""
+
+#: 
/home/job/merchant-backoffice/packages/bank/src/components/picker/DurationPicker.tsx:65
+#, c-format
+msgid "hours"
+msgstr ""
+
+#: 
/home/job/merchant-backoffice/packages/bank/src/components/picker/DurationPicker.tsx:76
+#, c-format
+msgid "minutes"
+msgstr ""
+
+#: 
/home/job/merchant-backoffice/packages/bank/src/components/picker/DurationPicker.tsx:87
+#, c-format
+msgid "seconds"
+msgstr ""
+
+#: /home/job/merchant-backoffice/packages/bank/src/pages/home/index.tsx:549
+#, c-format
+msgid "Page has a problem:"
+msgstr ""
+
 #  This file is part of GNU Taler
 #  (C) 2021 Taler Systems S.A.
 #  GNU Taler is free software; you can redistribute it and/or modify it under 
the
@@ -12,7 +37,7 @@
 #, fuzzy
 msgid ""
 msgstr ""
-"Project-Id-Version: Taler Bank\n"
+"Project-Id-Version: Taler Wallet\n"
 "Report-Msgid-Bugs-To: \n"
 "POT-Creation-Date: 2016-11-23 00:00+0100\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
@@ -23,4 +48,3 @@ msgstr ""
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 "Plural-Forms: nplurals=2; plural=(n != 1);\n"
-
diff --git a/packages/bank/src/i18n/taler-anastasis.pot 
b/packages/bank/src/i18n/de.po
similarity index 53%
copy from packages/bank/src/i18n/taler-anastasis.pot
copy to packages/bank/src/i18n/de.po
index 7cdbc04..2ffe0b8 100644
--- a/packages/bank/src/i18n/taler-anastasis.pot
+++ b/packages/bank/src/i18n/de.po
@@ -1,3 +1,28 @@
+#: 
/home/job/merchant-backoffice/packages/bank/src/components/picker/DurationPicker.tsx:55
+#, c-format
+msgid "days"
+msgstr ""
+
+#: 
/home/job/merchant-backoffice/packages/bank/src/components/picker/DurationPicker.tsx:65
+#, c-format
+msgid "hours"
+msgstr ""
+
+#: 
/home/job/merchant-backoffice/packages/bank/src/components/picker/DurationPicker.tsx:76
+#, c-format
+msgid "minutes"
+msgstr ""
+
+#: 
/home/job/merchant-backoffice/packages/bank/src/components/picker/DurationPicker.tsx:87
+#, c-format
+msgid "seconds"
+msgstr ""
+
+#: /home/job/merchant-backoffice/packages/bank/src/pages/home/index.tsx:549
+#, c-format
+msgid "Page has a problem:"
+msgstr "Es gibt ein Problem:"
+
 #  This file is part of GNU Taler
 #  (C) 2021 Taler Systems S.A.
 #  GNU Taler is free software; you can redistribute it and/or modify it under 
the
@@ -9,18 +34,16 @@
 #  You should have received a copy of the GNU General Public License along with
 #  GNU Taler; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
 #
-#, fuzzy
 msgid ""
 msgstr ""
-"Project-Id-Version: Taler Bank\n"
+"Project-Id-Version: Taler Wallet\n"
 "Report-Msgid-Bugs-To: \n"
 "POT-Creation-Date: 2016-11-23 00:00+0100\n"
-"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
-"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
-"Language-Team: LANGUAGE <LL@li.org>\n"
-"Language: \n"
+"PO-Revision-Date: 2022-01-06 19:44+0100\n"
+"Last-Translator:  <translations@taler.net>\n"
+"Language-Team: German\n"
+"Language: de\n"
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 "Plural-Forms: nplurals=2; plural=(n != 1);\n"
-
diff --git a/packages/bank/src/i18n/taler-anastasis.pot 
b/packages/bank/src/i18n/en.po
similarity index 52%
rename from packages/bank/src/i18n/taler-anastasis.pot
rename to packages/bank/src/i18n/en.po
index 7cdbc04..a145923 100644
--- a/packages/bank/src/i18n/taler-anastasis.pot
+++ b/packages/bank/src/i18n/en.po
@@ -1,3 +1,28 @@
+#: 
/home/job/merchant-backoffice/packages/bank/src/components/picker/DurationPicker.tsx:55
+#, c-format
+msgid "days"
+msgstr "days"
+
+#: 
/home/job/merchant-backoffice/packages/bank/src/components/picker/DurationPicker.tsx:65
+#, c-format
+msgid "hours"
+msgstr "hours"
+
+#: 
/home/job/merchant-backoffice/packages/bank/src/components/picker/DurationPicker.tsx:76
+#, c-format
+msgid "minutes"
+msgstr "minutes"
+
+#: 
/home/job/merchant-backoffice/packages/bank/src/components/picker/DurationPicker.tsx:87
+#, c-format
+msgid "seconds"
+msgstr "seconds"
+
+#: /home/job/merchant-backoffice/packages/bank/src/pages/home/index.tsx:549
+#, c-format
+msgid "Page has a problem:"
+msgstr ""
+
 #  This file is part of GNU Taler
 #  (C) 2021 Taler Systems S.A.
 #  GNU Taler is free software; you can redistribute it and/or modify it under 
the
@@ -9,18 +34,16 @@
 #  You should have received a copy of the GNU General Public License along with
 #  GNU Taler; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
 #
-#, fuzzy
 msgid ""
 msgstr ""
-"Project-Id-Version: Taler Bank\n"
+"Project-Id-Version: Taler Wallet\n"
 "Report-Msgid-Bugs-To: \n"
 "POT-Creation-Date: 2016-11-23 00:00+0100\n"
-"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
-"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
-"Language-Team: LANGUAGE <LL@li.org>\n"
-"Language: \n"
+"PO-Revision-Date: 2022-01-06 19:43+0100\n"
+"Last-Translator:  <translations@taler.net>\n"
+"Language-Team: English\n"
+"Language: en\n"
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 "Plural-Forms: nplurals=2; plural=(n != 1);\n"
-
diff --git a/packages/bank/src/i18n/strings.ts 
b/packages/bank/src/i18n/strings.ts
index d12e63e..c36254d 100644
--- a/packages/bank/src/i18n/strings.ts
+++ b/packages/bank/src/i18n/strings.ts
@@ -15,30 +15,61 @@
  */
 
 /*eslint quote-props: ["error", "consistent"]*/
-export const strings: { [s: string]: any } = {};
+export const strings: {[s: string]: any} = {};
 
-strings["de"] = {
-  domain: "messages",
-  locale_data: {
-    messages: {
+strings['de'] = {
+  "domain": "messages",
+  "locale_data": {
+    "messages": {
+      "days": [
+        ""
+      ],
+      "hours": [
+        ""
+      ],
+      "minutes": [
+        ""
+      ],
+      "seconds": [
+        ""
+      ],
+      "Page has a problem:": [
+        "Es gibt ein Problem:"
+      ],
       "": {
-        domain: "messages",
-        plural_forms: "nplurals=2; plural=(n != 1);",
-        lang: "",
-      },
-    },
-  },
+        "domain": "messages",
+        "plural_forms": "nplurals=2; plural=(n != 1);",
+        "lang": "de"
+      }
+    }
+  }
 };
 
-strings["en"] = {
-  domain: "messages",
-  locale_data: {
-    messages: {
+strings['en'] = {
+  "domain": "messages",
+  "locale_data": {
+    "messages": {
+      "days": [
+        "days"
+      ],
+      "hours": [
+        "hours"
+      ],
+      "minutes": [
+        "minutes"
+      ],
+      "seconds": [
+        "seconds"
+      ],
+      "Page has a problem:": [
+        ""
+      ],
       "": {
-        domain: "messages",
-        plural_forms: "nplurals=2; plural=(n != 1);",
-        lang: "",
-      },
-    },
-  },
+        "domain": "messages",
+        "plural_forms": "nplurals=2; plural=(n != 1);",
+        "lang": "en"
+      }
+    }
+  }
 };
+
diff --git a/packages/bank/src/pages/home/index.tsx 
b/packages/bank/src/pages/home/index.tsx
index beb19aa..27e9f11 100644
--- a/packages/bank/src/pages/home/index.tsx
+++ b/packages/bank/src/pages/home/index.tsx
@@ -543,8 +543,10 @@ export function BankHome(): VNode {
   var [pageState, pageStateSetter] = usePageState();
   var [accountState, accountStateSetter] = useAccountState();
 
+  var i18n = useTranslator();
+
   if (pageState.hasError) {
-    return <p>Page has a problem: {pageState.error}</p>;
+    return <p>{i18n`Page has a problem:`} {pageState.error}</p>;
   }
 
   /**

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]