@@ -12,6 +12,7 @@ import {
1212} from './messages' ;
1313import { CommunityContext } from './communityContext' ;
1414import * as commAdmin from './scenes.communityAdmin' ;
15+ import { isValidLanguage } from '../../../util/languages' ;
1516
1617const CURRENCIES = parseInt ( process . env . COMMUNITY_CURRENCIES || '10' ) ;
1718
@@ -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 ( ) ;
@@ -896,13 +895,11 @@ export const updateLanguageCommunityWizard = new Scenes.WizardScene(
896895 if ( ctx . message === undefined ) return ctx . scene . leave ( ) ;
897896
898897 const lang = ctx . message . text . trim ( ) . toLowerCase ( ) ;
899- // Check if language is valid
900- const validLanguages = [ 'en' , 'es' , 'fr' , 'de' , 'it' , 'pt' , 'ru' , 'uk' , 'ko' , 'fa' ] ;
901- if ( ! validLanguages . includes ( lang ) ) {
898+ if ( ! isValidLanguage ( lang ) ) {
902899 ctx . deleteMessage ( ) ;
903900 return await ctx . reply ( ctx . i18n . t ( 'wizard_community_invalid_language' ) ) ;
904901 }
905-
902+
906903 const { community } = ctx . wizard . state ;
907904 community . language = lang ;
908905 await community . save ( ) ;
0 commit comments