You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.4 KiB

import {Singleton, Inject} from '../../di'
import {CommandLine} from '../../cli'
import {InjectRequestLocale} from '../modules/InjectRequestLocale'
import {templateLocale} from '../template/locale'
import {Unit} from '../../lifecycle/Unit'
import {HTTPKernel} from '../../http/kernel/HTTPKernel'
import {Config} from '../../service/Config'
import {Logging} from '../../service/Logging'
* Application unit to register @extollo/i18n resources.
export class Internationalization extends Unit {
protected readonly kernel!: HTTPKernel
protected readonly config!: Config
protected readonly logging!: Logging
protected readonly cli!: CommandLine
* Registers the locale template and middleware, if enabled by config.
* You can set the "locale.enable" config property to `false` to disable
* the InjectRequestLocale HTTP kernel module.
up(): void {
this.logging.debug(`Registering locale template with CLI...`)
if ( this.config.get('locale.enable', true) ) {
} else {
this.logging.warn(`@extollo/i18n is registered, but disabled by config. Localization will not be done per-request.`)