EddyVerbruggen/nativescript-i18n

custom resource path

Opened this issue · 8 comments

@rborn Please allow us to pass a I18n source folder path when requiring the plugin so that we can have it follow our own directory conventions instead of having to use a hardcoded path; thank you (:

rborn commented

@vbresults could you give me more details on what you need? thank you

@rborn source path is hardcoded to app/i18n

This suggestion is to amend this, so that while by default it is still app/i18n, it can be changed, like so:

require("nativescript-i18n")({
  path: "resources/i18n"
});

// searches 'app/resources/i18n' for source strings instead of 'app/i18n'
rborn commented

@vbresults Not sure how to achieve this, there is a before-build hook that creates the iOS strings before the app it's built, so we need to know beforehand the path of the files :(

A way would be to try to set something in package.json but I'm not sure if this approach it's good and/or possible.

rborn commented

@vbresults please have a look in the custom_lang_path branch.

To set the custom path you need to alter your project's package.json file like in the demo app and of course to move the file in the new path.

Keep in mind that the new path is relative to the app's root.

Play with it and let me know, and once it's fine I'll merge it and push it to npm 😄

@rborn Thank you; is there any chance for it to follow this spec? NativeScript/NativeScript#2609

rborn commented

@vbresults so you'd like to have the i18n folder inside the app/App_Resources folder? Or am I getting it wrong?

@rborn Edit: Your package.json idea is better, will try it out

rborn commented

@vbresults related to the edited reply, until we have something official from NS I wouldn't venture in implementing something like this (application.paths).
Also the package.json could be a good way for #11 :)

Let me know how it goes