put supported languages in one constants file
This commit is contained in:
parent
4a0855e074
commit
ef1f6e9836
5 changed files with 23 additions and 8 deletions
|
@ -4,7 +4,8 @@ import isDev from 'electron-is-dev';
|
|||
import windowStateKeeper from 'electron-window-state';
|
||||
|
||||
import setupBarMenu from './menu/setupBarMenu';
|
||||
import * as PAGES from '../ui/constants/pages';
|
||||
import * as PAGES from '../../ui/constants/pages';
|
||||
import SUPPORTED_LANGUAGES from '../../ui/constants/supported_languages';
|
||||
|
||||
export default appState => {
|
||||
// Get primary display dimensions from Electron.
|
||||
|
@ -150,7 +151,9 @@ export default appState => {
|
|||
async function setLanguage(window) {
|
||||
const storedLanguage = await window.webContents.executeJavaScript("localStorage.getItem('language')");
|
||||
const lang = storedLanguage || app.getLocale().slice(0, 2) || 'en';
|
||||
if (['pl', 'id', 'de'].includes(lang)) {
|
||||
|
||||
const supportedNonEnglish = Object.keys(SUPPORTED_LANGUAGES).filter(language => language !== 'en');
|
||||
if (supportedNonEnglish.includes(lang)) {
|
||||
const response = await fetch('https://lbry.com/i18n/get/lbry-desktop/app-strings/' + lang + '.json');
|
||||
const json = await response.json();
|
||||
const messages = {};
|
||||
|
|
14
src/ui/constants/supported_languages.js
Normal file
14
src/ui/constants/supported_languages.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
import LANGUAGES from './languages';
|
||||
|
||||
const SUPPORTED_LANGUAGES = {
|
||||
en: LANGUAGES.en[1],
|
||||
pl: LANGUAGES.pl[1],
|
||||
id: LANGUAGES.id[1],
|
||||
de: LANGUAGES.de[1],
|
||||
fr: LANGUAGES.fr[1],
|
||||
sk: LANGUAGES.sk[1],
|
||||
tr: LANGUAGES.tr[1],
|
||||
zh: LANGUAGES.zh[1]
|
||||
};
|
||||
|
||||
export default SUPPORTED_LANGUAGES;
|
|
@ -4,6 +4,7 @@ import React, { useState } from 'react';
|
|||
import { FormField } from 'component/common/form';
|
||||
import Spinner from 'component/spinner';
|
||||
import { SETTINGS } from 'lbry-redux';
|
||||
import SUPPORTED_LANGUAGES from '../../constants/supported_languages';
|
||||
|
||||
type Props = {
|
||||
language: string,
|
||||
|
@ -13,9 +14,7 @@ type Props = {
|
|||
|
||||
function SettingLanguage(props: Props) {
|
||||
const [isFetching, setIsFetching] = useState(false);
|
||||
|
||||
// this should be fetched from lbry.com/transifex
|
||||
const languages = { en: 'English', pl: 'Polski', id: 'Bahasa Indonesia', de: 'Deutsche' , fr: 'Français', sk: 'Slovenský', tr: 'Türk', zh: '中文' };
|
||||
const languages = SUPPORTED_LANGUAGES;
|
||||
|
||||
const { language, showToast, setClientSetting } = props;
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ const LANGUAGES = {
|
|||
kv: ['Komi', 'Коми'],
|
||||
kw: ['Cornish', 'Kernewek'],
|
||||
ky: ['Kirghiz', 'Kırgızca / Кыргызча'],
|
||||
la: ['Latin', 'Latina'],
|
||||
la: ['Latin', 'Latina'],const languages = { en: 'English', pl: 'Polski', id: 'Bahasa Indonesia', de: 'Deutsche' , fr: 'Français', sk: 'Slovenský', tr: 'Türk', zh: '中文' };
|
||||
lb: ['Luxembourgish', 'Lëtzebuergesch'],
|
||||
lg: ['Ganda', 'Luganda'],
|
||||
li: ['Limburgian', 'Limburgs'],
|
||||
|
|
|
@ -13,7 +13,7 @@ import ReactDOM from 'react-dom';
|
|||
import { Provider } from 'react-redux';
|
||||
import { doConditionalAuthNavigate, doDaemonReady, doAutoUpdate, doOpenModal, doHideModal } from 'redux/actions/app';
|
||||
import { Lbry, doToast, isURIValid, setSearchApi } from 'lbry-redux';
|
||||
import { doUpdateIsNightAsync, doSetClientSetting } from 'redux/actions/settings';
|
||||
import { doUpdateIsNightAsync } from 'redux/actions/settings';
|
||||
import {
|
||||
doAuthenticate,
|
||||
Lbryio,
|
||||
|
@ -197,7 +197,6 @@ ipcRenderer.on('devtools-is-opened', () => {
|
|||
ipcRenderer.on('language-update', (event, messages, language) => {
|
||||
window.i18n_messages = messages;
|
||||
window.localStorage.setItem(SETTINGS.LANGUAGE, language);
|
||||
doSetClientSetting(SETTINGS.LANGUAGE, language);
|
||||
});
|
||||
|
||||
// Force exit mode for html5 fullscreen api
|
||||
|
|
Loading…
Reference in a new issue