简体   繁体   English

AngularJS Translation在占位符中不起作用

[英]AngularJS translate is not working in placeholder

I am using clip-two which is developed in AngularJS in which I am using translate multi-language using JSON file it is working for all HTML tags but I when trying to translate placeholder using this it not working. 我正在使用在AngularJS中开发的第二个剪辑,其中我正在使用JSON文件翻译多语言,它适用于所有HTML标记,但是当我尝试使用它翻译占位符时,它不起作用。

JSON format JSON格式

"addemployee": {
  "Name": "Name",
  "Typename": "Type name",
  "Employeid": "Employe id",
  "Username": "Username",
  "Contactno": "Contact no.",
  "Typecontactno": "Type contact no.",
  "Password": "Password",
  "Typepassword":"Type password",
  "Confirmpassword": "Confirm password",
  "Selectimagefile": "Select an image file",
  "remove": "Remove",
  "cancel": "Cancel",
  "upload": "Upload",
  "Addemployee": "Add employee",
  "TypeConfirmpassword": "Type Confirm password"
}

Works for HTML tag 适用于HTML标签

<h1 class="mainTitle" translate="addemployee.Addemployee"> Add Employee</h1>

But doesn't not work in input placeholder 但是在输入占位符中不起作用

placeholder=""

You did try just like this ? 您确实尝试过这样吗?

<input type="text" placeholder="{{ 'addemployee.Addemployee' | translate }}" ng-model="myModel">

Edit: 编辑:

<input type="text" ng-attr-placeholder="{{ 'addemployee.Addemployee' | translate }}" name="firstName" ng-model="employee.name" id="name" class="form-control" required>

"addemployee": { 
    "Name": "Name", 
    "Typename": "Type name", 
    "Employeid": "Employe id", 
    "Username": "Username", 
    "Contactno": "Contact no.", 
    "Typecontactno": "Type contact no.", 
    "Password": "Password", 
    "Typepassword":"Type password", 
    "Confirmpassword": "Confirm password", 
    "Selectimagefile": "Select an image file", 
    "remove": "Remove", 
    "cancel": "Cancel", 
    "upload": "Upload", 
    "Addemployee": "Add employee", 
    "TypeConfirmpassword": "Type Confirm password" 
}

You have to use condition for two translation just like ng-show or ng-hide . 您必须使用条件进行两次翻译,就像ng-showng-hide

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM