Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with multiple modules and lazy loading #45

Closed
mscudlik opened this issue Jan 7, 2017 · 9 comments
Closed

Issue with multiple modules and lazy loading #45

mscudlik opened this issue Jan 7, 2017 · 9 comments

Comments

@mscudlik
Copy link

mscudlik commented Jan 7, 2017

Hello Roberto,

It seems that there is an issue with angular2localization if you are using it with with multiple modules and lazy loading.

Somehow the texts are not always translated and you also do not see the i18n "key", especially in internet explorer / edge.

Here is also a small video (Foobar is the translated text):

8ded337182

I have created a demo project (https://github.com/matthiasscudlik/angular2localization-issue) with some more explanation in the README.md so that you can reproduce it. Just run ng-serve and go to http://localhost:4200/#shared

Did i do something wrong or is it a bug? For me it seems to be an issue of the service instance management across modules.

Thanks a lot for providing this great library and best regards,
Matthias

@robisim74
Copy link
Owner

Hi Matthias,

thanks for the great reporting. I'll give it a look and let you know.

Greetings,

Roberto

@robisim74
Copy link
Owner

Hi Matthias,

this is not a problem of Lazy loading: the problem is that the shared coomponent doesn't extend the Locale class, so the lang parameter is not passed when the http request of the json file is completed.
If sometimes it works is just a case: some browsers as Chrome use the cache on refresh, and http request is completed before the view is rendered. In any case it would not work when language changes.

About the Lazy loading:

Thanks for your interest in this project!

Roberto

@mscudlik
Copy link
Author

mscudlik commented Jan 8, 2017

Hi Roberto,

thanks a lot for your explanation, this way everything works and now i think i understand how it works :)

Best regards,
Matthias

@Ghyath-Serhal
Copy link

Ghyath-Serhal commented Jan 18, 2017

Hello,

I had the same problem as matthiasscudlik, and it worked fine, but I still have one problem.
I added the below 2 lines in my component

<div translate>NUMBER_IS_INVALID</div>
{{ 'MENU' | translate:lang}}

First 1 worked fine, but the pipe did not return any translation, just blank.

Any advise.
Thank you.

@robisim74
Copy link
Owner

Hi @Ghyath-Serhal,

I don't understand the first line: NUMBER_IS_INVALID.

About the second line, the pipe expects the lang parameter, and not a string.

@Ghyath-Serhal
Copy link

Hello @robisim74 .
Thank you for your fast answer, I updated my answer above.
The first line is working correctly. As for the second line I also tried it also with lang parameter. still is not working.

@robisim74
Copy link
Owner

Did you extend Locale class in your component?

@Ghyath-Serhal
Copy link

oops, My fault.
Now it is working fine.
Thank you.

@robisim74
Copy link
Owner

I close this issue. If you need, open a new issue.

Greetings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants