aboutsummaryrefslogtreecommitdiff
path: root/extension
diff options
context:
space:
mode:
authortg(x) <*@tg-x.net>2016-02-22 23:15:24 +0100
committertg(x) <*@tg-x.net>2016-02-22 23:15:24 +0100
commitc4446d02d541b4c4ea2234170520874cf64c4bc7 (patch)
tree11db4d65092944b133d372f34d30a2e8f2ad1f80 /extension
parent4c005a15960174ba96903f5e3882f56ab7485d81 (diff)
jedi18n
Diffstat (limited to 'extension')
-rw-r--r--extension/Makefile37
-rw-r--r--extension/header.po16
-rw-r--r--extension/lib/i18n.ts17
-rw-r--r--extension/package.json1
-rw-r--r--extension/pages/confirm-contract.html4
-rw-r--r--extension/pages/confirm-create-reserve.html4
-rw-r--r--extension/popup/popup.html4
7 files changed, 68 insertions, 15 deletions
diff --git a/extension/Makefile b/extension/Makefile
index 4055cb00e..c83cc3896 100644
--- a/extension/Makefile
+++ b/extension/Makefile
@@ -1,10 +1,12 @@
-src = lib background content_scripts pages
+src = lib background content_scripts pages popup
+ts = $(shell git ls-files $(src) | grep '\.tsx\?$$')
+langs = en-US de-DE
gulp = node_modules/gulp/bin/gulp.js
tsc = node_modules/typescript/bin/tsc
po2json = node_modules/po2json/bin/po2json
-.PHONY: taler.po lib/i18n.json
+.PHONY: pogen lib/i18n-strings.js
package-stable: tsc i18n
$(gulp) package-stable
@@ -18,15 +20,32 @@ tsc: tsconfig.json node_modules
tsconfig.json: gulpfile.js node_modules
$(gulp) tsconfig
-i18n: lib/i18n.json
+lib/vendor/jed.js: node_modules
+ test -e lib/vendor/jed.js || ln -s ../../node_modules/jed/jed.js lib/vendor/
-taler.po: node_modules
- for f in `find $(src) -name '*.ts' -or -name '*.tsx'`; do echo $$f; pogen/pogen.js $$f > `dirname $$f`/`basename $$f .ts`.po; done
- touch $@
- msgcat `find $(src) -name '*.po'` | msgmerge -o $@ $@ -
+i18n: lib/i18n-strings.js lib/vendor/jed.js
-lib/i18n.json: taler.po node_modules
- $(po2json) $< $@
+pogen: $(ts) node_modules
+ for ts in $(ts); do \
+ echo $$ts; \
+ pogen/pogen.js $$ts > `dirname $$ts`/`basename $$ts .ts`.po; \
+ done
+
+ for lang in $(langs); do \
+ echo $$lang; \
+ test -e taler-$$lang.po || cp header.po taler-$$lang.po; \
+ msgcat `find $(src) -name '*.po'` | msgmerge -o taler-$$lang.po taler-$$lang.po -; \
+ done
+
+lib/i18n-strings.js: $(ts) pogen node_modules
+ for lang in $(langs); do \
+ $(po2json) -f jed1.x -d $$lang taler-$$lang.po taler-$$lang.json; \
+ done
+
+ truncate -s0 $@
+ for lang in $(langs); do \
+ (echo -n "i18n.strings['$$lang'] = "; cat taler-$$lang.json; echo ';') >> $@; \
+ done
node_modules:
npm install .
diff --git a/extension/header.po b/extension/header.po
new file mode 100644
index 000000000..6e5a529b5
--- /dev/null
+++ b/extension/header.po
@@ -0,0 +1,16 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: Taler Wallet\n"
+"Report-Msgid-Bugs-To: taler@gnu.org\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"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
diff --git a/extension/lib/i18n.ts b/extension/lib/i18n.ts
index 6ed8942b3..c23ab0740 100644
--- a/extension/lib/i18n.ts
+++ b/extension/lib/i18n.ts
@@ -17,10 +17,22 @@
declare var i18n: any;
var i18n = <any>function i18n(strings, ...values) {
- // TODO: actually look up translation
- return String.raw(strings, ...values);
+ i18n['init']();
+ //console.log('i18n:', ...strings, ...values)
+ return i18n['jed'].translate(strings[0]).fetch(...values);
+ //return String.raw(strings, ...values);
};
+i18n.lang = chrome.i18n.getUILanguage();
+i18n.jed = null;
+i18n.strings = {};
+
+i18n.init = function() {
+ if (null == i18n.jed) {
+ i18n.jed = new window['Jed'] (i18n.strings[i18n.lang]);
+ }
+}
+
// Interpolate i8nized values with arbitrary objects and
// return array of strings/objects.
i18n.parts = function(strings, ...values) {
@@ -35,4 +47,3 @@ i18n.parts = function(strings, ...values) {
return parts;
};
-
diff --git a/extension/package.json b/extension/package.json
index 4523b91b0..a1934b7c8 100644
--- a/extension/package.json
+++ b/extension/package.json
@@ -20,6 +20,7 @@
"gulp-json-transform": "^0.3.0",
"gulp-typescript": "^2.10.0",
"gulp-zip": "^3.1.0",
+ "jed": "^1.1.0",
"map-stream": "0.0.6",
"mocha": "^2.3.4",
"po2json": "^0.4.1",
diff --git a/extension/pages/confirm-contract.html b/extension/pages/confirm-contract.html
index ca524a61a..2eac4a8e8 100644
--- a/extension/pages/confirm-contract.html
+++ b/extension/pages/confirm-contract.html
@@ -5,9 +5,11 @@
<title>Taler Wallet: Confirm Reserve Creation</title>
<script src="../lib/vendor/URI.js"></script>
<script src="../lib/vendor/mithril.js"></script>
- <script src="../lib/i18n.js"></script>
<script src="../lib/vendor/lodash.core.min.js"></script>
<script src="../lib/vendor/system-csp-production.src.js"></script>
+ <script src="../lib/vendor/jed.js"></script>
+ <script src="../lib/i18n.js"></script>
+ <script src="../lib/i18n-strings.js"></script>
<script src="../lib/module-trampoline.js"></script>
<link rel="stylesheet" type="text/css" href="../style/wallet.css">
diff --git a/extension/pages/confirm-create-reserve.html b/extension/pages/confirm-create-reserve.html
index 7bf2b0498..e14d10221 100644
--- a/extension/pages/confirm-create-reserve.html
+++ b/extension/pages/confirm-create-reserve.html
@@ -4,9 +4,11 @@
<head>
<title>Taler Wallet: Select Taler Provider</title>
<script src="../lib/vendor/URI.js"></script>
- <script src="../lib/i18n.js"></script>
<script src="../lib/vendor/mithril.js"></script>
<script src="../lib/vendor/system-csp-production.src.js"></script>
+ <script src="../lib/vendor/jed.js"></script>
+ <script src="../lib/i18n.js"></script>
+ <script src="../lib/i18n-strings.js"></script>
<script src="../lib/module-trampoline.js"></script>
<link rel="stylesheet" type="text/css" href="../style/wallet.css">
</head>
diff --git a/extension/popup/popup.html b/extension/popup/popup.html
index 0a5662d69..c67085c1b 100644
--- a/extension/popup/popup.html
+++ b/extension/popup/popup.html
@@ -4,9 +4,11 @@
<meta charset="utf-8">
<link rel="stylesheet" href="popup.css" type="text/css">
<script src="../lib/vendor/mithril.js"></script>
- <script src="../lib/i18n.js"></script>
<script src="../lib/vendor/lodash.core.min.js"></script>
<script src="../lib/vendor/system-csp-production.src.js"></script>
+ <script src="../lib/vendor/jed.js"></script>
+ <script src="../lib/i18n.js"></script>
+ <script src="../lib/i18n-strings.js"></script>
<script src="../lib/module-trampoline.js"></script>
</head>
<body>