question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

selectTranslate emits only the first time the active language is changed

See original GitHub issue

I’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:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
shaharkazazcommented, Dec 6, 2020

@micobarac would be great if you can retry now and verify 🙂

0reactions
micobaraccommented, Dec 7, 2020

@shaharkazaz I created a brand new Angular project.

ng add @ngneat/transloco added the newest version "@ngneat/transloco": "^2.19.3" to package.json.

It works ok now. Thanks. 🙂

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found