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

Cannot access the nested JSON Object #15

Closed
powercoder23 opened this issue Jan 14, 2016 · 5 comments
Closed

Cannot access the nested JSON Object #15

powercoder23 opened this issue Jan 14, 2016 · 5 comments

Comments

@powercoder23
Copy link

I am facing an issue, when i am using single string value in JSON it works, but when using object instead it doesn't works, below is the code explained.

   translate.setDefaultLang('en');

    translate.setTranslation('en', {
        "helloWorld": {
             "sayHello": "Hello there!"
         },
         "helloWorldSayHello": "Hello there!"
    });

    this.translate.use('en');
    <div>{{ 'helloWorldSayHello' | translate }} world</div> ----------//this does work
    <div>{{ 'helloWorld.sayHello' | translate }} world</div> ----------//this doesn't work

Is their any other way to make it work?

@ocombe
Copy link
Member

ocombe commented Jan 14, 2016

Not yet, but it's just a matter of improving the parser, I'll put it on my todo list :)

@webprofusion-chrisc
Copy link

👍 I'm currently looking to rebuild an existing app in Ionic2/Angular2 - our translations are created using https://webtranslateit.com/en and the resulting json looks like this: https://github.com/openchargemap/ocm-system/blob/master/Localisation/src/OCM_UI_LocalisationResources.it.json

When the translation for the selected language is null, we fallback (currently to the default text in the app). It would also be great to specify a fallback language in config. So if your app is in English but is mostly translated to Japanese then you could fallback to English.

@powercoder23
Copy link
Author

Thank you @ocombe ! you are doing a great job 👍

@ocombe
Copy link
Member

ocombe commented Jan 17, 2016

Both features are available in 1.4.0 !

@WillGeller
Copy link

Still having issues with attempting to use a nested json source for translations.
<div>{{ 'helloWorld.sayHello' | translate }}</div>
displays [Object object] rather then the translation value

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

No branches or pull requests

4 participants