How to use the ttag.useLocales function in ttag

To help you get started, we’ve selected a few ttag examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sozialhelden / wheelmap-frontend / src / lib / i18n.js View on Github external
export function addTranslationsToTTag(translations: Translations[]) {
  const localesToUse: Locale[] = [];

  // register with ttag
  for (const t of translations) {
    const locale = localeFromString(t.headers.language);
    addLocale(locale.string, t);
    localesToUse.push(locale);
  }

  console.log('Available locales:', localesToUse.map(l => l.string));

  // set locale in ttag
  useLocales(localesToUse.map(locale => locale.string));

  // update active locales
  // we need to modify the actual array content, so that all imported references get the changes
  currentLocales.splice(0, currentLocales.length);
  currentLocales.push(...localesToUse);
}
github sozialhelden / wheelmap-frontend / test / specs / generateScreenshots.js View on Github external
function loadAllLocales() {
  fs.readdirSync(poDirPath)
  .forEach(poFileName => {
    const localeToLoad = path.basename(poFileName, '.txt');
    loadedLocales.push(localeToLoad);
    const poFileContent = fs.readFileSync(path.join(poDirPath, poFileName));
    loadLocalizationFromPOFile(localeToLoad, poFileContent);
  });
}

loadAllLocales();
const preferredLocales = uniq([
  loadedLocales.indexOf(locale) === -1 ? localeWithoutCountry(locale) : locale,
  'en_US'
]);
useLocales(preferredLocales);

const selectors = {
  homeButton: t`Home`,
  startButton: t`Okay, let’s go!`,
  placeMarker: 'Bunte SchokoWelt' + ' ' + t`Fully wheelchair accessible`,
  editButton: t`Fully wheelchair accessible` + ' ' + t`Entrance has no steps, and all rooms are accessible without steps.`,
  expandButton: t`Expand details`,
  partiallyOption: t`Partially`,
  cancelButton: t`Cancel`,
  addImagesButton: t`Add images`,
  searchButton: t`Search`,
  searchInput: t`Search for place or address`,
  shoppingButton: t`Shopping`,
  atLeastPartiallyWheelchairAccessibleButton: t`Partially wheelchair accessible`,
  goButton: t`Go!`,
  showMeWhereIAmButton: t`Show me where I am`,

ttag

<div align='center'>

MIT
Latest version published 5 months ago

Package Health Score

78 / 100
Full package analysis