* change root dit and change way to import modules * update deps to latest versions * use latest tools for building bundles * rewrite webpack config * use nomodule technique for loading modern bundle * inject polyfills by babel usebuiltins * update eslint rules * rename all style files to CSS * use postcss preset env for building styles * proper typescript typing * put all html files to templates folder * etc
23 lines
597 B
JavaScript
23 lines
597 B
JavaScript
function renderLoadLocale(locales) {
|
|
return `/** this is generated file by "npm run translation:generate" **/
|
|
// it is ok that is empty. Default messages from code will be used.
|
|
const enMessages = {};
|
|
|
|
export async function loadLocale(locale: string): Promise<Record<string, string>> {
|
|
${locales
|
|
.map(
|
|
locale =>
|
|
` if (locale === '${locale}') {
|
|
return import(/* webpackChunkName: "${locale}.locale" */ '../locales/${locale}.json')
|
|
.then(m => m.default)
|
|
.catch(() => enMessages);
|
|
}
|
|
`
|
|
)
|
|
.join('')}
|
|
return enMessages;
|
|
}\n`;
|
|
}
|
|
|
|
module.exports = renderLoadLocale;
|