How to use ttag - 10 common examples

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 / test / specs / generateScreenshots.js View on Github external
function loadLocalizationFromPOFile(locale, poFileContent) {
  const localization = gettextParser.po.parse(poFileContent);
  // addLocale(locale, removeEmptyTranslations(localization));
  addLocale(locale, localization);
  return localization;
}
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 / 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 zzorba / ArkhamCards / components / CardSearchResultsComponent / CardResultList.tsx View on Github external
if (showNonCollection[section.id]) {
      // Already pressed it, so show a button to edit collection.
      return (
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`,
github ProtonMail / proton-mail-settings / src / app / containers / Filters / AddFilterModal.js View on Github external
const handleChangeSieve = console.log;

    console.log('[FILTER]', filter);
    return (
        
            {c('Add Filter Modal').t`Custom Filter`}

            
                <div>
                    <label>{c('New Label form').t`Name`}</label>
                    <input required="{true}" label="" placeholder="{c('New" value="{model.Name}" type="text" id="accountName">
                </div>
                {model.Name &amp;&amp; type !== 'sieve' ?  : null}
                {type === 'sieve' ?  : null}

                
                    {c('New Label form').t`Cancel`}
                    {c('New Label form').t`Save`}
                
            
        
    );
}
github ttag-org / ttag / examples / quickstart / counter.js View on Github external
const { t, ngettext, msgid, addLocale, useLocale } = require('ttag');

const locale = process.env.LOCALE;

if (locale) {
    const translationObj = require(`./${locale}.po.json`);
    addLocale(locale, translationObj);
    useLocale(locale);
}

function startCount(n) {
    console.log(t`starting count up to ${n}`);
    for (let i = 0; i &lt;= n; i++) {
        console.log(ngettext(msgid`${i} tick passed`, `${i} ticks passed`, i));
    }
}

startCount(3);
github zzorba / ArkhamCards / app / i18n.ts View on Github external
export function changeLocale(locale: string) {
  console.log(locale);
  const translationObj = getTranslationObj(locale);
  addLocale(locale, translationObj);
  useLocale(locale);
}
github zzorba / ArkhamCards / app / i18n.ts View on Github external
export function changeLocale(locale: string) {
  console.log(locale);
  const translationObj = getTranslationObj(locale);
  addLocale(locale, translationObj);
  useLocale(locale);
}
github ttag-org / ttag / examples / quickstart / counter.js View on Github external
const { t, ngettext, msgid, addLocale, useLocale } = require('ttag');

const locale = process.env.LOCALE;

if (locale) {
    const translationObj = require(`./${locale}.po.json`);
    addLocale(locale, translationObj);
    useLocale(locale);
}

function startCount(n) {
    console.log(t`starting count up to ${n}`);
    for (let i = 0; i &lt;= n; i++) {
        console.log(ngettext(msgid`${i} tick passed`, `${i} ticks passed`, i));
    }
}

startCount(3);

ttag

<div align='center'>

MIT
Latest version published 4 months ago

Package Health Score

78 / 100
Full package analysis