rubenv / angular-gettext

Gettext support for Angular.js
http://angular-gettext.rocketeer.be/
MIT License
649 stars 154 forks source link

Adding a translation at runtime? #351

Closed rdeslonde-eichleay closed 6 years ago

rdeslonde-eichleay commented 6 years ago

Our customers can provide custom messages to their customers on our platform. So we want to enable them to provide their own translations of their custom messages. So at runtime, I would like to add their translation to the catalog. Is that possible?

rdeslonde-eichleay commented 6 years ago

I think this answers my question?

https://angular-gettext.rocketeer.be/dev-guide/manual-setstrings/

But will setStrings overwrite existing language translation, or just add them to the existing catalog for a given language?

rubenv commented 6 years ago

@rdeslonde-eichleay yes it does, that's exactly the way to go!

rdeslonde-eichleay commented 6 years ago

If I already have a bunch of translations from a po file, and I use setStrings, will it clear the translations that already exist and set the new ones, or will it just set the new ones, adding them to the existing set?

rubenv commented 6 years ago

Source is here: https://github.com/rubenv/angular-gettext/blob/20d88695a25257764a62131182be271661b7b146/src/catalog.js#L155-L201

It merges.

rdeslonde-eichleay commented 6 years ago

Sweet, thanks. This is an awesome library. Thanks for maintaining it.

rubenv commented 6 years ago

Thanks, glad you like it. Don't have too much time for it nowadays, but it doesn't ask for much either.

Spread the word!