diff --git a/CliClient/app/build-translation.js b/CliClient/app/build-translation.js new file mode 100644 index 0000000000..ee471c1009 --- /dev/null +++ b/CliClient/app/build-translation.js @@ -0,0 +1,44 @@ +"use strict" + +require('source-map-support').install(); +require('babel-plugin-transform-runtime'); + +import fs from 'fs-extra'; +import gettextParser from 'gettext-parser'; + +const localeDir = __dirname + '/../app/locale'; +const outputDir = __dirname + '/locale'; + +fs.mkdirpSync(outputDir, 0o755); + +function parsePoFile(filePath) { + const content = fs.readFileSync(filePath); + return gettextParser.po.parse(content); +} + +function serializeTranslation(translation) { + let output = {}; + const translations = translation.translations['']; + for (let n in translations) { + if (!translations.hasOwnProperty(n)) continue; + if (n == '') continue; + output[n] = translations[n]['msgstr'][0]; + } + return JSON.stringify(output); +} + +function saveToFile(filePath, data) { + fs.writeFileSync(filePath, data); +} + +const inputFile = localeDir + '/fr_FR.po'; +const outputFile = outputDir + '/fr_FR.json'; + +function buildLocale(inputFile, outputFile) { + const r = parsePoFile(inputFile); + const translation = serializeTranslation(r); + saveToFile(outputFile, translation); +} + +buildLocale(localeDir + '/fr_FR.po', outputDir + '/fr_FR.json'); +buildLocale(localeDir + '/en_GB.po', outputDir + '/en_GB.json'); \ No newline at end of file diff --git a/CliClient/app/locale/en_GB.po b/CliClient/app/locale/en_GB.po new file mode 100644 index 0000000000..0026831b78 --- /dev/null +++ b/CliClient/app/locale/en_GB.po @@ -0,0 +1,237 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR Laurent Cozic +# This file is distributed under the same license as the Joplin-CLI package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: Joplin-CLI 1.0.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-07-17 17:25+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: app/app.js:92 +msgid "No notebook selected." +msgstr "" + +#: app/app.js:97 +msgid "No notebook has been specified." +msgstr "" + +#: app/app.js:128 +msgid "Usage: --profile " +msgstr "" + +#: app/app.js:135 +msgid "Usage: --env " +msgstr "" + +#: app/app.js:160 +msgid "Usage: --log-level " +msgstr "" + +#: app/app.js:167 +#, javascript-format +msgid "Unknown flag: %s" +msgstr "" + +#: app/app.js:183 +#, javascript-format +msgid "" +"Command line argument \"%s\" contains both quotes and double-quotes - " +"aborting." +msgstr "" + +#: app/app.js:275 +#, javascript-format +msgid "Synchronizing with directory \"%s\"" +msgstr "" + +#: app/app.js:352 +msgid "No notebook is defined. Create one with `mkbook `." +msgstr "" + +#: app/command-cat.js:33 +#, javascript-format +msgid "No item \"%s\" found." +msgstr "" + +#: app/command-cp.js:31 app/command-mv.js:36 +#, javascript-format +msgid "No notebook \"%s\"" +msgstr "" + +#: app/command-cp.js:34 app/command-mv.js:39 +#, javascript-format +msgid "No note matches this pattern: \"%s\"" +msgstr "" + +#: app/command-edit.js:33 +msgid "Done editing." +msgstr "" + +#: app/command-edit.js:39 +msgid "" +"No text editor is defined. Please set it using `config editor `" +msgstr "" + +#: app/command-edit.js:45 +msgid "No active notebook." +msgstr "" + +#: app/command-edit.js:66 +msgid "Starting to edit note. Close the editor to get back to the prompt." +msgstr "" + +#: app/command-import-enex.js:16 +msgid "Imports an Evernote notebook file (.enex file)." +msgstr "" + +#: app/command-import-enex.js:35 +#, javascript-format +msgid "Folder does not exists: \"%s\". Create it?" +msgstr "" + +#: app/command-import-enex.js:42 +#, javascript-format +msgid "Imported - %s" +msgstr "" + +#: app/command-import-enex.js:55 +#, javascript-format +msgid "File \"%s\" will be imported into notebook \"%s\". Continue?" +msgstr "" + +#: app/command-import-enex.js:62 +#, javascript-format +msgid "Found: %d." +msgstr "" + +#: app/command-import-enex.js:63 +#, javascript-format +msgid "Created: %d." +msgstr "" + +#: app/command-import-enex.js:64 +#, javascript-format +msgid "Updated: %d." +msgstr "" + +#: app/command-import-enex.js:65 +#, javascript-format +msgid "Skipped: %d." +msgstr "" + +#: app/command-import-enex.js:66 +#, javascript-format +msgid "Resources: %d." +msgstr "" + +#: app/command-import-enex.js:67 +#, javascript-format +msgid "Tagged: %d." +msgstr "" + +#: app/command-import-enex.js:78 +msgid "Importing notes..." +msgstr "" + +#: app/command-ls.js:65 +msgid "Please select a notebook first." +msgstr "" + +#: app/command-mknote.js:17 +msgid "Notes can only be created within a notebook." +msgstr "" + +#: app/command-mv.js:29 +#, javascript-format +msgid "No item matches pattern \"%s\"" +msgstr "" + +#: app/command-rm.js:39 +#, javascript-format +msgid "No notebook matchin pattern \"%s\"" +msgstr "" + +#: app/command-rm.js:40 +#, javascript-format +msgid "Delete notebook \"%s\"?" +msgstr "" + +#: app/command-rm.js:46 +#, javascript-format +msgid "No note matchin pattern \"%s\"" +msgstr "" + +#: app/command-rm.js:47 +#, javascript-format +msgid "%d notes match this pattern. Delete them?" +msgstr "" + +#: app/command-search.js:29 +#, javascript-format +msgid "Notebook not found: \"%s\"" +msgstr "" + +#: app/command-set.js:31 +#, javascript-format +msgid "No note \"%s\" found." +msgstr "" + +#: app/command-sync.js:65 +msgid "Synchronisation is already in progress." +msgstr "" + +#: app/command-sync.js:87 +#, javascript-format +msgid "Synchronization target: %s" +msgstr "" + +#: app/command-sync.js:89 +msgid "Cannot initialize synchronizer." +msgstr "" + +#: app/command-sync.js:91 +msgid "Starting synchronization..." +msgstr "" + +#: app/command-sync.js:98 +msgid "Done." +msgstr "" + +#: app/command-sync.js:113 +msgid "Cancelling..." +msgstr "" + +#: app/command-tag.js:25 app/command-tag.js:34 +#, javascript-format +msgid "Tag does not exist: \"%s\"" +msgstr "" + +#: app/command-tag.js:28 app/command-tag.js:35 +#, javascript-format +msgid "Note does not exist: \"%s\"" +msgstr "" + +#: app/command-tag.js:48 +#, javascript-format +msgid "Invalid command: \"%s\"" +msgstr "" + +#: app/command-use.js:28 +#, javascript-format +msgid "No folder \"%s\"" +msgstr "" + +#: app/command-version.js:17 +#, javascript-format +msgid "%s %s (%s)" +msgstr "" diff --git a/CliClient/app/locale/fr_FR.mo b/CliClient/app/locale/fr_FR.mo new file mode 100644 index 0000000000..b67a1434a4 Binary files /dev/null and b/CliClient/app/locale/fr_FR.mo differ diff --git a/CliClient/app/locale/fr_FR.po b/CliClient/app/locale/fr_FR.po new file mode 100644 index 0000000000..ca806a8c88 --- /dev/null +++ b/CliClient/app/locale/fr_FR.po @@ -0,0 +1,238 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR Laurent Cozic +# This file is distributed under the same license as the Joplin-CLI package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: Joplin-CLI 1.0.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-07-17 17:01+0100\n" +"PO-Revision-Date: 2017-07-17 17:02+0100\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 1.8.7.1\n" +"Last-Translator: \n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" +"Language: fr_FR\n" + +#: app/app.js:92 +msgid "No notebook selected." +msgstr "Aucun carnet n'est sélectionné." + +#: app/app.js:97 +msgid "No notebook has been specified." +msgstr "" + +#: app/app.js:128 +msgid "Usage: --profile " +msgstr "" + +#: app/app.js:135 +msgid "Usage: --env " +msgstr "" + +#: app/app.js:160 +msgid "Usage: --log-level " +msgstr "" + +#: app/app.js:167 +#, javascript-format +msgid "Unknown flag: %s" +msgstr "" + +#: app/app.js:183 +#, javascript-format +msgid "" +"Command line argument \"%s\" contains both quotes and double-quotes - " +"aborting." +msgstr "" + +#: app/app.js:275 +#, javascript-format +msgid "Synchronizing with directory \"%s\"" +msgstr "" + +#: app/app.js:352 +msgid "No notebook is defined. Create one with `mkbook `." +msgstr "" + +#: app/command-cat.js:33 +#, javascript-format +msgid "No item \"%s\" found." +msgstr "" + +#: app/command-cp.js:31 app/command-mv.js:36 +#, javascript-format +msgid "No notebook \"%s\"" +msgstr "" + +#: app/command-cp.js:34 app/command-mv.js:39 +#, javascript-format +msgid "No note matches this pattern: \"%s\"" +msgstr "" + +#: app/command-edit.js:33 +msgid "Done editing." +msgstr "" + +#: app/command-edit.js:39 +msgid "" +"No text editor is defined. Please set it using `config editor `" +msgstr "" + +#: app/command-edit.js:45 +msgid "No active notebook." +msgstr "" + +#: app/command-edit.js:66 +msgid "Starting to edit note. Close the editor to get back to the prompt." +msgstr "" + +#: app/command-import-enex.js:16 +msgid "Imports an Evernote notebook file (.enex file)." +msgstr "" + +#: app/command-import-enex.js:35 +#, javascript-format +msgid "Folder does not exists: \"%s\". Create it?" +msgstr "" + +#: app/command-import-enex.js:42 +#, javascript-format +msgid "Imported - %s" +msgstr "" + +#: app/command-import-enex.js:55 +#, javascript-format +msgid "File \"%s\" will be imported into notebook \"%s\". Continue?" +msgstr "" + +#: app/command-import-enex.js:62 +#, javascript-format +msgid "Found: %d." +msgstr "" + +#: app/command-import-enex.js:63 +#, javascript-format +msgid "Created: %d." +msgstr "" + +#: app/command-import-enex.js:64 +#, javascript-format +msgid "Updated: %d." +msgstr "" + +#: app/command-import-enex.js:65 +#, javascript-format +msgid "Skipped: %d." +msgstr "" + +#: app/command-import-enex.js:66 +#, javascript-format +msgid "Resources: %d." +msgstr "" + +#: app/command-import-enex.js:67 +#, javascript-format +msgid "Tagged: %d." +msgstr "" + +#: app/command-import-enex.js:78 +msgid "Importing notes..." +msgstr "" + +#: app/command-ls.js:65 +msgid "Please select a notebook first." +msgstr "" + +#: app/command-mknote.js:17 +msgid "Notes can only be created within a notebook." +msgstr "" + +#: app/command-mv.js:29 +#, javascript-format +msgid "No item matches pattern \"%s\"" +msgstr "" + +#: app/command-rm.js:39 +#, javascript-format +msgid "No notebook matchin pattern \"%s\"" +msgstr "" + +#: app/command-rm.js:40 +#, javascript-format +msgid "Delete notebook \"%s\"?" +msgstr "" + +#: app/command-rm.js:46 +#, javascript-format +msgid "No note matchin pattern \"%s\"" +msgstr "" + +#: app/command-rm.js:47 +#, javascript-format +msgid "%d notes match this pattern. Delete them?" +msgstr "" + +#: app/command-search.js:29 +#, javascript-format +msgid "Notebook not found: \"%s\"" +msgstr "" + +#: app/command-set.js:31 +#, javascript-format +msgid "No note \"%s\" found." +msgstr "" + +#: app/command-sync.js:65 +msgid "Synchronisation is already in progress." +msgstr "" + +#: app/command-sync.js:87 +#, javascript-format +msgid "Synchronization target: %s" +msgstr "" + +#: app/command-sync.js:89 +msgid "Cannot initialize synchronizer." +msgstr "" + +#: app/command-sync.js:91 +msgid "Starting synchronization..." +msgstr "" + +#: app/command-sync.js:98 +msgid "Done." +msgstr "" + +#: app/command-sync.js:113 +msgid "Cancelling..." +msgstr "" + +#: app/command-tag.js:25 app/command-tag.js:34 +#, javascript-format +msgid "Tag does not exist: \"%s\"" +msgstr "" + +#: app/command-tag.js:28 app/command-tag.js:35 +#, javascript-format +msgid "Note does not exist: \"%s\"" +msgstr "" + +#: app/command-tag.js:48 +#, javascript-format +msgid "Invalid command: \"%s\"" +msgstr "" + +#: app/command-use.js:28 +#, javascript-format +msgid "No folder \"%s\"" +msgstr "" + +#: app/command-version.js:17 +#, javascript-format +msgid "%s %s (%s)" +msgstr "" diff --git a/CliClient/build-translation.js b/CliClient/build-translation.js new file mode 100644 index 0000000000..70b613b93a --- /dev/null +++ b/CliClient/build-translation.js @@ -0,0 +1,6 @@ +var localeDir = __dirname + '/app/locale'; + + +var input = require('fs').readFileSync('en.po'); +var po = gettextParser.po.parse(input); +// console.log(po.translations['']); \ No newline at end of file diff --git a/CliClient/makepot.sh b/CliClient/makepot.sh new file mode 100755 index 0000000000..6d5f417bc8 --- /dev/null +++ b/CliClient/makepot.sh @@ -0,0 +1,5 @@ +#!/bin/bash +set -e + +xgettext --output=translation.pot --language=JavaScript --copyright-holder="Laurent Cozic" --package-name=Joplin-CLI --package-version=1.0.0 app/*.js +cp translation.pot app/locale/en_GB.po \ No newline at end of file diff --git a/CliClient/package.json b/CliClient/package.json index 37da1c583f..c4f9ae2367 100644 --- a/CliClient/package.json +++ b/CliClient/package.json @@ -47,6 +47,7 @@ "babel-preset-env": "^1.5.1", "babel-preset-es2015": "^6.1.4", "babel-preset-react": "^6.24.1", + "gettext-parser": "^1.2.2", "jasmine": "^2.6.0" }, "scripts": { diff --git a/CliClient/translation.pot b/CliClient/translation.pot new file mode 100644 index 0000000000..0026831b78 --- /dev/null +++ b/CliClient/translation.pot @@ -0,0 +1,237 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR Laurent Cozic +# This file is distributed under the same license as the Joplin-CLI package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: Joplin-CLI 1.0.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-07-17 17:25+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: app/app.js:92 +msgid "No notebook selected." +msgstr "" + +#: app/app.js:97 +msgid "No notebook has been specified." +msgstr "" + +#: app/app.js:128 +msgid "Usage: --profile " +msgstr "" + +#: app/app.js:135 +msgid "Usage: --env " +msgstr "" + +#: app/app.js:160 +msgid "Usage: --log-level " +msgstr "" + +#: app/app.js:167 +#, javascript-format +msgid "Unknown flag: %s" +msgstr "" + +#: app/app.js:183 +#, javascript-format +msgid "" +"Command line argument \"%s\" contains both quotes and double-quotes - " +"aborting." +msgstr "" + +#: app/app.js:275 +#, javascript-format +msgid "Synchronizing with directory \"%s\"" +msgstr "" + +#: app/app.js:352 +msgid "No notebook is defined. Create one with `mkbook `." +msgstr "" + +#: app/command-cat.js:33 +#, javascript-format +msgid "No item \"%s\" found." +msgstr "" + +#: app/command-cp.js:31 app/command-mv.js:36 +#, javascript-format +msgid "No notebook \"%s\"" +msgstr "" + +#: app/command-cp.js:34 app/command-mv.js:39 +#, javascript-format +msgid "No note matches this pattern: \"%s\"" +msgstr "" + +#: app/command-edit.js:33 +msgid "Done editing." +msgstr "" + +#: app/command-edit.js:39 +msgid "" +"No text editor is defined. Please set it using `config editor `" +msgstr "" + +#: app/command-edit.js:45 +msgid "No active notebook." +msgstr "" + +#: app/command-edit.js:66 +msgid "Starting to edit note. Close the editor to get back to the prompt." +msgstr "" + +#: app/command-import-enex.js:16 +msgid "Imports an Evernote notebook file (.enex file)." +msgstr "" + +#: app/command-import-enex.js:35 +#, javascript-format +msgid "Folder does not exists: \"%s\". Create it?" +msgstr "" + +#: app/command-import-enex.js:42 +#, javascript-format +msgid "Imported - %s" +msgstr "" + +#: app/command-import-enex.js:55 +#, javascript-format +msgid "File \"%s\" will be imported into notebook \"%s\". Continue?" +msgstr "" + +#: app/command-import-enex.js:62 +#, javascript-format +msgid "Found: %d." +msgstr "" + +#: app/command-import-enex.js:63 +#, javascript-format +msgid "Created: %d." +msgstr "" + +#: app/command-import-enex.js:64 +#, javascript-format +msgid "Updated: %d." +msgstr "" + +#: app/command-import-enex.js:65 +#, javascript-format +msgid "Skipped: %d." +msgstr "" + +#: app/command-import-enex.js:66 +#, javascript-format +msgid "Resources: %d." +msgstr "" + +#: app/command-import-enex.js:67 +#, javascript-format +msgid "Tagged: %d." +msgstr "" + +#: app/command-import-enex.js:78 +msgid "Importing notes..." +msgstr "" + +#: app/command-ls.js:65 +msgid "Please select a notebook first." +msgstr "" + +#: app/command-mknote.js:17 +msgid "Notes can only be created within a notebook." +msgstr "" + +#: app/command-mv.js:29 +#, javascript-format +msgid "No item matches pattern \"%s\"" +msgstr "" + +#: app/command-rm.js:39 +#, javascript-format +msgid "No notebook matchin pattern \"%s\"" +msgstr "" + +#: app/command-rm.js:40 +#, javascript-format +msgid "Delete notebook \"%s\"?" +msgstr "" + +#: app/command-rm.js:46 +#, javascript-format +msgid "No note matchin pattern \"%s\"" +msgstr "" + +#: app/command-rm.js:47 +#, javascript-format +msgid "%d notes match this pattern. Delete them?" +msgstr "" + +#: app/command-search.js:29 +#, javascript-format +msgid "Notebook not found: \"%s\"" +msgstr "" + +#: app/command-set.js:31 +#, javascript-format +msgid "No note \"%s\" found." +msgstr "" + +#: app/command-sync.js:65 +msgid "Synchronisation is already in progress." +msgstr "" + +#: app/command-sync.js:87 +#, javascript-format +msgid "Synchronization target: %s" +msgstr "" + +#: app/command-sync.js:89 +msgid "Cannot initialize synchronizer." +msgstr "" + +#: app/command-sync.js:91 +msgid "Starting synchronization..." +msgstr "" + +#: app/command-sync.js:98 +msgid "Done." +msgstr "" + +#: app/command-sync.js:113 +msgid "Cancelling..." +msgstr "" + +#: app/command-tag.js:25 app/command-tag.js:34 +#, javascript-format +msgid "Tag does not exist: \"%s\"" +msgstr "" + +#: app/command-tag.js:28 app/command-tag.js:35 +#, javascript-format +msgid "Note does not exist: \"%s\"" +msgstr "" + +#: app/command-tag.js:48 +#, javascript-format +msgid "Invalid command: \"%s\"" +msgstr "" + +#: app/command-use.js:28 +#, javascript-format +msgid "No folder \"%s\"" +msgstr "" + +#: app/command-version.js:17 +#, javascript-format +msgid "%s %s (%s)" +msgstr "" diff --git a/CliClient/yarn.lock b/CliClient/yarn.lock index ace8406f71..c8b2bbe864 100644 --- a/CliClient/yarn.lock +++ b/CliClient/yarn.lock @@ -909,7 +909,7 @@ electron-to-chromium@^1.3.14: version "1.3.15" resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.15.tgz#08397934891cbcfaebbd18b82a95b5a481138369" -encoding@^0.1.11: +encoding@0.1.12, encoding@^0.1.11: version "0.1.12" resolved "https://registry.yarnpkg.com/encoding/-/encoding-0.1.12.tgz#538b66f3ee62cd1ab51ec323829d1f9480c74beb" dependencies: @@ -1103,6 +1103,12 @@ getpass@^0.1.1: dependencies: assert-plus "^1.0.0" +gettext-parser@^1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/gettext-parser/-/gettext-parser-1.2.2.tgz#1ef0da75c1e759ae3089c73efa4d19e40298748e" + dependencies: + encoding "0.1.12" + glob-base@^0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/glob-base/-/glob-base-0.3.0.tgz#dbb164f6221b1c0b1ccf82aea328b497df0ea3c4" diff --git a/ReactNativeClient/lib/locale.js b/ReactNativeClient/lib/locale.js index dc64ba31b1..d6fc642872 100644 --- a/ReactNativeClient/lib/locale.js +++ b/ReactNativeClient/lib/locale.js @@ -6,4 +6,8 @@ function _(s, ...args) { return sprintf(s, ...args); } +function loadLocale(locale) { + +} + export { _ }; \ No newline at end of file