Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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) => {
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 () => {
await au.stop().wait();
}
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();
(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')
};
})