1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-12-14 23:26:58 +02:00

Detect locale

This commit is contained in:
Laurent Cozic
2017-07-25 18:57:06 +00:00
parent e2af824106
commit e128077326
7 changed files with 70 additions and 18 deletions

View File

@@ -85,6 +85,11 @@ class Setting extends BaseModel {
this.scheduleUpdate();
}
static formatValue(type, value) {
if (type == 'int') return Math.floor(Number(value));
return value;
}
static value(key) {
if (key in this.constants_) {
let output = this.constants_[key];
@@ -94,14 +99,15 @@ class Setting extends BaseModel {
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++) {
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 s.value;
return this.formatValue(md.type, md.value);
}
static isEnum(key) {
@@ -184,6 +190,7 @@ class Setting extends BaseModel {
delete s.appTypes;
delete s.label;
delete s.options;
s.value = this.formatValue(s.type, s.value);
queries.push(Database.insertQuery(this.tableName(), s));
}
@@ -228,6 +235,7 @@ Setting.SYNC_TARGET_ONEDRIVE = 3;
Setting.metadata_ = {
'activeFolderId': { value: '', type: 'string', public: false },
'firstStart': { value: 1, type: 'int', public: false },
'sync.2.path': { value: '', type: 'string', public: true, appTypes: ['cli'] },
'sync.3.auth': { value: '', type: 'string', public: false },
'sync.target': { value: Setting.SYNC_TARGET_ONEDRIVE, type: 'enum', public: true, label: () => _('Synchronisation target'), options: () => {