core
core copied to clipboard
Is there a way to package a self-made angular library with it's own translation files(JSON) with ngx-translate?
I have stumbled upon this post: [https://stackoverflow.com/questions/53972206/custom-angular-library-with-ngx-translate]
Based on the solution suggested there, a workaround for this, is to write translation text in TS format and import when translation changes. But, is there a way to package and publish a library with it's own JSON translation file?
Yes, you can use the "assets" property in the "ng-packagr" file of your library that will move those file to the library dist folder, from there it's just a matter of documenting how to import those. People can either import that from node modules or you could write a function to do it for them.
Thanks @ocombe for the suggestion, I have decided to create python script to copy the translation file into dist folder and packaging it from there. After that, on my Angular App that used to consume the self-made angular library, I installed ngx-translate-multi-http-loader to load from multiple translation file by specifying the directory in the AOT compiler.
For now, this workaround able to achieve what I wanted, since my Angular App does not utilizes many self-made library.