How to use the @aurelia/i18n.I18nConfiguration.customize function in @aurelia/i18n

To help you get started, we’ve selected a few @aurelia/i18n 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 aurelia / aurelia / packages / __tests__ / i18n / t / translation-integration.spec.ts View on Github external
itemWithCount_plural: '{{count}} Artikel',
      itemWithCount_interval: '(0)$t(itemWithCount_plural);(1)$t(itemWithCount);(2-7)$t(itemWithCount_plural);(7-inf){viele Artikel};',

      html: 'Dies ist ein <i>HTML</i> Inhalt',
      pre: 'Tic ',
      mid: 'Tac',
      midHtml: '<i>Tac</i>',
      post: ' Toe',

      imgPath: 'bar.jpg'
    };
    /* eslint-enable @typescript-eslint/camelcase */
    const ctx = TestContext.createHTMLTestContext();
    const au = new Aurelia(ctx.container);
    await au.register(
      I18nConfiguration.customize((config) =&gt; {
        config.initOptions = {
          resources: { en: { translation }, de: { translation: deTranslation } },
          skipTranslationOnMissingKey
        };
        config.translationAttributeAliases = aliases;
      }))
      .register(CustomMessage as unknown as IRegistration)
      .app({ host, component })
      .start()
      .wait();
    const i18n = au.container.get(I18N);

    return {
      en: translation, de: deTranslation, container: au.container, i18n, ctx, tearDown: async () =&gt; {
        await au.stop().wait();
      }
github aurelia / aurelia / examples / jit-webpack-ts / src / startup.ts View on Github external
import { DebugConfiguration } from '@aurelia/debug';
import { I18nConfiguration } from "@aurelia/i18n";
import { BasicConfiguration } from '@aurelia/jit-html-browser';
import { IRegistry } from '@aurelia/kernel';
import { Aurelia } from '@aurelia/runtime';
import { App } from './app';

const au = new Aurelia()
  .register(BasicConfiguration, DebugConfiguration,
    I18nConfiguration
      .customize(() => ({
        resources: {
          en: { translation: { whatever: "works" } }
        }
      })) as IRegistry
  );
console.log("registered");
try {
  au.app({ host: document.querySelector('app'), component: new App() });
  console.log("starting");
} catch (e) {
  console.log(e);
  throw e;
}
au.start();
github aurelia / aurelia / packages / __e2e__ / src / startup.ts View on Github external
(async function () {
  const host = document.querySelector('app');
  const searchParams = new URL(location.href).searchParams;
  const fetchResource = !!searchParams.get('fetchResource');

  const au = new Aurelia()
    .register(
      JitHtmlBrowserConfiguration,
      DebugConfiguration,
      I18nConfiguration.customize((options) => {
        options.translationAttributeAliases = ['t', 'i18n'];
        const plugins = [intervalPlural.default];
        if (fetchResource) {
          plugins.push(Fetch);
        }
        options.initOptions = {
          plugins,
          resources: !fetchResource ? resources : undefined,
          backend: fetchResource
            ? {
              loadPath: '/locales/{{lng}}/{{ns}}.json',
            }
            : undefined,
          skipTranslationOnMissingKey: !!searchParams.get('skipkey')
        };
      })