mirror of https://github.com/keeweb/keeweb.git
don't shorten locale
This commit is contained in:
parent
cd037f8e86
commit
da1c4fd4f3
|
@ -63,7 +63,10 @@ const SettingsManager = {
|
|||
|
||||
getBrowserLocale: function() {
|
||||
const language = navigator.languages && navigator.languages[0] || navigator.language;
|
||||
return language ? language.substr(0, 2).toLowerCase() : null;
|
||||
if (language && language.lastIndexOf('en', 0) === 0) {
|
||||
return 'en';
|
||||
}
|
||||
return language;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -60,9 +60,6 @@ const AppSettingsModel = Backbone.Model.extend({
|
|||
if (data.rememberKeyFiles === true) {
|
||||
data.rememberKeyFiles = 'data';
|
||||
}
|
||||
if (data.locale && data.locale.length > 2) {
|
||||
data.locale = data.locale.substr(0, 2);
|
||||
}
|
||||
},
|
||||
|
||||
save: function() {
|
||||
|
|
|
@ -58,16 +58,16 @@ const SettingsGeneralView = Backbone.View.extend({
|
|||
},
|
||||
|
||||
allLocales: {
|
||||
en: 'English',
|
||||
de: 'Deutsch',
|
||||
es: 'Español',
|
||||
fr: 'Français',
|
||||
it: 'Italiano',
|
||||
nl: 'Nederlands',
|
||||
pl: 'Polski',
|
||||
pt: 'Português',
|
||||
ru: 'Русский',
|
||||
zh: '汉语'
|
||||
'en': 'English',
|
||||
'de-DE': 'Deutsch',
|
||||
'es-ES': 'Español',
|
||||
'fr-FR': 'Français',
|
||||
'it-IT': 'Italiano',
|
||||
'nl-NL': 'Nederlands',
|
||||
'pl': 'Polski',
|
||||
'pt-PT': 'Português',
|
||||
'ru-RU': 'Русский',
|
||||
'zh-CN': '汉语'
|
||||
},
|
||||
|
||||
initialize: function() {
|
||||
|
|
|
@ -30,29 +30,28 @@ https.get(url, res => {
|
|||
return;
|
||||
}
|
||||
console.log('Response received, reading...');
|
||||
let data = [];
|
||||
const data = [];
|
||||
res.on('data', chunk => data.push(chunk));
|
||||
res.on('end', () => {
|
||||
console.log('Data received, parsing...');
|
||||
let json = Buffer.concat(data).toString('utf8');
|
||||
let languages = JSON.parse(json);
|
||||
const json = Buffer.concat(data).toString('utf8');
|
||||
const languages = JSON.parse(json);
|
||||
let langCount = 0;
|
||||
let skipCount = 0;
|
||||
let totalPhraseCount = Object.keys(languages['en-US'].translation).length;
|
||||
const totalPhraseCount = Object.keys(languages['en-US'].translation).length;
|
||||
Object.keys(languages).forEach(lang => {
|
||||
let languageTranslations = languages[lang].translation;
|
||||
lang = lang.substr(0, 2);
|
||||
if (lang === 'en' || !languageTranslations) {
|
||||
const languageTranslations = languages[lang].translation;
|
||||
if (lang === 'en-US' || !languageTranslations) {
|
||||
return;
|
||||
}
|
||||
let langPhraseCount = Object.keys(languageTranslations).length;
|
||||
let percentage = Math.round(langPhraseCount / totalPhraseCount * 100);
|
||||
let included = percentage >= PHRASE_COUNT_THRESHOLD_PERCENT;
|
||||
let action = included ? 'OK' : 'SKIP';
|
||||
const langPhraseCount = Object.keys(languageTranslations).length;
|
||||
const percentage = Math.round(langPhraseCount / totalPhraseCount * 100);
|
||||
const included = percentage >= PHRASE_COUNT_THRESHOLD_PERCENT;
|
||||
const action = included ? 'OK' : 'SKIP';
|
||||
console.log(`${lang}: ${langPhraseCount} / ${totalPhraseCount} (${percentage}%) -> ${action}`);
|
||||
if (included) {
|
||||
langCount++;
|
||||
let languageJson = JSON.stringify(languageTranslations, null, 4);
|
||||
const languageJson = JSON.stringify(languageTranslations, null, 4);
|
||||
fs.writeFileSync(`app/scripts/locales/${lang}.json`, languageJson);
|
||||
} else {
|
||||
skipCount++;
|
||||
|
|
Loading…
Reference in New Issue