1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-08-13 22:12:50 +02:00

Started adding support for localisation

This commit is contained in:
Laurent Cozic
2017-07-17 20:26:19 +00:00
parent 70415332d0
commit 58fa4a69b0
10 changed files with 779 additions and 1 deletions

View File

@@ -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');

View File

@@ -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 <EMAIL@ADDRESS>, 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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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 <dir-path>"
msgstr ""
#: app/app.js:135
msgid "Usage: --env <dev|prod>"
msgstr ""
#: app/app.js:160
msgid "Usage: --log-level <none|error|warn|info|debug>"
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 <notebook>`."
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 <editor-path>`"
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 ""

Binary file not shown.

View File

@@ -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 <EMAIL@ADDRESS>, 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 <dir-path>"
msgstr ""
#: app/app.js:135
msgid "Usage: --env <dev|prod>"
msgstr ""
#: app/app.js:160
msgid "Usage: --log-level <none|error|warn|info|debug>"
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 <notebook>`."
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 <editor-path>`"
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 ""

View File

@@ -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['']);

5
CliClient/makepot.sh Executable file
View File

@@ -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

View File

@@ -47,6 +47,7 @@
"babel-preset-env": "^1.5.1", "babel-preset-env": "^1.5.1",
"babel-preset-es2015": "^6.1.4", "babel-preset-es2015": "^6.1.4",
"babel-preset-react": "^6.24.1", "babel-preset-react": "^6.24.1",
"gettext-parser": "^1.2.2",
"jasmine": "^2.6.0" "jasmine": "^2.6.0"
}, },
"scripts": { "scripts": {

237
CliClient/translation.pot Normal file
View File

@@ -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 <EMAIL@ADDRESS>, 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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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 <dir-path>"
msgstr ""
#: app/app.js:135
msgid "Usage: --env <dev|prod>"
msgstr ""
#: app/app.js:160
msgid "Usage: --log-level <none|error|warn|info|debug>"
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 <notebook>`."
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 <editor-path>`"
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 ""

View File

@@ -909,7 +909,7 @@ electron-to-chromium@^1.3.14:
version "1.3.15" version "1.3.15"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.15.tgz#08397934891cbcfaebbd18b82a95b5a481138369" 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" version "0.1.12"
resolved "https://registry.yarnpkg.com/encoding/-/encoding-0.1.12.tgz#538b66f3ee62cd1ab51ec323829d1f9480c74beb" resolved "https://registry.yarnpkg.com/encoding/-/encoding-0.1.12.tgz#538b66f3ee62cd1ab51ec323829d1f9480c74beb"
dependencies: dependencies:
@@ -1103,6 +1103,12 @@ getpass@^0.1.1:
dependencies: dependencies:
assert-plus "^1.0.0" 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: glob-base@^0.3.0:
version "0.3.0" version "0.3.0"
resolved "https://registry.yarnpkg.com/glob-base/-/glob-base-0.3.0.tgz#dbb164f6221b1c0b1ccf82aea328b497df0ea3c4" resolved "https://registry.yarnpkg.com/glob-base/-/glob-base-0.3.0.tgz#dbb164f6221b1c0b1ccf82aea328b497df0ea3c4"

View File

@@ -6,4 +6,8 @@ function _(s, ...args) {
return sprintf(s, ...args); return sprintf(s, ...args);
} }
function loadLocale(locale) {
}
export { _ }; export { _ };