1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Support for RN localisation

This commit is contained in:
Laurent Cozic 2017-07-19 22:26:30 +01:00
parent 0ed442930b
commit f529b9e3b9
10 changed files with 307 additions and 7 deletions

View File

@ -98,6 +98,17 @@ async function mergePotToPo(potFilePath, poFilePath) {
await removePoHeaderDate(poFilePath);
}
function buildIndex(locales) {
let output = [];
output.push('var locales = {};');
for (let i = 0; i < locales.length; i++) {
const locale = locales[i];
output.push("locales['" + locale + "'] = require('./" + locale + ".json');");
}
output.push('module.exports = { locales: locales };');
return output.join("\n");
}
async function main() {
let potFilePath = cliLocalesDir + '/joplin.pot';
let jsonLocalesDir = cliDir + '/build/locales';
@ -108,6 +119,8 @@ async function main() {
rnDir + '/lib/*.js',
rnDir + '/lib/models/*.js',
rnDir + '/lib/services/*.js',
rnDir + '/lib/components/*.js',
rnDir + '/lib/components/screens/*.js',
]);
await execCommand('cp "' + potFilePath + '" ' + '"' + cliLocalesDir + '/' + defaultLocale + '.po"');
@ -123,7 +136,10 @@ async function main() {
buildLocale(poFilePäth, jsonFilePath);
}
saveToFile(jsonLocalesDir + '/index.json', JSON.stringify(locales));
saveToFile(jsonLocalesDir + '/index.js', buildIndex(locales));
const rnJsonLocaleDir = rnDir + '/locales';
await execCommand('rsync -a "' + jsonLocalesDir + '/" "' + rnJsonLocaleDir + '"');
}
main().catch((error) => {

View File

@ -477,3 +477,91 @@ msgstr ""
#, javascript-format
msgid "%s: %d notes"
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/action-button.js:66
msgid "New todo"
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/action-button.js:73
msgid "New note"
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/action-button.js:81
msgid "New folder"
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screen-header.js:145
msgid "Log"
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screen-header.js:150
msgid "Status"
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/folder.js:73
#, javascript-format
msgid "The folder could not be saved: %s"
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/folders.js:21
msgid ""
"There is currently no notebook. Create one by clicking on the (+) button."
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/note.js:153
msgid "Untitled"
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/note.js:169
msgid "Delete note?"
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/note.js:200
msgid "Attach file"
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/note.js:201
msgid "Delete note"
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/note.js:202
msgid "Convert to regular note"
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/note.js:202
msgid "Convert to todo"
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/note.js:203
msgid "Toggle metadata"
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/note.js:362
msgid "Edit"
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/notes.js:23
msgid "Delete notebook?"
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/notes.js:46
msgid "Delete notebook"
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/notes.js:47
msgid "Edit notebook"
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/notes.js:66
msgid "There are currently no notes. Create one by clicking on the (+) button."
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/welcome.js:24
msgid ""
"Click on the (+) button to create a new note or notebook. Click on the side "
"menu to access your existing notebooks."
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/welcome.js:24
msgid "You currently have no notebook. Create one by clicking on (+) button."
msgstr ""

View File

@ -513,6 +513,100 @@ msgstr "Carnets"
msgid "%s: %d notes"
msgstr "%s : %d notes"
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/action-button.js:66
msgid "New todo"
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/action-button.js:73
msgid "New note"
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/action-button.js:81
msgid "New folder"
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screen-header.js:145
msgid "Log"
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screen-header.js:150
#, fuzzy
msgid "Status"
msgstr "Etat : %s."
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/folder.js:73
#, javascript-format
msgid "The folder could not be saved: %s"
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/folders.js:21
msgid ""
"There is currently no notebook. Create one by clicking on the (+) button."
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/note.js:153
msgid "Untitled"
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/note.js:169
#, fuzzy
msgid "Delete note?"
msgstr "Supprimer le carnet \"%s\" ?"
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/note.js:200
msgid "Attach file"
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/note.js:201
#, fuzzy
msgid "Delete note"
msgstr "Supprime le carnet."
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/note.js:202
msgid "Convert to regular note"
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/note.js:202
msgid "Convert to todo"
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/note.js:203
msgid "Toggle metadata"
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/note.js:362
msgid "Edit"
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/notes.js:23
#, fuzzy
msgid "Delete notebook?"
msgstr "Supprimer le carnet \"%s\" ?"
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/notes.js:46
#, fuzzy
msgid "Delete notebook"
msgstr "Supprime le carnet."
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/notes.js:47
#, fuzzy
msgid "Edit notebook"
msgstr "Editer la note."
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/notes.js:66
msgid "There are currently no notes. Create one by clicking on the (+) button."
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/welcome.js:24
msgid ""
"Click on the (+) button to create a new note or notebook. Click on the side "
"menu to access your existing notebooks."
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/welcome.js:24
msgid "You currently have no notebook. Create one by clicking on (+) button."
msgstr ""
#, fuzzy
#~ msgid "Invalid command. Showing help:"
#~ msgstr "Commande invalie : \"%s\""

View File

@ -477,3 +477,91 @@ msgstr ""
#, javascript-format
msgid "%s: %d notes"
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/action-button.js:66
msgid "New todo"
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/action-button.js:73
msgid "New note"
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/action-button.js:81
msgid "New folder"
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screen-header.js:145
msgid "Log"
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screen-header.js:150
msgid "Status"
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/folder.js:73
#, javascript-format
msgid "The folder could not be saved: %s"
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/folders.js:21
msgid ""
"There is currently no notebook. Create one by clicking on the (+) button."
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/note.js:153
msgid "Untitled"
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/note.js:169
msgid "Delete note?"
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/note.js:200
msgid "Attach file"
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/note.js:201
msgid "Delete note"
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/note.js:202
msgid "Convert to regular note"
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/note.js:202
msgid "Convert to todo"
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/note.js:203
msgid "Toggle metadata"
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/note.js:362
msgid "Edit"
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/notes.js:23
msgid "Delete notebook?"
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/notes.js:46
msgid "Delete notebook"
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/notes.js:47
msgid "Edit notebook"
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/notes.js:66
msgid "There are currently no notes. Create one by clicking on the (+) button."
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/welcome.js:24
msgid ""
"Click on the (+) button to create a new note or notebook. Click on the side "
"menu to access your existing notebooks."
msgstr ""
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/welcome.js:24
msgid "You currently have no notebook. Create one by clicking on (+) button."
msgstr ""

View File

@ -181,9 +181,14 @@ let loadedLocales_ = {};
let currentLocale_ = 'en_GB';
function supportedLocales() {
if (supportedLocales_) return supportedLocales_;
supportedLocales_ = require('../locales/index.json');
return supportedLocales_;
if (!supportedLocales_) supportedLocales_ = require('../locales/index.js').locales;
let output = [];
for (let n in supportedLocales_) {
if (!supportedLocales_.hasOwnProperty(n)) continue;
output.push(n);
}
return output;
}
function closestSupportedLocale(canonicalName, defaultToEnglish = true) {
@ -257,7 +262,7 @@ function localeStrings(canonicalName) {
if (loadedLocales_[locale]) return loadedLocales_[locale];
loadedLocales_[locale] = require('../locales/' + locale + '.json');
loadedLocales_[locale] = Object.assign({}, supportedLocales_[locale]);
return loadedLocales_[locale];
}
@ -269,9 +274,7 @@ function setLocale(canonicalName) {
function _(s, ...args) {
let strings = localeStrings(currentLocale_);
let result = strings[s];
if (result === '' || result === undefined) result = s;
return sprintf(result, ...args);
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,4 @@
var locales = {};
locales['en_GB'] = require('./en_GB.json');
locales['fr_FR'] = require('./fr_FR.json');
module.exports = { locales: locales };

View File

@ -0,0 +1 @@
["en_GB","fr_FR"]

View File

@ -32,6 +32,7 @@ import { SideMenu } from 'lib/components/side-menu.js';
import { SideMenuContent } from 'lib/components/side-menu-content.js';
import { DatabaseDriverReactNative } from 'lib/database-driver-react-native';
import { reg } from 'lib/registry.js';
import { _, setLocale } from 'lib/locale.js';
import RNFetchBlob from 'react-native-fetch-blob';
let defaultState = {
@ -370,6 +371,9 @@ async function initialize(dispatch, backButtonHandler) {
reg.logger().info('Loading settings...');
await Setting.load();
// Setting.setValue('locale', 'fr_FR');
// setLocale(Setting.value('locale'));
reg.logger().info('Loading folders...');
await FoldersScreenUtils.refreshFolders();