lephyrus / ngx-translate-messageformat-compiler

Advanced pluralization (and more) for ngx-translate, using standard ICU syntax which is compiled with the help of messageformat.js.
MIT License
93 stars 29 forks source link

Smoother Transition #30

Closed beeing closed 7 months ago

beeing commented 6 years ago

Hi, giving this some thoughts, how about adding a feature to allow fallback to original translator or new messageformat.

My idea is to add a special character, say backtick character to the key which then use the messageformat compiler, else it fallbacks to original translator.

Then it is easier to transition over to messageformat for bigger projects.

Thanks!

lephyrus commented 6 years ago

Thanks for the suggestion, I can see the usefulness of such a mechanism. Proper fallback would need to be handled by the ngx-translate core, not this plugin, however. There is no way for the compiler to say "I see a backtick, so I'll pass this along to the next (default) compiler in line." It could probably get its own instance of the default compiler and use that, but it's a bit messy. I'll try and see what it looks like, but no promises.

beeing commented 6 years ago

@lephyrus thank you for your thoughts, agree that the core may also play apart but (correct me if I'm wrong) this compiler has taken over the default compiler which in a way it has priority to intercept all translate compilation task.

Unless the core allows special syntax to choose which compiler to use. Anyway, looking forward to a solution for this :)

lephyrus commented 7 months ago

... more than 5 years later: You were right, @beeing. This was easy, and I should have done it a long time ago.

beeing commented 7 months ago

... more than 5 years later: You were right, @beeing. This was easy, and I should have done it a long time ago.

Well, it's never too late. Glad it helps.