samedi 22 septembre 2018

Ember.js - Whats the proper way to handle property translations?

I have a model with a gender property, which can be "female" or "male".

What's the best way to handle the translation of that property?

I thought of some ways to tackle this, but not sure if I'm overthinkering this or solving it poorly.

1) Make a helper or tagless component that receives the value, has the translations service injected and translates it. With an aditional flag to capitalize or lower case the output.

2) Just use t helper and concat for the translation key, eg: . This is very straight forward and I will be copy-pasting this everywhere, looks messy.

3) Computed property in the model. I feel like injecting the translations service in my models is wrong (just my impression, if this is the proper way I'm good with it)

4) Computed property in the component that has to show the gender. This is like option 2 but in the component instead of the template, will be copy-pasting this a lot.




Aucun commentaire:

Enregistrer un commentaire