All files / web/bundles/pimui/js i18n.ts

85.71% Statements 12/14
83.33% Branches 10/12
100% Functions 3/3
84.62% Lines 11/13

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 321183x 4714x                     6025x 4714x       4714x 4714x 4714x   4714x       4714x     1183x 41217x    
const flagTemplate = (country: string, language: string, displayLanguage: boolean) => {
  return `
<span class="flag-language">
  <i class="flag flag-${country}"></i>${
    displayLanguage
      ? `
  <span class="language">${language}</span>`
      : ''
  }
</span>`;
};
 
export const getFlag = (locale: string, displayLanguage: boolean = true): string => {
  Iif (!locale) {
    return '';
  }
 
  const info = locale.split('_');
  let language = info[0];
  let country = info[1];
 
  Iif (3 === info.length) {
    country = info[2];
  }
 
  return flagTemplate(country.toLowerCase(), language, displayLanguage);
};
 
export const getLabel = (labels: {[locale: string]: string}, locale: string, fallback: string): string => {
  return (labels && labels[locale]) ? labels[locale] : `[${fallback}]`;
};