Skip to main content
Version: 5.x.x

Namespaces

Tolgee allows you to split your i18n data into multiple namespaces. When using the translate pipe, t attribute, or translation methods, Tolgee automatically loads the namespace data for you.

Ideally, you should split translations for each module into different namespaces. For a lazy module, wait for the i18n data to be fetched before loading the lazy module. You can achieve this with NamespaceResolver.

...
import { NamespaceResolver } from '@tolgee/ngx';

const routes: Routes = [
...
{
path: 'lazy',
loadChildren: () => import('./lazy/lazy.module').then((m) => m.LazyModule),
data: { tolgeeNamespace: 'my-loaded-namespace' },
resolve: {
_namespace: NamespaceResolver,
},
},
];

@NgModule({
imports: [
RouterModule.forRoot(routes, ...),
],
exports: [RouterModule],
})
export class AppRoutingModule {}

When using NamespaceResolver, provide tolgeeNamespace property to the data object of your route configuration as defined in the above example.

You can learn more in the namespaces documentation.