This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ng-container *transloco="let t; scope: 'core'"> | |
<p>{{ t('core.title') }}</p> | |
</ng-container> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, OnInit } from '@angular/core'; | |
import { TRANSLOCO_SCOPE } from '@ngneat/transloco'; | |
@Component({ | |
selector: 'app-core', | |
templateUrl: './core.component.html', | |
providers: [{ provide: TRANSLOCO_SCOPE, useValue: 'core'] | |
}) | |
export class CoreComponent { | |
constructor() {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"scopePathMap": { | |
"my-scope": "src/app/path-to-scope", | |
"my-project-scope": "projects/my-project/i18n" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"hello": "transloco es", | |
"todos": { | |
"todos-translation": "todos es" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { TranslocoScopedLibsWebpackPlugin } = require('@ngneat/transloco-scoped-libs/webpack'); | |
module.exports = { | |
plugins: [new TranslocoScopedLibsWebpackPlugin()] | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Injectable({ providedIn: 'root' }) | |
export class HttpLoader implements TranslocoLoader { | |
contructor(private http: HttpClient) {} | |
getTranslation(lang: string, { scope }) { | |
const base = this.http.get(`/assets/i18n/${lang}.json`); | |
if(scope) { | |
return base; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "@app/core", | |
"i18n": [ | |
{ | |
"scope": "core", | |
"path": "src/lib/i18n", | |
"strategy": "join" | |
} | |
] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
... | |
scopedLibs: [ | |
{ | |
src: './projects/core', | |
dist: ['./projects/spa/src/assets/i18n', './src/assets/i18n/'] | |
} | |
] | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
... | |
scopedLibs: ['./projects/core/', '@lib/name'] | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "@app/core", | |
"i18n": [ | |
{ | |
"scope": "core", | |
"path": "src/lib/i18n" | |
} | |
] | |
} |
NewerOlder