@rootthenile wrote:
Hi I just make a multi language app with RTL for the menu
here’s my code in my Settings Page ts where the change language bottom there
export class SettingsPage { languageSelected : any = 'en'; languages : Array<LanguageModel>; dir: string; constructor ( public navCtrl: NavController, public translate: TranslateService, public languageService: LanguageService, public platform:Platform ) { this.languages = this.languageService.getLanguages(); this.setLanguage(); } changeLanguage(languageId) { if (languageId === 'ar') { this.platform.setDir('rtl', true); this.translate.setDefaultLang(languageId); } else { this.platform.setDir('ltr', true); this.translate.setDefaultLang(languageId); } } setLanguage(){ this.dir = this.dir == 'ltr' ? 'rtl' : 'ltr'; this.platform.setDir(this.dir,true); let defaultLanguage = this.translate.getDefaultLang(); if(this.languageSelected){ this.translate.setDefaultLang(this.languageSelected); this.translate.use(this.languageSelected); }else{ this.languageSelected = defaultLanguage; this.translate.use(defaultLanguage); } } }
and I get error Cannot read property ‘dir’ of undefined
Posts: 1
Participants: 1