mirror of
https://github.com/zulip/zulip-desktop.git
synced 2025-11-05 06:23:14 +00:00
general-section: Import supported-locales.json as a JSON module.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
@@ -10,6 +10,7 @@ import BaseSection from './base-section';
|
|||||||
import * as ConfigUtil from '../../utils/config-util';
|
import * as ConfigUtil from '../../utils/config-util';
|
||||||
import * as EnterpriseUtil from '../../utils/enterprise-util';
|
import * as EnterpriseUtil from '../../utils/enterprise-util';
|
||||||
import * as t from '../../utils/translation-util';
|
import * as t from '../../utils/translation-util';
|
||||||
|
import supportedLocales from '../../../../translations/supported-locales.json';
|
||||||
|
|
||||||
export default class GeneralSection extends BaseSection {
|
export default class GeneralSection extends BaseSection {
|
||||||
// TODO: TypeScript - Here props should be object type
|
// TODO: TypeScript - Here props should be object type
|
||||||
@@ -407,10 +408,7 @@ export default class GeneralSection extends BaseSection {
|
|||||||
setLocale(): void {
|
setLocale(): void {
|
||||||
const langDiv: HTMLSelectElement = document.querySelector('.lang-div');
|
const langDiv: HTMLSelectElement = document.querySelector('.lang-div');
|
||||||
// This path is for the JSON file that stores key: value pairs for supported locales
|
// This path is for the JSON file that stores key: value pairs for supported locales
|
||||||
const path = __dirname.replace('renderer/js/pages/preference', 'translations/supported-locales.json');
|
const langList = this.generateSelectTemplate(supportedLocales, 'lang-menu');
|
||||||
const data = fs.readFileSync(path, {encoding: 'utf8'});
|
|
||||||
const langs = JSON.parse(data);
|
|
||||||
const langList = this.generateSelectTemplate(langs, 'lang-menu');
|
|
||||||
langDiv.innerHTML += langList;
|
langDiv.innerHTML += langList;
|
||||||
// langMenu is the select-option dropdown menu formed after executing the previous command
|
// langMenu is the select-option dropdown menu formed after executing the previous command
|
||||||
const langMenu: HTMLSelectElement = document.querySelector('.lang-menu');
|
const langMenu: HTMLSelectElement = document.querySelector('.lang-menu');
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
"lib": ["dom", "dom.iterable", "esnext"],
|
"lib": ["dom", "dom.iterable", "esnext"],
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
|
"resolveJsonModule": true,
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
|
|
||||||
/* Strict type-checking */
|
/* Strict type-checking */
|
||||||
|
|||||||
Reference in New Issue
Block a user