2021-07-08 00:59:34 +02:00
|
|
|
const { readdirSync, path } = require('../config/config')
|
|
|
|
|
|
|
|
class LangTask {
|
2021-07-15 07:05:36 +02:00
|
|
|
updaterLang = async ({ i18n, Extra, markup, replyWithHTML }) => {
|
2021-07-08 00:59:34 +02:00
|
|
|
const locales = {}
|
|
|
|
const markupArr = []
|
|
|
|
const __PATH__ = path.resolve(__dirname, '../locales')
|
|
|
|
|
|
|
|
readdirSync(__PATH__).forEach(fileName => {
|
|
|
|
const value = fileName.split('.')[0]
|
|
|
|
locales[value.toString()] = { name: i18n.t(value) }
|
|
|
|
})
|
|
|
|
|
|
|
|
Object.keys(locales).forEach(value => {
|
|
|
|
let name = locales[value.toString()].name
|
|
|
|
if (value === i18n.languageCode) {
|
|
|
|
name = `✅ ${name}`
|
|
|
|
}
|
|
|
|
return markupArr.push(markup.callbackButton(name, `set_lang|${value}`))
|
|
|
|
})
|
|
|
|
|
|
|
|
return await replyWithHTML(
|
|
|
|
i18n.t('default.lang'),
|
2021-07-15 07:05:36 +02:00
|
|
|
Extra.HTML().markup(m => m.inlineKeyboard(markupArr))
|
2021-07-08 00:59:34 +02:00
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = new LangTask()
|