marcobuschini / ng-i18n

A package for helping in translating Angular packages.
MIT License
0 stars 0 forks source link

Implement messageformat syntax for messages #2

Closed marcobuschini closed 4 years ago

marcobuschini commented 4 years ago

Is your feature request related to a problem? Please describe. At present translations are performed via debug templates. Those are not viable for production.

Describe the solution you'd like I would love to implement MessageFormat syntax as described at http://userguide.icu-project.org/formatparse/messages but without the full burden of MessageFormat API and data structures. Simply a function format(string, parameters) would be perfect.

Describe alternatives you've considered JavaScript messageformat (https://messageformat.github.io/messageformat/) has been considered, but it compiles messages to JavaScript at build time. That is incompatible with my dynamic RXJS approach that loads translations only when needed.

marcobuschini commented 4 years ago

I can, perhaps, get inspiration from http://www.java2s.com/Code/Java/I18N/AtextformatsimilartoMessageFormatbutusingstringratherthannumerickeys.htm

marcobuschini commented 4 years ago

Maybe messageformat for Javascript can generate files that can be loaded with this method: https://medium.com/better-programming/angular-load-external-javascript-file-dynamically-3d14dde815cb

marcobuschini commented 4 years ago

Best option: learn how to use messageformat from https://github.com/lephyrus/ngx-translate-messageformat-compiler/blob/master/src/lib/translate-message-format-compiler.ts