how to translate the html5 placeholders dynamically

前端 未结 5 1190
星月不相逢
星月不相逢 2021-02-01 13:41

I\'m using angular-translate to translate the page content in to different languages.




        
相关标签:
5条回答
  • 2021-02-01 14:16

    There is a directive in angular-translate to help with this. See this issue.

    <input placeholder="Regular Placeholder" translate translate-attr-placeholder="text" translate-value-browser="{{app.browser}}">
    

    Here is a preview of a working plunkr from that thread: http://plnkr.co/edit/J4Ai71puzOaA0op7kDgo?p=preview

    0 讨论(0)
  • 2021-02-01 14:25

    I Use this method:

    In en.json:

    {
       "ENTER_TEXT": "{{label}} را وارد کنید",
       "DISCOUNT_CODE": "کد تخفیف"
    }
    

    In template:

    <input type="text" placeholder="{{'ENTER_TEXT' | translate: {label: 'DISCOUNT_CODE' | translate} }}" >
    
    0 讨论(0)
  • 2021-02-01 14:29

    +ira 's solution works for me.

    <input type ='text' placeholder = "{'USERNAME' | translate}">
    

    where username is the key for the translation. So that translation JSON line might look like the following in Spanish

    "USERNAME": "Nombre",
    

    The two together puts Nombre as a placeholder inside the input box

    0 讨论(0)
  • 2021-02-01 14:37

    I used placeholder="{{ 'some_text' | translate }}" instead of placeholder="{{ "some_text" | translate }}" that worked for me

    0 讨论(0)
  • 2021-02-01 14:38

    Did you try:

    <input type="text" placeholder="{{ 'my.i18n.key' | translate }}" ng-model="myModel">
    
    0 讨论(0)
提交回复
热议问题