Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
robisim74 committed Jan 30, 2024
1 parent 54fe668 commit 88fd3f2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ export const l10nConfig: L10nConfig = {

@Injectable() export class TranslationLoader implements L10nTranslationLoader {
public get(language: string, provider: L10nProvider): Observable<{ [key: string]: any }> {
/**
* Translation files are lazy-loaded via dynamic import and will be split into separate chunks during build.
* Assets names and keys must be valid variable names
*/
const data = import(`../i18n/${language}/${provider.asset}.json`);
return from(data);
}
Expand All @@ -69,6 +73,8 @@ _src/i18n/en-US/app.json_
}
```

> Note. The implementation above of `L10nTranslationLoader` is just an example: you can load the translation data in the way you prefer.
Register the configuration:

_src/app/app.config.ts_
Expand Down
2 changes: 1 addition & 1 deletion angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"builder": "@angular-devkit/build-angular:browser-esbuild",
"options": {
"outputPath": "dist/angular-l10n-app",
"index": "projects/angular-l10n-app/src/index.html",
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"dom"
],
"useDefineForClassFields": false,
"allowSyntheticDefaultImports": true
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true
},
"angularCompilerOptions": {
"strictInjectionParameters": true,
Expand Down

0 comments on commit 88fd3f2

Please sign in to comment.