diff --git a/.tx/config b/.tx/config new file mode 100644 index 0000000..28c21f4 --- /dev/null +++ b/.tx/config @@ -0,0 +1,10 @@ +[main] +host = https://www.transifex.com +minimum_perc = 1 +lang_map = fr_CA:fr-CA,pt_BR:pt-BR,zh_CN:zh-CN,zh_HK:zh-HK,zh_TW:zh-TW,da_DK:da-DK,sv_SE:sv-SE,kn_IN:kn-IN,nl_NL:nl-NL,en_NL:en-NL,gl_ES:gl-ES + +[brouter-web.brouter-website] +file_filter = locales/.json +source_file = locales/en.json +source_lang = en +type = JSON diff --git a/README.md b/README.md index 2af7314..a5f0ca5 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,18 @@ http://brouter.de General BRouter discussions/questions, support: https://groups.google.com/group/osm-android-bikerouting +## Translating + +Translations are managed using the +[Transifex](https://www.transifex.com/openstreetmap/brouter-web/) platform. After +signing up, you can go to [BRouter's project +page](https://www.transifex.com/openstreetmap/brouter-web/dashboard/), select a language and +click **Translate** to start translating. + + + +
Loading chart...
+ ## Installation As an alternative to the above online version, the standalone server of BRouter can also be run on your local desktop. diff --git a/gulpfile.js b/gulpfile.js index 569493d..0dd6828 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -21,6 +21,8 @@ var replace = require('gulp-replace'); var release = require('gulp-github-release'); var cleanCSS = require('gulp-clean-css'); var modifyCssUrls = require('gulp-modify-css-urls'); +var sort = require('gulp-sort'); +var scanner = require('i18next-scanner'); var debug = false; @@ -50,6 +52,7 @@ var paths = { ).concat('css/*.css'), images: mainNpmFiles().filter(f => RegExp('.*.+(png|gif|svg)', 'i').test(f)), fonts: mainNpmFiles().filter(f => RegExp('font-awesome/fonts/.*', 'i').test(f)), + locales: 'locales/*.json', dest: 'dist', destName: 'brouter-web' }; @@ -118,6 +121,11 @@ gulp.task('fonts', ['clean'], function() { .pipe(gulp.dest(paths.dest + '/fonts')); }); +gulp.task('locales', ['clean'], function() { + return gulp.src(paths.locales) + .pipe(gulp.dest(paths.dest + '/locales')); +}); + gulp.task('clean', function(cb) { del(paths.dest + '/**/*' , cb); }); @@ -140,7 +148,8 @@ gulp.task('log', function() { //return gulp.src(paths.scripts) //return gulp.src(paths.styles) //return gulp.src(paths.images) - return gulp.src(paths.scripts.concat(paths.styles).concat(paths.images)) + // return gulp.src(paths.locales) + return gulp.src(paths.scripts.concat(paths.styles).concat(paths.images).concat(paths.locales)) .pipe(gulpDebug()); }); @@ -153,7 +162,7 @@ gulp.task('inject', function () { .pipe(gulp.dest('.')); }); -gulp.task('default', ['clean', 'scripts_config', 'scripts', 'styles', 'images', 'fonts']); +gulp.task('default', ['clean', 'scripts_config', 'scripts', 'styles', 'images', 'fonts', 'locales']); gulp.task('debug', function() { debug = true; @@ -244,4 +253,22 @@ gulp.task('release:publish', ['release:zip'], function() { }); gulp.task('release', ['release:init', 'bump', 'release:commit', 'release:tag', - 'release:push', 'release:zip', 'release:publish']); \ No newline at end of file + 'release:push', 'release:zip', 'release:publish']); + +gulp.task('i18next', function() { + return gulp.src(['index.html', 'locales/keys.js', 'js/**/*.js']) + .pipe(sort()) + .pipe(scanner({ + lngs: ['en'], // we only generate English version, other languages are handled by transifex via yarn transifex-pull/push + removeUnusedKeys: true, + sort: true, + resource: { + // the source path is relative to current working directory + loadPath: 'locales/{{lng}}.json', + + // the destination path is relative to your `gulp.dest()` path + savePath: 'locales/{{lng}}.json' + } + })) + .pipe(gulp.dest('.')); +}) diff --git a/index.html b/index.html index c20cc7e..ae90e6d 100644 --- a/index.html +++ b/index.html @@ -5,7 +5,7 @@ - BRouter web client + BRouter web client @@ -25,29 +25,32 @@
@@ -61,51 +64,51 @@ - + @@ -145,25 +148,25 @@ - +