mirror of
https://github.com/kirameki-cafe/Yumi.git
synced 2026-09-13 18:59:19 +00:00
27 lines
617 B
TypeScript
27 lines
617 B
TypeScript
import { I18n } from 'i18n';
|
|||
|
|
import * as path from 'path';
|
||
|
|
import Logger from '../libs/Logger';
|
||
|
|
|
||
|
|
class Locale {
|
||
|
|
public localePath: string;
|
||
|
|
|
||
|
|
constructor() {
|
||
|
|
this.localePath = path.join(process.cwd(), 'locales/');
|
||
|
|
}
|
||
|
|
|
||
|
|
public init(): void {
|
||
|
|
Logger.log('info', 'Loaded locales: ' + this.getLocaleProvider("en").getLocales().join(', '));
|
||
|
|
}
|
||
|
|
|
||
|
|
public getLocaleProvider(locale: string) {
|
||
|
|
const i18n = new I18n();
|
||
|
|
i18n.configure({
|
||
|
|
directory: this.localePath
|
||
|
|
})
|
||
|
|
i18n.setLocale(locale);
|
||
|
|
return i18n;
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
export default new Locale();
|