All files / components/enum KoconutLocale.ts

100% Statements 26/26
66.66% Branches 4/6
100% Functions 4/4
100% Lines 26/26

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 33 34 35 36 37 38 39 40 41 42  1x   1x   1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x     1x 1x     1x 1x   1x 1x 18x   1x 1x 1x              
/* eslint-disable no-unused-vars */
`use strict`;
// ref http://www.lingoes.net/en/translator/langcode.html
export enum KoconutLocale {
  // English
  en = 'en', // English
  en_AU = 'en-AU', // Australia
  en_BZ = 'en-BZ', // Belize
  en_CA = 'en-CA', // Canada
  en_CB = 'en-CB', // Caribbean
  en_GB = 'en-GB', // United Kingdom
  en_IE = 'en-IE', // Ireland
  en_JM = 'en-JM', // Jamaica
  en_NZ = 'en-NZ', // New Zealand
  en_PH = 'en-PH', // Republic of the Philippines
  en_TT = 'en-TT', // Trinidad and Tobago
  en_US = 'en-US', // United States
  en_ZA = 'en-ZA', // South Africa
  en_ZW = 'en-ZW', // Zimbabwe
 
  // Japanese
  ja = 'ja', // Japanese,
  ja_JP = 'ja-JP', // Japan
 
  // Korean
  ko = 'ko', // Korean
  ko_KR = 'ko-KR', // Korea
}
const localeNames = Object.values(KoconutLocale);
const upperCaseLocaleNames = localeNames.map((eachName) =>
  eachName.toString().toUpperCase(),
);
export namespace KoconutLocale {
  export function fromString(localeString: string): KoconutLocale {
    return upperCaseLocaleNames.includes(localeString.toUpperCase())
      ? (localeNames[
          upperCaseLocaleNames.indexOf(localeString.toUpperCase())
        ] as KoconutLocale)
      : KoconutLocale.en_US;
  }
}