Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 168x 20x 20x 148x 148x 148x 148x 148x 148x 148x 149x 168x 168x 1x | import { LangKeyType, LanguageEnum } from './language.interface' /** * Represents a set of utility methods for working with languages. * * @internal * @category Internal * @class */ export class Language { /** * Parses a language string into its corresponding LanguageEnum value. * * @param lang The language string to parse, or null/undefined to default to English. * @returns The LanguageEnum value corresponding to the provided string, or English if the string is invalid or undefined. */ static parseLang(lang?: string | null): LanguageEnum { if (!lang) { return LanguageEnum.ENGLISH } const langKeys = Object.keys(LanguageEnum) const matchingKey = langKeys.find( (key) => LanguageEnum[key as LangKeyType] === lang, ) return matchingKey ? LanguageEnum[matchingKey as LangKeyType] : LanguageEnum.ENGLISH } } |