import { NextFunction } from 'grammy' ; import Context from '@/models/Context' ; import engines from '@/engines' ; export default function configureI18n ( ctx , next ) { const chat = ctx . dbchat ; const engine = engines [ chat . engine ] ; const chatLanguage = chat . languages [ chat . engine ] || engine . defaultLanguageCode ; const language = engine . languages . find ( ( l ) => l . code === chatLanguage ) ; ctx . i18n . locale ( language ?. i18nCode ) ; return next ( ) ; }