2014-05-12 3 views
3

내가 도우미에 지어진 Ember.js을 사용하고있는 경우 input핸들 바 헬퍼 국제화

{{input value=query class="form-input" placeholder="Search"}} 

내가 그 문자열의 번역 된 버전으로 자리 문자열을 교체 "검색"을하고 싶다. 나는 이미 input 도우미를 사용하지 않을 경우

일반적으로,이 같은 번역 된 문자열에 액세스 할 :

{{ t "home.search" }} 

답변

0

내가 사용하는 내 응용 프로그램의 이것 :

// This is a custom text field that allows i18n placeholders 
App.TextField = Ember.TextField.extend({ 
    attributeBindings: ['autofocus', 'z-index', 'autocomplete'], 

    placeholder: function() { 
     if (this.get('placeholderKey')) { 
      return I18n.t(this.get('placeholderKey')); 
     } else { 
      return ''; //or this.get('placeholder') 
     } 
    }.property('placeholderKey') 
}); 
2

Ember.I18n의 도우미가 번역 된 텍스트 자체가 아니라 번역 된 텍스트를 감싸는 범위를 반환하기 때문에 작업 할 수있는 솔루션이 부족합니다.

{{input value=login placeholder=(ts 'signin.login') }} 
: 다음과 같이 내 도우미를 사용할 수 있었다

Ember.Handlebars.registerHelper('ts', function (key) { 
    return Em.I18n.t(key); 
}); 

: 내가 직접 번역을 호출 내 자신의 도우미를 작성하여이를 해결