jedi18n
This commit is contained in:
parent
4c005a1596
commit
c4446d02d5
@ -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
|
gulp = node_modules/gulp/bin/gulp.js
|
||||||
tsc = node_modules/typescript/bin/tsc
|
tsc = node_modules/typescript/bin/tsc
|
||||||
po2json = node_modules/po2json/bin/po2json
|
po2json = node_modules/po2json/bin/po2json
|
||||||
|
|
||||||
.PHONY: taler.po lib/i18n.json
|
.PHONY: pogen lib/i18n-strings.js
|
||||||
|
|
||||||
package-stable: tsc i18n
|
package-stable: tsc i18n
|
||||||
$(gulp) package-stable
|
$(gulp) package-stable
|
||||||
@ -18,15 +20,32 @@ tsc: tsconfig.json node_modules
|
|||||||
tsconfig.json: gulpfile.js node_modules
|
tsconfig.json: gulpfile.js node_modules
|
||||||
$(gulp) tsconfig
|
$(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
|
i18n: lib/i18n-strings.js lib/vendor/jed.js
|
||||||
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 $@ $@ -
|
|
||||||
|
|
||||||
lib/i18n.json: taler.po node_modules
|
pogen: $(ts) node_modules
|
||||||
$(po2json) $< $@
|
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:
|
node_modules:
|
||||||
npm install .
|
npm install .
|
||||||
|
16
extension/header.po
Normal file
16
extension/header.po
Normal file
@ -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"
|
@ -17,10 +17,22 @@
|
|||||||
declare var i18n: any;
|
declare var i18n: any;
|
||||||
|
|
||||||
var i18n = <any>function i18n(strings, ...values) {
|
var i18n = <any>function i18n(strings, ...values) {
|
||||||
// TODO: actually look up translation
|
i18n['init']();
|
||||||
return String.raw(strings, ...values);
|
//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
|
// Interpolate i8nized values with arbitrary objects and
|
||||||
// return array of strings/objects.
|
// return array of strings/objects.
|
||||||
i18n.parts = function(strings, ...values) {
|
i18n.parts = function(strings, ...values) {
|
||||||
@ -35,4 +47,3 @@ i18n.parts = function(strings, ...values) {
|
|||||||
|
|
||||||
return parts;
|
return parts;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
"gulp-json-transform": "^0.3.0",
|
"gulp-json-transform": "^0.3.0",
|
||||||
"gulp-typescript": "^2.10.0",
|
"gulp-typescript": "^2.10.0",
|
||||||
"gulp-zip": "^3.1.0",
|
"gulp-zip": "^3.1.0",
|
||||||
|
"jed": "^1.1.0",
|
||||||
"map-stream": "0.0.6",
|
"map-stream": "0.0.6",
|
||||||
"mocha": "^2.3.4",
|
"mocha": "^2.3.4",
|
||||||
"po2json": "^0.4.1",
|
"po2json": "^0.4.1",
|
||||||
|
@ -5,9 +5,11 @@
|
|||||||
<title>Taler Wallet: Confirm Reserve Creation</title>
|
<title>Taler Wallet: Confirm Reserve Creation</title>
|
||||||
<script src="../lib/vendor/URI.js"></script>
|
<script src="../lib/vendor/URI.js"></script>
|
||||||
<script src="../lib/vendor/mithril.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/lodash.core.min.js"></script>
|
||||||
<script src="../lib/vendor/system-csp-production.src.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>
|
<script src="../lib/module-trampoline.js"></script>
|
||||||
<link rel="stylesheet" type="text/css" href="../style/wallet.css">
|
<link rel="stylesheet" type="text/css" href="../style/wallet.css">
|
||||||
|
|
||||||
|
@ -4,9 +4,11 @@
|
|||||||
<head>
|
<head>
|
||||||
<title>Taler Wallet: Select Taler Provider</title>
|
<title>Taler Wallet: Select Taler Provider</title>
|
||||||
<script src="../lib/vendor/URI.js"></script>
|
<script src="../lib/vendor/URI.js"></script>
|
||||||
<script src="../lib/i18n.js"></script>
|
|
||||||
<script src="../lib/vendor/mithril.js"></script>
|
<script src="../lib/vendor/mithril.js"></script>
|
||||||
<script src="../lib/vendor/system-csp-production.src.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>
|
<script src="../lib/module-trampoline.js"></script>
|
||||||
<link rel="stylesheet" type="text/css" href="../style/wallet.css">
|
<link rel="stylesheet" type="text/css" href="../style/wallet.css">
|
||||||
</head>
|
</head>
|
||||||
|
@ -4,9 +4,11 @@
|
|||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<link rel="stylesheet" href="popup.css" type="text/css">
|
<link rel="stylesheet" href="popup.css" type="text/css">
|
||||||
<script src="../lib/vendor/mithril.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/lodash.core.min.js"></script>
|
||||||
<script src="../lib/vendor/system-csp-production.src.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>
|
<script src="../lib/module-trampoline.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
Loading…
Reference in New Issue
Block a user