%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/emergentqj/actioncivile/pre-auth/.632e77b3fb93bc8da5b589b869bc0037/static/js/utils/
Upload File :
Create Path :
Current File : /home/emergentqj/actioncivile/pre-auth/.632e77b3fb93bc8da5b589b869bc0037/static/js/utils/getTranslations.js

import countryConfig from "config/countryData";

const {
  countryData,
  langData,
} = countryConfig;

export const getTranslationItem = (languageCode) => {
  const langItem = langData.find((lang) => lang.code === languageCode);
  return (langItem)
    ? {
      name: langItem.nativename,
      code: langItem.code,
    }
    : null;
};

export const getTranslations = (countryCode) => {
  const country = countryData[countryCode];

  // We have the country, we have the translations

  if (country && country.translations) {
    return country.translations
      .map(getTranslationItem)
      .filter((item) => item != null);
  }

  // No country, offer fallback

  const translations = [{
    name: "English",
    code: "en",
  }];

  translations.sort((a, b) => a.name > b.name);

  return translations;
};

Zerion Mini Shell 1.0