Added localization support

This commit is contained in:
2022-06-06 20:11:54 +07:00
parent 36d719835f
commit 060ebd07a0
4 changed files with 41 additions and 0 deletions
+2
View File
@@ -6,7 +6,9 @@ NativeException.process();
App.loadConfig();
App.loadENV();
App.loadPrisma();
App.loadLocale();
App.loadDiscord();
App.load_osu();
export default App;
+6
View File
@@ -5,6 +5,7 @@ import Discord from './Discord';
import osu from './osuAPI';
import Logger from '../libs/Logger';
import Locale from './Locale';
class App {
public readonly versionNumber = `0.09`;
public readonly version = `${this.versionNumber}${
@@ -31,6 +32,11 @@ class App {
Discord.init();
}
public loadLocale(): void {
Logger.log('info', 'Loading Locale');
Locale.init();
}
public load_osu(): void {
Logger.log('info', 'Loading osu! Client');
osu.init();
+27
View File
@@ -0,0 +1,27 @@
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();