You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-08-13 22:12:50 +02:00
Detect locale
This commit is contained in:
@@ -11,7 +11,7 @@ import { sprintf } from 'sprintf-js';
|
|||||||
import { vorpalUtils } from 'vorpal-utils.js';
|
import { vorpalUtils } from 'vorpal-utils.js';
|
||||||
import { reg } from 'lib/registry.js';
|
import { reg } from 'lib/registry.js';
|
||||||
import { fileExtension } from 'lib/path-utils.js';
|
import { fileExtension } from 'lib/path-utils.js';
|
||||||
import { _, setLocale } from 'lib/locale.js';
|
import { _, setLocale, defaultLocale, closestSupportedLocale } from 'lib/locale.js';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import fs from 'fs-extra';
|
import fs from 'fs-extra';
|
||||||
|
|
||||||
@@ -318,6 +318,16 @@ class Application {
|
|||||||
|
|
||||||
await Setting.load();
|
await Setting.load();
|
||||||
|
|
||||||
|
if (Setting.value('firstStart')) {
|
||||||
|
let locale = process.env.LANG;
|
||||||
|
if (!locale) locale = defaultLocale();
|
||||||
|
locale = locale.split('.');
|
||||||
|
locale = locale[0];
|
||||||
|
reg.logger().info('First start: detected locale as ' + locale);
|
||||||
|
Setting.setValue('locale', closestSupportedLocale(locale));
|
||||||
|
Setting.setValue('firstStart', 0)
|
||||||
|
}
|
||||||
|
|
||||||
setLocale(Setting.value('locale'));
|
setLocale(Setting.value('locale'));
|
||||||
|
|
||||||
this.loadCommands_();
|
this.loadCommands_();
|
||||||
|
@@ -415,6 +415,9 @@ msgstr ""
|
|||||||
msgid "New notebook"
|
msgid "New notebook"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "There are currently no notes. Create one by clicking on the (+) button."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Log"
|
msgid "Log"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
@@ -434,6 +437,9 @@ msgstr ""
|
|||||||
msgid "The notebook could not be saved: %s"
|
msgid "The notebook could not be saved: %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Edit notebook"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Untitled"
|
msgid "Untitled"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
@@ -470,10 +476,10 @@ msgstr ""
|
|||||||
msgid "Delete notebook"
|
msgid "Delete notebook"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "Edit notebook"
|
msgid "Login with OneDrive"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "There are currently no notes. Create one by clicking on the (+) button."
|
msgid "Search"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid ""
|
msgid ""
|
||||||
@@ -483,3 +489,6 @@ msgstr ""
|
|||||||
|
|
||||||
msgid "You currently have no notebook. Create one by clicking on (+) button."
|
msgid "You currently have no notebook. Create one by clicking on (+) button."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Welcome"
|
||||||
|
msgstr ""
|
||||||
|
@@ -450,6 +450,11 @@ msgstr "Nouvelle note"
|
|||||||
msgid "New notebook"
|
msgid "New notebook"
|
||||||
msgstr "Nouveau carnet"
|
msgstr "Nouveau 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 "Log"
|
msgid "Log"
|
||||||
msgstr "Journal"
|
msgstr "Journal"
|
||||||
|
|
||||||
@@ -469,6 +474,9 @@ msgstr "Annuler synchronisation"
|
|||||||
msgid "The notebook could not be saved: %s"
|
msgid "The notebook could not be saved: %s"
|
||||||
msgstr "Ce carnet n'a pas pu être sauvegardé : %s"
|
msgstr "Ce carnet n'a pas pu être sauvegardé : %s"
|
||||||
|
|
||||||
|
msgid "Edit notebook"
|
||||||
|
msgstr "Editer le carnet"
|
||||||
|
|
||||||
msgid "Untitled"
|
msgid "Untitled"
|
||||||
msgstr "Sans titre"
|
msgstr "Sans titre"
|
||||||
|
|
||||||
@@ -505,13 +513,11 @@ msgstr "Supprimer le carnet ?"
|
|||||||
msgid "Delete notebook"
|
msgid "Delete notebook"
|
||||||
msgstr "Supprimer le carnet"
|
msgstr "Supprimer le carnet"
|
||||||
|
|
||||||
msgid "Edit notebook"
|
msgid "Login with OneDrive"
|
||||||
msgstr "Editer le carnet"
|
msgstr ""
|
||||||
|
|
||||||
msgid "There are currently no notes. Create one by clicking on the (+) button."
|
msgid "Search"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Ce carnet ne contient aucune note. Créez-en une en cliquant sur le bouton "
|
|
||||||
"(+)."
|
|
||||||
|
|
||||||
msgid ""
|
msgid ""
|
||||||
"Click on the (+) button to create a new note or notebook. Click on the side "
|
"Click on the (+) button to create a new note or notebook. Click on the side "
|
||||||
@@ -525,6 +531,9 @@ msgstr ""
|
|||||||
"Vous n'avez pour l'instant pas de carnets. Créez-en un en pressant le bouton "
|
"Vous n'avez pour l'instant pas de carnets. Créez-en un en pressant le bouton "
|
||||||
"(+)."
|
"(+)."
|
||||||
|
|
||||||
|
msgid "Welcome"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#~ msgid ""
|
#~ msgid ""
|
||||||
#~ "There is currently no notebook. Create one by clicking on the (+) button."
|
#~ "There is currently no notebook. Create one by clicking on the (+) button."
|
||||||
#~ msgstr ""
|
#~ msgstr ""
|
||||||
|
@@ -415,6 +415,9 @@ msgstr ""
|
|||||||
msgid "New notebook"
|
msgid "New notebook"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "There are currently no notes. Create one by clicking on the (+) button."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Log"
|
msgid "Log"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
@@ -434,6 +437,9 @@ msgstr ""
|
|||||||
msgid "The notebook could not be saved: %s"
|
msgid "The notebook could not be saved: %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Edit notebook"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Untitled"
|
msgid "Untitled"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
@@ -470,10 +476,10 @@ msgstr ""
|
|||||||
msgid "Delete notebook"
|
msgid "Delete notebook"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "Edit notebook"
|
msgid "Login with OneDrive"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "There are currently no notes. Create one by clicking on the (+) button."
|
msgid "Search"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid ""
|
msgid ""
|
||||||
@@ -483,3 +489,6 @@ msgstr ""
|
|||||||
|
|
||||||
msgid "You currently have no notebook. Create one by clicking on (+) button."
|
msgid "You currently have no notebook. Create one by clicking on (+) button."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Welcome"
|
||||||
|
msgstr ""
|
||||||
|
@@ -292,4 +292,4 @@ function _(s, ...args) {
|
|||||||
return sprintf(result, ...args);
|
return sprintf(result, ...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
export { _, supportedLocales, localeStrings, setLocale, supportedLocalesToLanguages, defaultLocale };
|
export { _, supportedLocales, localeStrings, setLocale, supportedLocalesToLanguages, defaultLocale, closestSupportedLocale };
|
@@ -85,6 +85,11 @@ class Setting extends BaseModel {
|
|||||||
this.scheduleUpdate();
|
this.scheduleUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static formatValue(type, value) {
|
||||||
|
if (type == 'int') return Math.floor(Number(value));
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
static value(key) {
|
static value(key) {
|
||||||
if (key in this.constants_) {
|
if (key in this.constants_) {
|
||||||
let output = this.constants_[key];
|
let output = this.constants_[key];
|
||||||
@@ -94,14 +99,15 @@ class Setting extends BaseModel {
|
|||||||
|
|
||||||
if (!this.cache_) throw new Error('Settings have not been initialized!');
|
if (!this.cache_) throw new Error('Settings have not been initialized!');
|
||||||
|
|
||||||
|
const md = this.settingMetadata(key);
|
||||||
|
|
||||||
for (let i = 0; i < this.cache_.length; i++) {
|
for (let i = 0; i < this.cache_.length; i++) {
|
||||||
if (this.cache_[i].key == key) {
|
if (this.cache_[i].key == key) {
|
||||||
return this.cache_[i].value;
|
return this.formatValue(md.type, this.cache_[i].value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let s = this.settingMetadata(key);
|
return this.formatValue(md.type, md.value);
|
||||||
return s.value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static isEnum(key) {
|
static isEnum(key) {
|
||||||
@@ -184,6 +190,7 @@ class Setting extends BaseModel {
|
|||||||
delete s.appTypes;
|
delete s.appTypes;
|
||||||
delete s.label;
|
delete s.label;
|
||||||
delete s.options;
|
delete s.options;
|
||||||
|
s.value = this.formatValue(s.type, s.value);
|
||||||
queries.push(Database.insertQuery(this.tableName(), s));
|
queries.push(Database.insertQuery(this.tableName(), s));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,6 +235,7 @@ Setting.SYNC_TARGET_ONEDRIVE = 3;
|
|||||||
|
|
||||||
Setting.metadata_ = {
|
Setting.metadata_ = {
|
||||||
'activeFolderId': { value: '', type: 'string', public: false },
|
'activeFolderId': { value: '', type: 'string', public: false },
|
||||||
|
'firstStart': { value: 1, type: 'int', public: false },
|
||||||
'sync.2.path': { value: '', type: 'string', public: true, appTypes: ['cli'] },
|
'sync.2.path': { value: '', type: 'string', public: true, appTypes: ['cli'] },
|
||||||
'sync.3.auth': { value: '', type: 'string', public: false },
|
'sync.3.auth': { value: '', type: 'string', public: false },
|
||||||
'sync.target': { value: Setting.SYNC_TARGET_ONEDRIVE, type: 'enum', public: true, label: () => _('Synchronisation target'), options: () => {
|
'sync.target': { value: Setting.SYNC_TARGET_ONEDRIVE, type: 'enum', public: true, label: () => _('Synchronisation target'), options: () => {
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { BackHandler, Keyboard } from 'react-native';
|
import { BackHandler, Keyboard, NativeModules } from 'react-native';
|
||||||
import { connect, Provider } from 'react-redux'
|
import { connect, Provider } from 'react-redux'
|
||||||
import { createStore, applyMiddleware } from 'redux';
|
import { createStore, applyMiddleware } from 'redux';
|
||||||
import { shimInit } from 'lib/shim-init-react.js';
|
import { shimInit } from 'lib/shim-init-react.js';
|
||||||
@@ -31,7 +31,7 @@ import { SideMenu } from 'lib/components/side-menu.js';
|
|||||||
import { SideMenuContent } from 'lib/components/side-menu-content.js';
|
import { SideMenuContent } from 'lib/components/side-menu-content.js';
|
||||||
import { DatabaseDriverReactNative } from 'lib/database-driver-react-native';
|
import { DatabaseDriverReactNative } from 'lib/database-driver-react-native';
|
||||||
import { reg } from 'lib/registry.js';
|
import { reg } from 'lib/registry.js';
|
||||||
import { _, setLocale } from 'lib/locale.js';
|
import { _, setLocale, closestSupportedLocale, defaultLocale } from 'lib/locale.js';
|
||||||
import RNFetchBlob from 'react-native-fetch-blob';
|
import RNFetchBlob from 'react-native-fetch-blob';
|
||||||
import { PoorManIntervals } from 'lib/poor-man-intervals.js';
|
import { PoorManIntervals } from 'lib/poor-man-intervals.js';
|
||||||
|
|
||||||
@@ -401,6 +401,13 @@ async function initialize(dispatch, backButtonHandler) {
|
|||||||
reg.logger().info('Loading settings...');
|
reg.logger().info('Loading settings...');
|
||||||
await Setting.load();
|
await Setting.load();
|
||||||
|
|
||||||
|
if (Setting.value('firstStart')) {
|
||||||
|
const locale = NativeModules.I18nManager.localeIdentifier
|
||||||
|
if (!locale) locale = defaultLocale();
|
||||||
|
Setting.setValue('locale', closestSupportedLocale(locale));
|
||||||
|
Setting.setValue('firstStart', 0)
|
||||||
|
}
|
||||||
|
|
||||||
setLocale(Setting.value('locale'));
|
setLocale(Setting.value('locale'));
|
||||||
|
|
||||||
reg.logger().info('Loading folders...');
|
reg.logger().info('Loading folders...');
|
||||||
|
Reference in New Issue
Block a user