nativescript-angularnativescript-plugin

A clear example how to implement nativescript-localize with angular


It's about nativescript-localize from https://market.nativescript.org/plugins/nativescript-localize#angular I've followed step-by-step the documentation but the result was:

<Label text="{{ [ERROR ->]'Hello world !' | L }}" ></Label>
JS: <Label text="{{ 'I am %s' | L:'user name' }}" ></Label>
JS: 
JS: "): ng:///ClassementModule/ClassementComponent.html@17:16
JS: The pipe 'L' could not be found ("

The fr.default.json it looks like:

{
  "hello": {
    "world": "Bonjour le monde !"
  },
  "not found in en.default": "pas trouvé dans en.default"
}

To be honest I couldn't find a clear example of how to implement this plugin. I have a look on the demo-angular from here: DEMO-ANGULAR and is also not so clear :(

I feel like is something missing from the documentation and I'm stuck.

Could you please help me with some hints?


Solution

  • For Nativescript 7, you have to follow this tutorial: https://github.com/NativeScript/plugins/tree/master/packages/localize

    NB: The documentation states that the i18n folder should be in the "app" folder. This did not work for me, and I had to put it in the "src" folder. enter image description here

    I had to add it to the component module as well (not just the app module).

    After I added everything I restarted the build manually.

    app module

    enter image description here

    enter image description here

    enter image description here