Import other modules into monorepo
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
30
src/i18n/template/locale.ts
Normal file
30
src/i18n/template/locale.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
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 = <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 }
|
||||
Reference in New Issue
Block a user