selectTranslate emits only the first time the active language is changed
See original GitHub issueI’m submitting a…
[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:
Current behavior
selectTranslate
emits only the first time the active language is changed.
Expected behavior
Docs say: selectTranslate
will emit each time the active language is changed.
Minimal reproduction of the problem with instructions
I installed @ngneat/transloco with:
ng add @ngneat/transloco
This installed some old version 1.1.1
instead of the latest 2.19.2
?!
this.translocoService.selectTranslate('hello').subscribe((value) => console.log(value));
This event fires only once, on page load, but with empty result.
My language file is simple:
{
"hello": "Hello"
}
The console output says the language file was loaded successfully:
ngneat-transloco.js:508 🍻 Translation Load Success: en
Any subsequent language changes are ignored.
What is the motivation / use case for changing the behavior?
Getting the translation asynchronously on every language change
Environment
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 11.0.3
Node: 14.15.0
OS: darwin x64
Angular: 11.0.3
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Ivy Workspace: Yes
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1100.3
@angular-devkit/build-angular 0.1100.3
@angular-devkit/core 11.0.3
@angular-devkit/schematics 11.0.3
@angular/cdk 11.0.1
@angular/flex-layout 11.0.0-beta.33
@angular/material 11.0.1
@schematics/angular 11.0.3
@schematics/update 0.1100.3
rxjs 6.6.3
typescript 4.0.5
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Transloco translate doesn't work the first time - Stack Overflow
It seems that the first time you load the app there is no time to load the translations. Is there a way to...
Read more >ngneat-transloco/lobby - Gitter
It says Title in Spanish because I set es as active language in the ... (I've changed only customers module, so please ignore...
Read more >Translation API | Transloco Angular i18n - GitHub Pages
selectTranslate will emit each time the active language is changed. You can also select a translation from scope , simply inject the scope...
Read more >@ngneat/transloco - npm
selectTranslation ('es').subscribe(translation => ...);. Note that selectTranslate will emit each time the active language is changed.
Read more >Using ngx-translate to switch the language of a Form in your ...
All you need to do is install the below 2 packages and make some changes in app.module of the angular application. npm install...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@micobarac would be great if you can retry now and verify 🙂
@shaharkazaz I created a brand new Angular project.
ng add @ngneat/transloco
added the newest version"@ngneat/transloco": "^2.19.3"
topackage.json
.It works ok now. Thanks. 🙂