import {Template} from "../../cli" import {UniversalPath} from "../../util" import {Container} from "../../di" import {Config} from "../../service/Config"; /** * CLI template that generates a new locale file. * Automatically adds placeholder entries for phrases that exist in the * associated common locale file. */ const locale_template: Template = { name: 'locale', fileSuffix: '.config.ts', description: 'Create a new config file that specifies translations for a locale.', baseAppPath: ['configs', 'lang'], render: (name: string, fullCanonicalName: string, targetFilePath: UniversalPath) => { const config = Container.getContainer().make(Config) const subloc = fullCanonicalName.split(':').slice(1).join(':') const common: any = config.get(`lang:common${subloc ? ':' + subloc : ''}`, {}) return `import {env} from '@extollo/lib' export default { ${Object.keys(common).map(key => ' ' + key + ': \'\',\n')} } ` }, } export { locale_template }