But the problem is when the value changes the original model is not updated. Any help is highly appreciated. It is funny how I have built a few mid-sized Ember apps in the past and now I can’t get my head over this…
I don’t know if there is a way of achieving what you want to do but you can create a component wrapping the input and checking the language to know which key it must bind:
Yes I thought about that too, but I felt there should be a more elegant way of solving this. I ended up changing data format and added a computed property to controller that filters embedded records by current language. Here’s the idea:
I don’t know about your user case but what you are trying to do is some kind of internationalization (commonly known as i18n), right? as far as I know, that works a bit different as you are doing now. Instead of having your strings and your translations in the model, you have only keys (or unique strings in a specific language) and then in another part a list of translations for those keys, so you end up looking for the key and the language and showing the right string.
What I’m building is a tool where users can compose a form from a variety of different input fields. Labels for the fields need to be available in several languages. Using a translation map would lead me to the original problem where I was not able to bind value by key. This is what I’d end up with:
{{#each animal in safari itemController='animal' }}
{{input value=animal.name}}
{{/each}}
and when you change the language the value will correctly switch.
The white magic happens in the computed property generated by the #translatedProperty method. It is both setter and getter. But can be simplified if you don’t need such a general case.