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;








2















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?










share|improve this question


























  • I don't want to use this.translate.onLangChange.subscribe each time. Any other approach?

    – Roshin Thomas
    Mar 28 at 15:53

















2















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?










share|improve this question


























  • I don't want to use this.translate.onLangChange.subscribe each time. Any other approach?

    – Roshin Thomas
    Mar 28 at 15:53













2












2








2








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?










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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

















  • 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












1 Answer
1






active

oldest

votes


















3
















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






share|improve this answer



























  • 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













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
);



);














draft saved

draft discarded
















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









3
















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






share|improve this answer



























  • 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















3
















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






share|improve this answer



























  • 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













3














3










3









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






share|improve this answer















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







share|improve this answer














share|improve this answer



share|improve this answer








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

















  • 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




















draft saved

draft discarded















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현