How to use the ttag.useLocale 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 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 <= n; i++) {
        console.log(ngettext(msgid`${i} tick passed`, `${i} ticks passed`, i));
    }
}

startCount(3);
github ttag-org / ttag / examples / webpack-setup / localeSetup.js View on Github external
import { addLocale, useLocale } from 'ttag';

if (process.env.NODE_ENV !== 'production') {
    const ukLocale = require('./uk.po');
    addLocale('uk', ukLocale);
    useLocale('uk');
}

ttag

[![Stand With Ukraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner-direct.svg)](https://stand-with-ukraine.pp.ua)

MIT
Latest version published 6 months ago

Package Health Score

70 / 100
Full package analysis