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

Set locale of RN app

This commit is contained in:
Laurent Cozic 2017-07-24 22:29:40 +01:00
parent fc7163b324
commit 4464fb0f90
11 changed files with 133 additions and 125 deletions

View File

@ -10,7 +10,7 @@ class Command extends BaseCommand {
}
description() {
return _('Creates a new command alias which can then be used as a regular command (eg. `alias ll "ls -l"`).');
return 'Creates a new command alias which can then be used as a regular command (eg. `alias ll "ls -l"`)';
}
async action(args) {

View File

@ -49,11 +49,6 @@ msgstr ""
msgid "No notebook is defined. Create one with `mkbook <notebook>`."
msgstr ""
msgid ""
"Creates a new command alias which can then be used as a regular command (eg. "
"`alias ll \"ls -l\"`)."
msgstr ""
msgid "Displays the given note."
msgstr ""
@ -370,6 +365,9 @@ msgstr ""
msgid "OneDrive"
msgstr ""
msgid "Language"
msgstr ""
msgid "Todo filter"
msgstr ""
@ -432,15 +430,8 @@ msgstr ""
msgid "Cancel synchronization"
msgstr ""
msgid "Save"
msgstr ""
#, javascript-format
msgid "The folder could not be saved: %s"
msgstr ""
msgid ""
"There is currently no notebook. Create one by clicking on the (+) button."
msgid "The notebook could not be saved: %s"
msgstr ""
msgid "Untitled"

View File

@ -13,7 +13,7 @@ msgstr ""
"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"
"X-Generator: Poedit 2.0.3\n"
msgid "No notebook selected."
msgstr "Aucun carnet n'est sélectionné."
@ -51,11 +51,6 @@ msgstr "Quitter le logiciel."
msgid "No notebook is defined. Create one with `mkbook <notebook>`."
msgstr "Aucun carnet n'est défini. Créez-en un avec `mkbook <carnet>`."
msgid ""
"Creates a new command alias which can then be used as a regular command (eg. "
"`alias ll \"ls -l\"`)."
msgstr ""
msgid "Displays the given note."
msgstr "Affiche la note."
@ -66,7 +61,6 @@ msgstr "Affiche tous les détails de la note."
msgid "Cannot find \"%s\"."
msgstr "Impossible de trouver \"%s\"."
#, fuzzy
msgid ""
"Gets or sets a config value. If [value] is not provided, it will show the "
"value of [name]. If neither [name] nor [value] is provided, it will list the "
@ -77,15 +71,15 @@ msgstr ""
"sont fournies, la configuration complète est affichée."
msgid "Also displays hidden config variables."
msgstr ""
msgstr "Afficher également les variables cachées."
#, fuzzy, javascript-format
#, javascript-format
msgid "%s = %s (%s)"
msgstr "%s %s (%s)"
msgstr "%s = %s (%s)"
#, javascript-format
msgid "%s = %s"
msgstr ""
msgstr "%s = %s"
msgid ""
"Duplicates the notes matching <pattern> to [notebook]. If no notebook is "
@ -114,9 +108,8 @@ msgstr ""
"Edition de la note en cours. Fermez l'éditeur de texte pour retourner à "
"l'invite de commande."
#, fuzzy
msgid "Displays a geolocation URL for the note."
msgstr "Affiche tous les détails de la note."
msgstr "Afficher l'URL de l'emplacement de la note."
msgid "Imports an Evernote notebook file (.enex file)."
msgstr "Importer un carnet Evernote (fichier .enex)."
@ -294,7 +287,7 @@ msgstr ""
"Changer de carnet - toutes les opérations à venir se feront dans ce carnet."
msgid "Displays version information"
msgstr "Affiche les informations de version."
msgstr "Affiche les informations de version"
#, javascript-format
msgid "%s %s (%s)"
@ -316,16 +309,17 @@ msgstr "Le logiciel a été autorisé. Vous pouvez maintenant fermer cet onglet.
msgid "The application has been successfully authorised."
msgstr "Le logiciel a été autorisé."
#, fuzzy
msgid "Please open this URL in your browser to authenticate the application:"
msgstr ""
"Veuillez ouvrir cette URL dans votre navigateur internet pour autentifier le "
"logiciel :"
"Veuillez ouvrir cette URL dans votre navigateur internet pour authentifier "
"le logiciel :"
msgid ""
"Please set the \"sync.2.path\" config value to the desired synchronisation "
"destination."
msgstr ""
"Veuillez attribuer une valeur au paramètre de configuration \"sync.2.path\" "
"pour indiquer le dossier où devra se faire la synchronisation."
#, javascript-format
msgid "Created local items: %d."
@ -363,9 +357,9 @@ msgstr "Dernière erreur : %s (Plus d'information dans le journal d'erreurs)"
msgid "Completed: %s"
msgstr "Terminé : %s"
#, fuzzy, javascript-format
#, javascript-format
msgid "Synchronization is already in progress. State: %s"
msgstr "Synchronisation est déjà en cours."
msgstr "Synchronisation est déjà en cours. Etat : %s"
msgid "Conflicts"
msgstr "Conflits"
@ -379,7 +373,7 @@ msgid "Notebooks cannot be named \"%s\", which is a reserved title."
msgstr "Les carnets ne peuvent être nommés \"%s\" car c'est un nom réservé."
msgid "This note does not have geolocation information."
msgstr ""
msgstr "Cette note n'a pas d'information d'emplacement."
#, javascript-format
msgid "Cannot copy note to \"%s\" notebook"
@ -391,33 +385,35 @@ msgstr "Impossible de déplacer la note vers le carnet \"%s\""
#, javascript-format
msgid "Invalid option value: \"%s\". Possible values are: %s."
msgstr ""
msgstr "Option invalide: \"%s\". Les valeurs possibles sont : %s."
#, fuzzy, javascript-format
#, javascript-format
msgid "%s (%s)"
msgstr "%s %s (%s)"
msgstr "%s (%s)"
#, fuzzy
msgid "Synchronisation target"
msgstr "Cible de la synchronisation : %s"
msgstr "Cible de la synchronisation"
msgid "File system"
msgstr ""
msgstr "Système de fichier"
msgid "OneDrive"
msgstr ""
msgstr "OneDrive"
msgid "Language"
msgstr "Langue"
msgid "Todo filter"
msgstr ""
msgstr "Filtre des tâches"
msgid "Show all"
msgstr ""
msgstr "Afficher tous"
msgid "Non-completed and recently completed ones"
msgstr ""
msgstr "Tâches non-complétées et récentes"
msgid "Non-completed ones only"
msgstr ""
msgstr "Tâche complétée seulement"
msgid "Sync status (synced items / total items)"
msgstr "Status de la synchronisation (objets synchro. / total)"
@ -446,97 +442,94 @@ msgid "%s: %d notes"
msgstr "%s : %d notes"
msgid "New todo"
msgstr ""
msgstr "Nouvelle tâche"
msgid "New note"
msgstr ""
msgstr "Nouvelle note"
#, fuzzy
msgid "New notebook"
msgstr "Supprime le carnet."
msgstr "Nouveau carnet"
msgid "Log"
msgstr ""
msgstr "Journal"
#, fuzzy
msgid "Status"
msgstr "Etat : %s."
msgstr "Etat"
msgid "Configuration"
msgstr ""
msgstr "Configuration"
msgid "Synchronize"
msgstr ""
msgstr "Synchroniser"
#, fuzzy
msgid "Cancel synchronization"
msgstr "Commencement de la synchronisation..."
msgstr "Annuler synchronisation"
msgid "Save"
msgstr ""
#, javascript-format
msgid "The folder could not be saved: %s"
msgstr ""
msgid ""
"There is currently no notebook. Create one by clicking on the (+) button."
msgstr ""
#, fuzzy, javascript-format
msgid "The notebook could not be saved: %s"
msgstr "Ce carnet n'a pas pu être sauvegardé : %s"
msgid "Untitled"
msgstr ""
msgstr "Sans titre"
#, fuzzy
msgid "Delete note?"
msgstr "Supprimer le carnet \"%s\" ?"
msgstr "Supprimer la note ?"
msgid "Attach file"
msgstr ""
msgstr "Attacher un fichier"
#, fuzzy
msgid "Delete note"
msgstr "Supprime le carnet."
msgstr "Supprimer la note"
msgid "Convert to regular note"
msgstr ""
msgstr "Convertir en note"
msgid "Convert to todo"
msgstr ""
msgstr "Convertir en tâche"
msgid "Hide metadata"
msgstr ""
msgstr "Cacher les métadonnées"
msgid "Show metadata"
msgstr ""
msgstr "Afficher les métadonnées"
msgid "View location on map"
msgstr ""
msgstr "Voir l'emplacement sur une carte"
msgid "Edit"
msgstr ""
msgstr "Editer"
#, fuzzy
msgid "Delete notebook?"
msgstr "Supprimer le carnet \"%s\" ?"
msgstr "Supprimer le carnet ?"
#, fuzzy
msgid "Delete notebook"
msgstr "Supprime le carnet."
msgstr "Supprimer le carnet"
#, fuzzy
msgid "Edit notebook"
msgstr "Editer la note."
msgstr "Editer le carnet"
msgid "There are currently no notes. Create one by clicking on the (+) button."
msgstr ""
"Ce carnet ne contient aucune note. Créez-en une en cliquant sur le bouton "
"(+)."
msgid ""
"Click on the (+) button to create a new note or notebook. Click on the side "
"menu to access your existing notebooks."
msgstr ""
"Cliquez sur le bouton (+) pour une nouvelle note ou carnet. Ouvrez le menu "
"latéral pour accéder à vos carnets."
msgid "You currently have no notebook. Create one by clicking on (+) button."
msgstr ""
"Vous n'avez pour l'instant pas de carnets. Créez-en un en pressant le bouton "
"(+)."
#~ msgid ""
#~ "There is currently no notebook. Create one by clicking on the (+) button."
#~ msgstr ""
#~ "Il n'y a pour l'instant aucun carnet. Créez-en un en cliquant sur le "
#~ "bouton (+)"
#~ msgid "Synchronizing with directory \"%s\""
#~ msgstr "Synchronisation avec dossier \"%s\""

View File

@ -49,11 +49,6 @@ msgstr ""
msgid "No notebook is defined. Create one with `mkbook <notebook>`."
msgstr ""
msgid ""
"Creates a new command alias which can then be used as a regular command (eg. "
"`alias ll \"ls -l\"`)."
msgstr ""
msgid "Displays the given note."
msgstr ""
@ -370,6 +365,9 @@ msgstr ""
msgid "OneDrive"
msgstr ""
msgid "Language"
msgstr ""
msgid "Todo filter"
msgstr ""
@ -432,15 +430,8 @@ msgstr ""
msgid "Cancel synchronization"
msgstr ""
msgid "Save"
msgstr ""
#, javascript-format
msgid "The folder could not be saved: %s"
msgstr ""
msgid ""
"There is currently no notebook. Create one by clicking on the (+) button."
msgid "The notebook could not be saved: %s"
msgstr ""
msgid "Untitled"

View File

@ -2,13 +2,27 @@ import React, { Component } from 'react';
import { View, StyleSheet, Picker, Text, Button } from 'react-native';
import { connect } from 'react-redux'
import { ScreenHeader } from 'lib/components/screen-header.js';
import { _ } from 'lib/locale.js';
import { _, setLocale } from 'lib/locale.js';
import { BaseScreenComponent } from 'lib/components/base-screen.js';
import { globalStyle } from 'lib/components/global-style.js';
import { Setting } from 'lib/models/setting.js';
let styles = {
body: {}
settingContainer: {
borderBottomWidth: 1,
borderBottomColor: globalStyle.dividerColor,
paddingTop: globalStyle.marginTop,
paddingBottom: globalStyle.marginBottom,
paddingLeft: globalStyle.marginLeft,
paddingRight: globalStyle.marginRight,
},
settingText: {
fontWeight: 'bold',
color: globalStyle.color,
},
settingControl: {
color: globalStyle.color,
},
}
styles = StyleSheet.create(styles);
@ -45,6 +59,7 @@ class ConfigScreenComponent extends BaseScreenComponent {
let values = this.state.values;
values[key] = value;
this.setState({ values: values });
this.saveSettings();
}
const value = this.state.values[key];
@ -58,9 +73,9 @@ class ConfigScreenComponent extends BaseScreenComponent {
}
return (
<View key={key}>
<Text key="label">{setting.label()}</Text>
<Picker key="control" selectedValue={value} onValueChange={(itemValue, itemIndex) => updateSettingValue(key, itemValue)} >
<View key={key} style={styles.settingContainer}>
<Text key="label" style={styles.settingText}>{setting.label()}</Text>
<Picker key="control" style={styles.settingControl} selectedValue={value} onValueChange={(itemValue, itemIndex) => updateSettingValue(key, itemValue)} >
{ items }
</Picker>
</View>
@ -72,13 +87,15 @@ class ConfigScreenComponent extends BaseScreenComponent {
return output;
}
saveButton_press() {
saveSettings() {
const values = this.state.values;
for (let key in values) {
if (!values.hasOwnProperty(key)) continue;
Setting.setValue(key, values[key]);
}
Setting.saveAll();
setLocale(Setting.value('locale'));
}
render() {
@ -86,6 +103,8 @@ class ConfigScreenComponent extends BaseScreenComponent {
let settingComps = [];
for (let key in settings) {
if (key == 'sync.target') continue;
if (!settings.hasOwnProperty(key)) continue;
const comp = this.settingToComponent(key, settings[key]);
if (!comp) continue;
@ -98,7 +117,6 @@ class ConfigScreenComponent extends BaseScreenComponent {
<View style={styles.body}>
{ settingComps }
</View>
<Button title={_('Save')} onPress={() => this.saveButton_press()} />
</View>
);
}

View File

@ -70,7 +70,7 @@ class FolderScreenComponent extends BaseScreenComponent {
reg.scheduleSync();
} catch (error) {
dialogs.error(this, _('The folder could not be saved: %s', error.message));
dialogs.error(this, _('The notebook could not be saved: %s', error.message));
return;
}

View File

@ -18,7 +18,7 @@ class FoldersScreenComponent extends BaseScreenComponent {
return (
<View style={this.styles().screen}>
<ScreenHeader navState={this.props.navigation.state} />
<FolderList noItemMessage={_('There is currently no notebook. Create one by clicking on the (+) button.')} style={{flex: 1}}/>
<FolderList noItemMessage={'There is currently no notebook. Create one by clicking on the (+) button.'} style={{flex: 1}}/>
<ActionButton addFolderNoteButtons={true}></ActionButton>
</View>
);

View File

@ -178,7 +178,13 @@ let supportedLocales_ = null;
let loadedLocales_ = {};
let currentLocale_ = 'en_GB';
const defaultLocale_ = 'en_GB';
let currentLocale_ = defaultLocale_;
function defaultLocale() {
return defaultLocale_;
}
function supportedLocales() {
if (!supportedLocales_) supportedLocales_ = require('../locales/index.js').locales;
@ -191,6 +197,16 @@ function supportedLocales() {
return output;
}
function supportedLocalesToLanguages() {
const locales = supportedLocales();
let output = {};
for (let i = 0; i < locales.length; i++) {
const locale = locales[i];
output[locale] = countryDisplayName(locale);
}
return output;
}
function closestSupportedLocale(canonicalName, defaultToEnglish = true) {
const locales = supportedLocales();
if (locales.indexOf(canonicalName) >= 0) return canonicalName;
@ -210,19 +226,16 @@ function countryName(countryCode) {
return codeToCountry_[countryCode] ? codeToCountry_[countryCode] : '';
}
function languageNameInEnglish(languageCode) {
return codeToLanguageE_[languageCode] ? codeToLanguageE_[languageCode] : '';
}
function languageName(languageCode, defaultToEnglish = true) {
if (codeToLanguage_[languageCode]) return codeToLanguage_[languageCode];
if (defaultToEnglish) return languageNameInEnglish(languageCode)
return '';
}
function languageCodeOnly(canonicalName) {
if (canonicalName.length < 2) return canonicalName;
return canonicalName.substr(0, 2);
@ -279,4 +292,4 @@ function _(s, ...args) {
return sprintf(result, ...args);
}
export { _, supportedLocales, localeStrings, setLocale };
export { _, supportedLocales, localeStrings, setLocale, supportedLocalesToLanguages, defaultLocale };

View File

@ -1,6 +1,6 @@
import { BaseModel } from 'lib/base-model.js';
import { Database } from 'lib/database.js';
import { _ } from 'lib/locale.js';
import { _, supportedLocalesToLanguages, defaultLocale } from 'lib/locale.js';
class Setting extends BaseModel {
@ -239,7 +239,9 @@ Setting.metadata_ = {
}},
'sync.context': { value: '', type: 'string', public: false },
'editor': { value: '', type: 'string', public: true, appTypes: ['cli'] },
'locale': { value: 'en_GB', type: 'string', public: true },
'locale': { value: defaultLocale(), type: 'enum', public: true, label: () => _('Language'), options: () => {
return supportedLocalesToLanguages();
}},
'todoFilter': { value: 'all', type: 'enum', public: true, appTypes: ['mobile'], label: () => _('Todo filter'), options: () => ({
all: _('Show all'),
recent: _('Non-completed and recently completed ones'),

View File

@ -395,9 +395,8 @@ async function initialize(dispatch, backButtonHandler) {
reg.logger().info('Database is ready.');
reg.logger().info('Loading settings...');
await Setting.load();
// Setting.setValue('locale', 'fr_FR');
// setLocale(Setting.value('locale'));
setLocale(Setting.value('locale'));
reg.logger().info('Loading folders...');
@ -410,16 +409,16 @@ async function initialize(dispatch, backButtonHandler) {
let folderId = Setting.value('activeFolderId');
let folder = await Folder.load(folderId);
// dispatch({
// type: 'Navigation/NAVIGATE',
// routeName: 'Config',
// });
dispatch({
type: 'Navigation/NAVIGATE',
routeName: 'Config',
});
if (folder) {
await NotesScreenUtils.openNoteList(folderId);
} else {
await NotesScreenUtils.openDefaultNoteList();
}
// if (folder) {
// await NotesScreenUtils.openNoteList(folderId);
// } else {
// await NotesScreenUtils.openDefaultNoteList();
// }
} catch (error) {
reg.logger().error('Initialization error:', error);
}

View File

@ -30,6 +30,7 @@
"*.po",
"*.pot",
"locales/*.json",
"ReactNativeClient/locales/*",
]
}
]