mirror of
https://github.com/zulip/zulip-desktop.git
synced 2025-10-23 03:31:56 +00:00
Compare commits
1 Commits
v2.5.0-bet
...
i18n
Author | SHA1 | Date | |
---|---|---|---|
|
411150fd72 |
@@ -10,6 +10,8 @@ const ConfigUtil = require(__dirname + '/../renderer/js/utils/config-util.js');
|
||||
|
||||
const appName = app.getName();
|
||||
|
||||
const i18n = require(__dirname + '/../translations/i18n');
|
||||
|
||||
class AppMenu {
|
||||
getHistorySubmenu() {
|
||||
return [{
|
||||
@@ -246,15 +248,15 @@ class AppMenu {
|
||||
}, {
|
||||
label: 'Edit',
|
||||
submenu: [{
|
||||
role: 'undo'
|
||||
role: 'undo', label: i18n._('Undo')
|
||||
}, {
|
||||
role: 'redo'
|
||||
role: 'redo', label: i18n._('Redo')
|
||||
}, {
|
||||
type: 'separator'
|
||||
}, {
|
||||
role: 'cut'
|
||||
role: 'cut', label: i18n._('Cut')
|
||||
}, {
|
||||
role: 'copy'
|
||||
role: 'copy', label: i18n._('Copy')
|
||||
}, {
|
||||
role: 'paste'
|
||||
}, {
|
||||
@@ -334,11 +336,11 @@ class AppMenu {
|
||||
accelerator: 'Ctrl+Q'
|
||||
}]
|
||||
}, {
|
||||
label: 'Edit',
|
||||
label: i18n.__('Edit'),
|
||||
submenu: [{
|
||||
role: 'undo'
|
||||
role: 'undo', label: i18n.__('Undo')
|
||||
}, {
|
||||
role: 'redo'
|
||||
role: 'redo', label: i18n.__('Redo')
|
||||
}, {
|
||||
type: 'separator'
|
||||
}, {
|
||||
|
@@ -41,6 +41,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
if (serverLanguage) {
|
||||
// Set spellcheker language
|
||||
ConfigUtil.setConfigItem('spellcheckerLanguage', serverLanguage);
|
||||
|
||||
// Init spellchecker
|
||||
SetupSpellChecker.init();
|
||||
}
|
||||
|
4
app/translations/de.json
Normal file
4
app/translations/de.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"Edit": "Redigera",
|
||||
"Undo": "Ångra"
|
||||
}
|
4
app/translations/en.json
Normal file
4
app/translations/en.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"Edit": "Edit",
|
||||
"Undo": "Undo"
|
||||
}
|
34
app/translations/i18n.js
Normal file
34
app/translations/i18n.js
Normal file
@@ -0,0 +1,34 @@
|
||||
const path = require('path');
|
||||
const electron = require('electron');
|
||||
const fs = require('fs');
|
||||
|
||||
const ConfigUtil = require(__dirname + '/../renderer/js/utils/config-util.js');
|
||||
|
||||
class i18n {
|
||||
constructor() {
|
||||
this.app = electron.app ? electron.app : electron.remote.app;
|
||||
this.appLanguage = ConfigUtil.getConfigItem('spellcheckerLanguage');
|
||||
this.appLocale = path.join(__dirname, this.appLanguage + '.json');
|
||||
|
||||
if (fs.existsSync(this.appLocale)) {
|
||||
this.loadedLanguage = JSON.parse(fs.readFileSync(this.appLocale, 'utf8'));
|
||||
console.log('translate into', this.appLanguage);
|
||||
console.log(this.loadedLanguage);
|
||||
} else {
|
||||
this.loadedLanguage = JSON.parse(fs.readFileSync(path.join(__dirname, 'en.json'), 'utf8'));
|
||||
console.log('no lang found');
|
||||
console.log(this.loadedLanguage);
|
||||
}
|
||||
}
|
||||
|
||||
_(phrase) {
|
||||
let translation = this.loadedLanguage[phrase];
|
||||
if (translation === undefined) {
|
||||
translation = phrase;
|
||||
}
|
||||
return translation;
|
||||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line new-cap
|
||||
module.exports = new i18n();
|
Reference in New Issue
Block a user