ngx-translate issue with translate instantngx-translate: pipe vs directive@ngx-translate get observable not firing on language changeDynamic locale on angular2/moment and ngx-translate@ngx-translate with lazy-loaded module in Angular 5ngx-translate - merge translation file of different modulesngx-translate .pipe is not a functionngx-translate not showing any text in lazy-loaded modulengx-translate is not working for lazy loaded moduleAngular 5 and ngx-translate with shared module loose translations if refreshAvoid duplicate translations in @ngx-translate
If an object moving in a circle experiences centripetal force, then doesn't it also experience centrifugal force, because of Newton's third law?
Writing a letter of recommendation for a mediocre student
Does wetting a beer glass change the foam characteristics?
How do I deal with too many NPCs in my campaign?
Norwegian refuses EU delay (4.7 hours) compensation because it turned out there was nothing wrong with the aircraft
The 100 soldier problem
Is it more effective to add yeast before or after kneading?
Leaving a job that I just took based on false promise of a raise. What do I tell future interviewers?
How to manage expenditure when billing cycles and paycheck cycles are not aligned?
Examples of "unsuccessful" theories with afterlives
Where Does VDD+0.3V Input Limit Come From on IC chips?
How to ask a man to not take up more than one seat on public transport while avoiding conflict?
1, 2, 4, 8, 16, ... 33?
Allocating credit card points
Hilbert's hotel, why can't I repeat it infinitely many times?
Where are they calling from?
Which museums have artworks of all four Ninja Turtles' namesakes?
What benefits does the Power Word Kill spell have?
Conditionally execute a command if a specific package is loaded
Was there a trial by combat between a man and a dog in medieval France?
Can this word order be rearranged?
What is the meaning of "heutig" in this sentence?
Worms crawling under skin
How to make interviewee comfortable interviewing in lounge chairs
ngx-translate issue with translate instant
ngx-translate: pipe vs directive@ngx-translate get observable not firing on language changeDynamic locale on angular2/moment and ngx-translate@ngx-translate with lazy-loaded module in Angular 5ngx-translate - merge translation file of different modulesngx-translate .pipe is not a functionngx-translate not showing any text in lazy-loaded modulengx-translate is not working for lazy loaded moduleAngular 5 and ngx-translate with shared module loose translations if refreshAvoid duplicate translations in @ngx-translate
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am using ngx-translate in Angular(v6) with lazy-loading approach. I am facing a problem with translate.instant('Title')
Using translate pipe it works fine.( translate
)
Using translate.instant()
method the default language always works, but I am unable to change language via language selector(select component used for switching language) which is in shared module.
I don't want to use this.translate.onLangChange.subscribe
each time, is there an alternative to using this method?
angular angular6 ngx-translate
add a comment
|
I am using ngx-translate in Angular(v6) with lazy-loading approach. I am facing a problem with translate.instant('Title')
Using translate pipe it works fine.( translate
)
Using translate.instant()
method the default language always works, but I am unable to change language via language selector(select component used for switching language) which is in shared module.
I don't want to use this.translate.onLangChange.subscribe
each time, is there an alternative to using this method?
angular angular6 ngx-translate
I don't want to use this.translate.onLangChange.subscribe each time. Any other approach?
– Roshin Thomas
Mar 28 at 15:53
add a comment
|
I am using ngx-translate in Angular(v6) with lazy-loading approach. I am facing a problem with translate.instant('Title')
Using translate pipe it works fine.( translate
)
Using translate.instant()
method the default language always works, but I am unable to change language via language selector(select component used for switching language) which is in shared module.
I don't want to use this.translate.onLangChange.subscribe
each time, is there an alternative to using this method?
angular angular6 ngx-translate
I am using ngx-translate in Angular(v6) with lazy-loading approach. I am facing a problem with translate.instant('Title')
Using translate pipe it works fine.( translate
)
Using translate.instant()
method the default language always works, but I am unable to change language via language selector(select component used for switching language) which is in shared module.
I don't want to use this.translate.onLangChange.subscribe
each time, is there an alternative to using this method?
angular angular6 ngx-translate
angular angular6 ngx-translate
edited Mar 28 at 16:07
Narm
4,4101 gold badge20 silver badges42 bronze badges
4,4101 gold badge20 silver badges42 bronze badges
asked Mar 28 at 15:51
Roshin ThomasRoshin Thomas
4311 bronze badges
4311 bronze badges
I don't want to use this.translate.onLangChange.subscribe each time. Any other approach?
– Roshin Thomas
Mar 28 at 15:53
add a comment
|
I don't want to use this.translate.onLangChange.subscribe each time. Any other approach?
– Roshin Thomas
Mar 28 at 15:53
I don't want to use this.translate.onLangChange.subscribe each time. Any other approach?
– Roshin Thomas
Mar 28 at 15:53
I don't want to use this.translate.onLangChange.subscribe each time. Any other approach?
– Roshin Thomas
Mar 28 at 15:53
add a comment
|
1 Answer
1
active
oldest
votes
Use translate.stream('Title') instead of translate.instant('Title'). It returns an Observable.
See also https://github.com/ngx-translate/core
How it works:
import Component from '@angular/core';
import TranslateService from '@ngx-translate/core';
import Observable from 'rxjs';
@Component( async as name">
<p>Observable name </p>
</ng-container>
</div>
`,
)
export class AppComponent
public name$: Observable<string>;
constructor(public translate: TranslateService) fr/) ? browserLang : 'en');
public ngOnInit(): void
this.name$ = this.translate.stream('HOME.TITLE');
Here is a link to a stackblitz demo: https://stackblitz.com/edit/github-az4kgy
is it possible to use same way like translate.instant('key') ?
– Roshin Thomas
Mar 28 at 15:57
am using shared selector component for switching language > by default instant works as taking 'english' but when i switch to another language translate using pipe works and instant failed.
– Roshin Thomas
Mar 28 at 15:59
The reason is that instant returns a string not an Observable.
– Pierre
Mar 28 at 16:00
will try that approach..
– Roshin Thomas
Mar 28 at 16:01
Sorry it’s not working
– Roshin Thomas
Mar 29 at 4:19
|
show 3 more comments
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55401875%2fngx-translate-issue-with-translate-instant%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Use translate.stream('Title') instead of translate.instant('Title'). It returns an Observable.
See also https://github.com/ngx-translate/core
How it works:
import Component from '@angular/core';
import TranslateService from '@ngx-translate/core';
import Observable from 'rxjs';
@Component( async as name">
<p>Observable name </p>
</ng-container>
</div>
`,
)
export class AppComponent
public name$: Observable<string>;
constructor(public translate: TranslateService) fr/) ? browserLang : 'en');
public ngOnInit(): void
this.name$ = this.translate.stream('HOME.TITLE');
Here is a link to a stackblitz demo: https://stackblitz.com/edit/github-az4kgy
is it possible to use same way like translate.instant('key') ?
– Roshin Thomas
Mar 28 at 15:57
am using shared selector component for switching language > by default instant works as taking 'english' but when i switch to another language translate using pipe works and instant failed.
– Roshin Thomas
Mar 28 at 15:59
The reason is that instant returns a string not an Observable.
– Pierre
Mar 28 at 16:00
will try that approach..
– Roshin Thomas
Mar 28 at 16:01
Sorry it’s not working
– Roshin Thomas
Mar 29 at 4:19
|
show 3 more comments
Use translate.stream('Title') instead of translate.instant('Title'). It returns an Observable.
See also https://github.com/ngx-translate/core
How it works:
import Component from '@angular/core';
import TranslateService from '@ngx-translate/core';
import Observable from 'rxjs';
@Component( async as name">
<p>Observable name </p>
</ng-container>
</div>
`,
)
export class AppComponent
public name$: Observable<string>;
constructor(public translate: TranslateService) fr/) ? browserLang : 'en');
public ngOnInit(): void
this.name$ = this.translate.stream('HOME.TITLE');
Here is a link to a stackblitz demo: https://stackblitz.com/edit/github-az4kgy
is it possible to use same way like translate.instant('key') ?
– Roshin Thomas
Mar 28 at 15:57
am using shared selector component for switching language > by default instant works as taking 'english' but when i switch to another language translate using pipe works and instant failed.
– Roshin Thomas
Mar 28 at 15:59
The reason is that instant returns a string not an Observable.
– Pierre
Mar 28 at 16:00
will try that approach..
– Roshin Thomas
Mar 28 at 16:01
Sorry it’s not working
– Roshin Thomas
Mar 29 at 4:19
|
show 3 more comments
Use translate.stream('Title') instead of translate.instant('Title'). It returns an Observable.
See also https://github.com/ngx-translate/core
How it works:
import Component from '@angular/core';
import TranslateService from '@ngx-translate/core';
import Observable from 'rxjs';
@Component( async as name">
<p>Observable name </p>
</ng-container>
</div>
`,
)
export class AppComponent
public name$: Observable<string>;
constructor(public translate: TranslateService) fr/) ? browserLang : 'en');
public ngOnInit(): void
this.name$ = this.translate.stream('HOME.TITLE');
Here is a link to a stackblitz demo: https://stackblitz.com/edit/github-az4kgy
Use translate.stream('Title') instead of translate.instant('Title'). It returns an Observable.
See also https://github.com/ngx-translate/core
How it works:
import Component from '@angular/core';
import TranslateService from '@ngx-translate/core';
import Observable from 'rxjs';
@Component( async as name">
<p>Observable name </p>
</ng-container>
</div>
`,
)
export class AppComponent
public name$: Observable<string>;
constructor(public translate: TranslateService) fr/) ? browserLang : 'en');
public ngOnInit(): void
this.name$ = this.translate.stream('HOME.TITLE');
Here is a link to a stackblitz demo: https://stackblitz.com/edit/github-az4kgy
edited Mar 29 at 7:49
answered Mar 28 at 15:54
PierrePierre
4943 silver badges10 bronze badges
4943 silver badges10 bronze badges
is it possible to use same way like translate.instant('key') ?
– Roshin Thomas
Mar 28 at 15:57
am using shared selector component for switching language > by default instant works as taking 'english' but when i switch to another language translate using pipe works and instant failed.
– Roshin Thomas
Mar 28 at 15:59
The reason is that instant returns a string not an Observable.
– Pierre
Mar 28 at 16:00
will try that approach..
– Roshin Thomas
Mar 28 at 16:01
Sorry it’s not working
– Roshin Thomas
Mar 29 at 4:19
|
show 3 more comments
is it possible to use same way like translate.instant('key') ?
– Roshin Thomas
Mar 28 at 15:57
am using shared selector component for switching language > by default instant works as taking 'english' but when i switch to another language translate using pipe works and instant failed.
– Roshin Thomas
Mar 28 at 15:59
The reason is that instant returns a string not an Observable.
– Pierre
Mar 28 at 16:00
will try that approach..
– Roshin Thomas
Mar 28 at 16:01
Sorry it’s not working
– Roshin Thomas
Mar 29 at 4:19
is it possible to use same way like translate.instant('key') ?
– Roshin Thomas
Mar 28 at 15:57
is it possible to use same way like translate.instant('key') ?
– Roshin Thomas
Mar 28 at 15:57
am using shared selector component for switching language > by default instant works as taking 'english' but when i switch to another language translate using pipe works and instant failed.
– Roshin Thomas
Mar 28 at 15:59
am using shared selector component for switching language > by default instant works as taking 'english' but when i switch to another language translate using pipe works and instant failed.
– Roshin Thomas
Mar 28 at 15:59
The reason is that instant returns a string not an Observable.
– Pierre
Mar 28 at 16:00
The reason is that instant returns a string not an Observable.
– Pierre
Mar 28 at 16:00
will try that approach..
– Roshin Thomas
Mar 28 at 16:01
will try that approach..
– Roshin Thomas
Mar 28 at 16:01
Sorry it’s not working
– Roshin Thomas
Mar 29 at 4:19
Sorry it’s not working
– Roshin Thomas
Mar 29 at 4:19
|
show 3 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55401875%2fngx-translate-issue-with-translate-instant%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I don't want to use this.translate.onLangChange.subscribe each time. Any other approach?
– Roshin Thomas
Mar 28 at 15:53