From d972d61f1b004211e0a4260c50da2f57c1e9eb4a Mon Sep 17 00:00:00 2001 From: markokajzer Date: Mon, 27 Aug 2018 16:51:07 +0200 Subject: [PATCH] Find available locales dynamically --- src/i18n/i18n.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/i18n/i18n.ts b/src/i18n/i18n.ts index 384edda5..f129f8e1 100644 --- a/src/i18n/i18n.ts +++ b/src/i18n/i18n.ts @@ -1,8 +1,13 @@ import i18n = require('i18n'); + +import fs from 'fs'; import path from 'path'; +const files = fs.readdirSync('./config/locales'); + + i18n.configure({ - locales: ['en', 'de', 'hu'], + locales: files.map(file => file.split('.')[0]), defaultLocale: 'en', directory: path.join(__dirname, '..', '..', 'config', 'locales'), objectNotation: true