mirror of https://github.com/zulip/zulip.git
i18n: Fix TypeScript noUncheckedIndexedAccess errors.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
eedde08f24
commit
6a429603ad
|
@ -5,6 +5,7 @@ import type {MessageDescriptor} from "@formatjs/intl";
|
|||
import {DEFAULT_INTL_CONFIG, IntlErrorCode, createIntl, createIntlCache} from "@formatjs/intl";
|
||||
import type {FormatXMLElementFn, PrimitiveType} from "intl-messageformat";
|
||||
import _ from "lodash";
|
||||
import assert from "minimalistic-assert";
|
||||
|
||||
import {page_params} from "./base_page_params";
|
||||
|
||||
|
@ -53,13 +54,9 @@ export function $t_html(
|
|||
export let language_list: (typeof page_params & {page_type: "home"})["language_list"];
|
||||
|
||||
export function get_language_name(language_code: string): string {
|
||||
const language_list_map: Record<string, string> = {};
|
||||
|
||||
// One-to-one mapping from code to name for all languages
|
||||
for (const language of language_list) {
|
||||
language_list_map[language.code] = language.name;
|
||||
}
|
||||
return language_list_map[language_code];
|
||||
const language = language_list.find((language) => language.code === language_code);
|
||||
assert(language !== undefined);
|
||||
return language.name;
|
||||
}
|
||||
|
||||
export function initialize(language_params: {language_list: typeof language_list}): void {
|
||||
|
|
Loading…
Reference in New Issue