Angular 7のLaravelミドルウェアのようなものや、ルートを介してサイトの言語を設定する方法はありますか?(https://example.com/en/about、https://example.com/de/about)
subscribe
ルーターイベントを実行NavigationStart
し、前述のtranslationServiceアプローチで使用する言語を変更することもできますが、ngx-translateを使用することを強くお勧めします。
this.router.events.subscribe((event: any): void => {
if (event instanceof NavigationStart) {
/* You should parse for the language code in the route
here and use it in the following line. Also make sure that the parsed
language code is an actual language code */
this.translationService.use(languageCode).then(() => // do your stuff);
}
});
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加