diff --git a/Makefile b/Makefile
index 42f11b3ab..ae82c3825 100644
--- a/Makefile
+++ b/Makefile
@@ -1,20 +1,19 @@
src = src
-ts = $(shell git ls-files $(src) | grep '\.tsx\?$$')
poname = taler-wallet-webex
gulp = node_modules/gulp/bin/gulp.js
tsc = node_modules/typescript/bin/tsc
-po2json = node_modules/po2json/bin/po2json
+pogen = node_modules/pogen/pogen.js
-.PHONY: pogen src/i18n/strings.ts yarn-install
+.PHONY: src/i18n/strings.ts yarn-install
-package-stable: tsc yarn-install
+package-stable: i18n
$(gulp) package-stable
-package-unstable: tsc yarn-install
+package-unstable: i18n
$(gulp) package-unstable
-tsc: tsconfig.json yarn-install src/i18n/strings.ts
+tsc: tsconfig.json yarn-install
$(tsc)
yarn-install:
@@ -23,32 +22,20 @@ yarn-install:
tsconfig.json: gulpfile.js yarn-install
$(gulp) tsconfig
-pogen/pogen.js: pogen/pogen.ts pogen/tsconfig.json
- cd pogen; ../$(tsc)
-
-pogen: $(ts) pogen/pogen.js yarn-install
- find $(src) \( -name '*.ts' -or -name '*.tsx' \) ! -name '*.d.ts' \
- | xargs node pogen/pogen.js \
- | msguniq \
- | msgmerge src/i18n/poheader - \
- > src/i18n/$(poname).pot
-
-msgmerge:
- @for pofile in src/i18n/*.po; do \
- echo merging $$pofile; \
- msgmerge -o $$pofile $$pofile src/i18n/$(poname).pot; \
- done; \
-
dist:
$(gulp) srcdist
-src/i18n/strings.ts: pogen msgmerge
- cp src/i18n/strings-prelude src/i18n/strings.ts
- for pofile in src/i18n/*.po; do \
- b=`basename $$pofile`; \
- lang=$${b%%.po}; \
- $(po2json) -F -f jed1.x -d $$lang $$pofile $$pofile.json; \
- (echo -n "strings['$$lang'] = "; cat $$pofile.json; echo ';') >> $@; \
- rm $$pofile.json; \
- done
-
+i18n: yarn-install
+ # extract translatable strings
+ find $(src) \( -name '*.ts' -or -name '*.tsx' \) ! -name '*.d.ts' \
+ | xargs node $(pogen) \
+ | msguniq \
+ | msgmerge src/i18n/poheader - \
+ > src/i18n/$(poname).pot
+ # merge existing translations
+ @for pofile in src/i18n/*.po; do \
+ echo merging $$pofile; \
+ msgmerge -o $$pofile $$pofile src/i18n/$(poname).pot; \
+ done;
+ # generate .ts file containing all translations
+ $(gulp) po2js
diff --git a/gulpfile.js b/gulpfile.js
index e1897330b..1df9d47ff 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -41,14 +41,15 @@ const concat = require("gulp-concat");
const ts = require("gulp-typescript");
const debug = require("gulp-debug");
const glob = require("glob");
-const jsonTransform = require('gulp-json-transform');
+const jsonTransform = require("gulp-json-transform");
const fs = require("fs");
const del = require("del");
-const through = require('through2');
-const File = require('vinyl');
-const Stream = require('stream').Stream;
-const vfs = require('vinyl-fs');
-const webpack = require('webpack');
+const through = require("through2");
+const File = require("vinyl");
+const Stream = require("stream").Stream;
+const vfs = require("vinyl-fs");
+const webpack = require("webpack");
+const po2json = require("po2json");
const paths = {
ts: {
@@ -71,7 +72,6 @@ const paths = {
"img/icon.png",
"img/logo.png",
"src/**/*.{css,html}",
- "src/taler-wallet-lib.js",
"src/emscripten/taler-emscripten-lib.js",
"dist/*-bundle.js",
],
@@ -250,7 +250,7 @@ gulp.task("pogenjs", [], function () {
/**
* Extract .po files from source code
*/
-gulp.task("pogen", ["pogenjs"], function (cb) {
+gulp.task("pogen", function (cb) {
throw Error("not yet implemented");
});
@@ -266,10 +266,10 @@ function tsconfig(confBase) {
files: []
};
Object.assign(conf.compilerOptions, confBase);
- return through.obj(function(file, enc, cb) {
+ return through.obj(function (file, enc, cb) {
conf.files.push(file.relative);
cb();
- }, function(cb) {
+ }, function (cb) {
conf.files.sort();
let x = JSON.stringify(conf, null, 2);
let f = new File({
@@ -282,9 +282,65 @@ function tsconfig(confBase) {
}
+/**
+ * Get the content of a Vinyl file object as a buffer.
+ */
+function readContentsBuffer(file, cb) {
+ if (file.isBuffer()) {
+ cb(file.contents);
+ return;
+ }
+ if (!file.isStream()) {
+ throw Error("file must be stream or buffer");
+ }
+ const chunks = [];
+ file.contents.on("data", function (chunk) {
+ if (!Buffer.isBuffer(chunk)) {
+ throw Error("stream data must be a buffer");
+ }
+ chunks.push(chunk);
+ });
+ file.contents.on("end", function (chunk) {
+ cb(Buffer.concat(chunks));
+ });
+ file.contents.on("error", function (err) {
+ cb(undefined, err);
+ });
+}
+
+
+/**
+ * Combine multiple translations (*.po files) into
+ * one JavaScript file.
+ */
+function pofilesToJs(targetPath) {
+ const outStream = through();
+ const f = new File({
+ path: targetPath,
+ contents: outStream,
+ });
+ const prelude = fs.readFileSync("./src/i18n/strings-prelude");
+ outStream.write(prelude);
+ return through.obj(function (file, enc, cb) {
+ readContentsBuffer(file, function (buf, error) {
+ if (error) {
+ throw error;
+ }
+ const lang = file.stem;
+ const pojson = po2json.parse(buf, {format: "jed1.x", fuzzy: true});
+ outStream.write("strings['" + lang + "'] = " + JSON.stringify(pojson, null, " ") + ";\n");
+ cb();
+ });
+ }, function (cb) {
+ this.push(f);
+ return cb();
+ });
+}
+
+
// Generate the tsconfig file
// that should be used during development.
-gulp.task("tsconfig", function() {
+gulp.task("tsconfig", function () {
let opts = {base: "."};
const files = concatStreams(
vfs.src(paths.ts.src, opts),
@@ -294,5 +350,11 @@ gulp.task("tsconfig", function() {
.pipe(gulp.dest("."));
});
+gulp.task("po2js", function () {
+ return gulp.src("src/i18n/*.po", {base: "."})
+ .pipe(pofilesToJs("src/i18n/strings.ts"))
+ .pipe(gulp.dest("."));
+});
+
gulp.task("default", ["package-stable", "tsconfig"]);
diff --git a/node_modules/talertest/node/runtime.js b/node_modules/talertest/node/runtime.js
deleted file mode 100644
index 8c899337c..000000000
--- a/node_modules/talertest/node/runtime.js
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- This file is part of TALER
- (C) 2016 Inria
-
- 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
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see
- */
-
-/**
- *
- * @author Florian Dold
- */
-
-
-"use strict";
-
-let vm = require("vm");
-let fs = require("fs");
-let process = require("process");
-let path = require("path");
-
-let testFile = path.resolve(process.argv[2]);
-
-console.log("TAP version 13");
-console.log("running test", testFile);
-
-process.on('unhandledRejection', function(reason, p){
- console.log("Possibly Unhandled Rejection at: Promise ", p, " reason: ", reason);
- process.exit(1);
-});
-
-let tt = require("../talertest");
-require(testFile);
-
-tt.run();
diff --git a/node_modules/talertest/node_modules/.bin/tsc b/node_modules/talertest/node_modules/.bin/tsc
deleted file mode 120000
index 0863208a6..000000000
--- a/node_modules/talertest/node_modules/.bin/tsc
+++ /dev/null
@@ -1 +0,0 @@
-../typescript/bin/tsc
\ No newline at end of file
diff --git a/node_modules/talertest/node_modules/.bin/tsserver b/node_modules/talertest/node_modules/.bin/tsserver
deleted file mode 120000
index f8f8f1a0c..000000000
--- a/node_modules/talertest/node_modules/.bin/tsserver
+++ /dev/null
@@ -1 +0,0 @@
-../typescript/bin/tsserver
\ No newline at end of file
diff --git a/node_modules/talertest/node_modules/.yarn-integrity b/node_modules/talertest/node_modules/.yarn-integrity
deleted file mode 100644
index f3495ec00..000000000
--- a/node_modules/talertest/node_modules/.yarn-integrity
+++ /dev/null
@@ -1 +0,0 @@
-26b883fc46369c1149e0f90e023e6166ad0ba226be24e4aaca3599c7c9fc1d26
\ No newline at end of file
diff --git a/node_modules/talertest/node_modules/typescript/.mailmap b/node_modules/talertest/node_modules/typescript/.mailmap
deleted file mode 100644
index 6a9362f6e..000000000
--- a/node_modules/talertest/node_modules/typescript/.mailmap
+++ /dev/null
@@ -1,228 +0,0 @@
-
-AbubakerB # Abubaker Bashir
-Alexander # Alexander Kuvaev
-Adam Freidin Adam Freidin
-Adi Dahiya Adi Dahiya
-Ahmad Farid ahmad-farid
-Alexander Rusakov
-Alex Eagle
-Anatoly Ressin
-Anders Hejlsberg unknown unknown
-about-code # Andreas Martin
-Andrej Baran
-Andrew Ochsner
-Andrew Z Allen
-Andy Hanson Andy
-Anil Anar
-Anton Tolmachev
-Anubha Mathur anubmat
-Arnavion # Arnav Singh
-Arthur Ozga Arthur Ozga Arthur Ozga Arthur Ozga Arthur Ozga
-Asad Saeeduddin
-Schmavery # Avery Morin
-Basarat Ali Syed Basarat Syed basarat
-Bill Ticehurst Bill Ticehurst
-Ben Duffield
-Ben Mosher
-Blake Embrey
-Bowden Kelly
-Brett Mayen
-Bryan Forbes
-Caitlin Potter
-ChrisBubernak unknown # Chris Bubernak
-Christophe Vidal
-Chuck Jazdzewski
-Colby Russell
-Colin Snover
-Cyrus Najmabadi CyrusNajmabadi unknown
-Dafrok # Dafrok Zhang
-Dan Corder
-Dan Quirk Dan Quirk nknown
-Daniel Rosenwasser Daniel Rosenwasser Daniel Rosenwasser Daniel Rosenwasser Daniel Rosenwasser
-David Li
-David Sheldrick
-David Souther
-Denis Nedelyaev
-Dick van den Brink unknown unknown
-Dirk Baeumer Dirk Bäumer # Dirk Bäumer
-Dirk Holtwick
-Dom Chen
-Doug Ilijev
-Erik Edrosa
-erictsangx # Eric Tsang
-Ethan Rubio
-Evan Martin
-Evan Sebastian
-Eyas # Eyas Sharaiha
-Fabian Cook
-falsandtru # @falsandtru
-flowmemo # @flowmemo
-Frank Wallis
-František Žiacik František Žiacik
-Gabe Moothart
-Gabriel Isenberg
-Gilad Peleg
-Godfrey Chan
-Graeme Wicksted
-Guillaume Salles
-Guy Bedford guybedford
-Harald Niesche
-Homa Wong
-Iain Monro
-Ingvar Stepanyan
-impinball # Isiah Meadows
-Ivo Gabe de Wolff
-Jakub Młokosiewicz
-James Whitney
-Jason Freeman Jason Freeman
-Jason Killian
-Jason Ramsay jramsay
-Jed Mao
-Jeffrey Morlan
-tobisek # Jiri Tobisek
-Johannes Rieken
-John Vilk
-jbondc jbondc jbondc # Jonathan Bond-Caron
-Jonathan Park
-Jonathan Turner Jonathan Turner
-Jonathan Toland
-Jesse Schalken
-Joel Day
-Josh Abernathy joshaber
-Josh Kalderimis
-Josh Soref
-Juan Luis Boya García
-Julian Williams
-Justin Bay
-Justin Johansson
-Herrington Darkholme (´·?·`) # Herrington Darkholme
-Kagami Sascha Rosylight SaschaNaz
-Kanchalai Tanglertsampan Yui
-Kanchalai Tanglertsampan Yui T
-Kanchalai Tanglertsampan Yui
-Kanchalai Tanglertsampan Yui
-Kanchalai Tanglertsampan yui T
-Kārlis Gaņģis
-Keith Mashinter kmashint
-Ken Howard
-Kevin Lang
-kimamula # Kenji Imamula
-Klaus Meinhardt
-Kyle Kelley
-Lorant Pinter
-Lucien Greathouse
-Lukas Elmer Lukas Elmer
-Martin Vseticka Martin Všeticka MartyIX
-gcnew # Marin Marinov
-vvakame # Masahiro Wakame
-Matt McCutchen
-MANISH-GIRI # Manish Giri
-Max Deepfield
-Micah Zoltu
-Michael
-Mohamed Hegazy
-Nathan Shively-Sanders
-Nathan Yee
-Nima Zahedi
-Noah Chen
-Noj Vek
-mihailik # Oleg Mihailik
-Oleksandr Chekhovskyi
-Paul van Brenk Paul van Brenk unknown unknown unknown
-Omer Sheikh
-Oskar Segersva¨rd
-pcan # Piero Cangianiello
-pcbro <2bux89+dk3zspjmuh16o@sharklasers.com> # @pcbro
-Pedro Maltez # Pedro Maltez
-piloopin # @piloopin
-milkisevil # Philip Bulley
-progre # @progre
-Prayag Verma
-Punya Biswal
-Rado Kirov
-Ron Buckton Ron Buckton rbuckton
-Rostislav Galimsky
-Richard Knoll Richard Knoll
-Rowan Wyborn
-Ryan Cavanaugh Ryan Cavanaugh Ryan Cavanaugh
-Ryohei Ikegami
-Sarangan Rajamanickam
-Sébastien Arod
-Sergey Shandar
-Sheetal Nandi
-Shengping Zhong
-shyyko.serhiy@gmail.com # Shyyko Serhiy
-Sam El-Husseini
-Simon Hürlimann
-Slawomir Sadziak
-Solal Pirelli
-Stan Thomas
-Stanislav Sysoev
-Steve Lucco steveluc
-Sudheesh Singanamalla
-Tarik # Tarik Ozket
-Tetsuharu OHZEKI # Tetsuharu Ohzeki
-Tien Nguyen tien unknown #Tien Hoanhtien
-Tim Perry
-Tim Viiding-Spader
-Tingan Ho
-togru # togru
-Tomas Grubliauskas
-ToddThomson # Todd Thomson
-Torben Fitschen
-TruongSinh Tran-Nguyen
-vilicvane # Vilic Vane
-Vladimir Matveev vladima v2m
-Wesley Wigham Wesley Wigham
-York Yao york yao yaoyao
-Yuichi Nukiyama YuichiNukiyama
-Zev Spitz
-Zhengbo Li zhengbli Zhengbo Li Zhengbo Li tinza123 unknown Zhengbo Li zhengbli
-zhongsp # Patrick Zhong
-T18970237136 # @T18970237136
-JBerger
-bootstraponline # @bootstraponline
-yortus # @yortus
-András Parditka
-Anton Khlynovskiy