经过大量研究,我最终决定使用Angular Internationalization (i18n)。
当前路线(如您所见,它们与语言无关):
const routes: Routes = [
{
path: '',
canActivate: [AuthGuardService],
loadChildren: () => import('./commercial-layout/commercial-layout.module').then(m => m.CommercialLayoutModule)
},
{path: 'maintenance', component: MaintenanceComponent},
{
path: 'auth',
loadChildren: () => import('./auth/auth.module').then(m => m.AuthModule)
},
{path: '**', redirectTo: 'water', pathMatch: 'full'}
];
我现在支持 2 种语言,en 和 fr。
注意:我的网站已经在生产中,我现在正在添加 i18n。
但是,我面临以下问题并且找不到任何资源来修复它:
如果我在我的网址结束后手动输入“en”或“fr”(www.myUrl.com/en OR www.myUrl.com/fr) ,它工作正常。
但是,如果我尝试转到没有语言的默认 url (www.myUrl.com),网站会崩溃/无法加载。
此外,我的 LAZY LOADED 应用程序中的所有路由也无法正常工作。
前往我的主要路线时出错:403 Forbidden
我是否需要重写所有路由以支持 i18n 还是有更好的方法?
谢谢!