@@ -9,6 +9,7 @@ import { isValidInvoice } from '../../validations';
99import { createCommunityWizardStatus , wizardCommunityWrongPermission } from './messages' ;
1010import { CommunityContext } from './communityContext' ;
1111import * as commAdmin from './scenes.communityAdmin' ;
12+ import { isValidLanguage } from '../../../util/languages' ;
1213
1314const CURRENCIES = parseInt ( process . env . COMMUNITY_CURRENCIES || '10' ) ;
1415
@@ -165,10 +166,8 @@ const createCommunitySteps = {
165166
166167 ctx . wizard . state . error = null ;
167168 const lang = text . trim ( ) . toLowerCase ( ) ;
168-
169- // Check if language is valid
170- const validLanguages = [ 'en' , 'es' , 'fr' , 'de' , 'it' , 'pt' , 'ru' , 'uk' , 'ko' , 'fa' ] ;
171- if ( ! validLanguages . includes ( lang ) ) {
169+
170+ if ( ! isValidLanguage ( lang ) ) {
172171 ctx . telegram . deleteMessage ( ctx . chat ! . id , ctx . message ! . message_id ) ;
173172 ctx . wizard . state . error = ctx . i18n . t ( 'wizard_community_invalid_language' ) ;
174173 return await ctx . wizard . state . updateUI ( ) ;
@@ -897,13 +896,11 @@ export const updateLanguageCommunityWizard = new Scenes.WizardScene(
897896 if ( ctx . message === undefined ) return ctx . scene . leave ( ) ;
898897
899898 const lang = ctx . message . text . trim ( ) . toLowerCase ( ) ;
900- // Check if language is valid
901- const validLanguages = [ 'en' , 'es' , 'fr' , 'de' , 'it' , 'pt' , 'ru' , 'uk' , 'ko' , 'fa' ] ;
902- if ( ! validLanguages . includes ( lang ) ) {
899+ if ( ! isValidLanguage ( lang ) ) {
903900 ctx . deleteMessage ( ) ;
904901 return await ctx . reply ( ctx . i18n . t ( 'wizard_community_invalid_language' ) ) ;
905902 }
906-
903+
907904 const { community } = ctx . wizard . state ;
908905 community . language = lang ;
909906 await community . save ( ) ;
0 commit comments