Closed joefiorini closed 11 years ago
Couldn't you use the {{t}}
helper within your content?
{{#view MyView}}
{{t blah}}
{{/view}}
From what I've seen you cannot concatenate strings to pass into Handlebars,
but I need to dynamically generate the key based on an attribute of my
view. Therefore, I need to pass it using nameBinding
and let the
valueTranslation
live in my view. But then I get a value
attribute in
the DOM, which I absolutely do not want.
On Wed, Feb 20, 2013 at 3:07 PM, Nathan Rapheld notifications@github.comwrote:
Couldn't you use the {{t}} helper within your content?
{{#view MyView}} {{t blah}} {{/view}}
— Reply to this email directly or view it on GitHubhttps://github.com/jamesarosen/ember-i18n/issues/40#issuecomment-13853345.
If you need dynamic keys, you'll have to do that in the view. I'm not 100% clear about what you're trying to accomplish, but hopefully this example is relevant:
I18n:
Em.I18n.Translations = {
translation.token.alpha: "ay",
translation.token.beta: "bee",
translation.token.gamma: "gee",
};
View:
var MyView = Ember.extend({
foobarBinding: 'controller.someValue',
myTranslatedString: function() {
return I18n.t('translation.token.%@'.fmt(this.get('foobar')));
}.property('foobar')
});
Template:
{{#view MyView}}
{{view.myTranslatedString}}
{{/view}}
If you want the translated text to show up as the <div>
's content, you want the t
helper:
{{#view MyView nameTranslation="blah"}}{{t "foozle"}}{{/view}}
@joefiorini Can you share how you've solved the dynamic keys thing pls? I have the same issue.
I'm actually not using the plugin anymore. The project I was using it on got canned. If we revisit it and I figure it out I'll be sure to post something here.
On Mon, Jul 1, 2013 at 9:23 AM, Thomas notifications@github.com wrote:
@joefiorini https://github.com/joefiorini Can you share how you've solved the dynamic keys thing pls? I have the same issue.
— Reply to this email directly or view it on GitHubhttps://github.com/jamesarosen/ember-i18n/issues/40#issuecomment-20281113 .
If I have something like:
I'm going to end up with markup like:
But what if I want to use the translated attribute to populate the div's content? I don't want that getting serialized into my HTML, but from what I could see in the code, it will since it ends in Translation.
Is there a way around this currently?