[英]add traduction to ui-datepicker in angular ui-grid
is there a way to translate the button in the angular ui-datepicker in this plunker example. 在此插件示例中,有没有一种方法可以在有角度的ui- datepicker中转换按钮。 I tried adding close-text="{{\\'lblClose\\' | translate}}" current-text="{{\\'lblToday\\' | translate}}" clear-text="{{\\'lblClear\\' | translate}}"
like the other Angular ui-datepicker but it's not working. 我尝试添加close-text="{{\\'lblClose\\' | translate}}" current-text="{{\\'lblToday\\' | translate}}" clear-text="{{\\'lblClear\\' | translate}}"
就像其他Angular ui-datepicker一样,但无法正常工作。 any help is really apreciated 真的很感谢任何帮助
您可以通过更新类似<div class="datepicker-wrapper" ><input uib-datepicker-popup is-open="isOpen" ng-model="' + attrs.rowField + '" ng-change="changeDate($event)" close-text="closeText" current-text="curentText" clear-text="clearText"on-open-focus="false" disabled/></div>
请参阅此插件为了结果
After looking more deeply on how ui-grid-datepicker is working I found a dirty solution (I don't think there is a clean solution) 在更深入地研究ui-grid-datepicker的工作原理后,我发现了一个肮脏的解决方案(我认为没有一个干净的解决方案)
You can see a plunker here where I changed the text of the close button: http://plnkr.co/edit/za99R9wUOcM2s2EkHLsv?p=preview 您可以在此处查看更改了“关闭”按钮的文本的小插曲: http ://plnkr.co/edit/za99R9wUOcM2s2EkHLsv?p=preview
THe problem is that the setting to change the Done button must be applied on the element that has the directive "uib-datepicker-popup" 问题是更改“完成”按钮的设置必须应用于具有指令“ uib-datepicker-popup”的元素
So if you want to modify the label of the Done button you have to change the library of ui-grid-settings (which is not a good solution but I don't see any other way). 因此,如果要修改“完成”按钮的标签,则必须更改ui-grid-settings库(这不是一个好的解决方案,但我看不到其他任何方法)。
from this: 由此:
template: function(element, attrs) {
var html = '<div class="datepicker-wrapper" ><input uib-datepicker-popup is-open="isOpen" ng-model="' + attrs.rowField + '" ng-change="changeDate($event)" on-open-focus="false" disabled/></div>';
return html;
},
You change it to (notice I added the close-text attribute with a paramter) : 您将其更改为(注意,我添加了带参数的close-text属性):
template: function(element, attrs) {
var html = '<div class="datepicker-wrapper" ><input uib-datepicker-popup is-open="isOpen" close-text="' + attrs.closeLabel + '" ng-model="' + attrs.rowField + '" ng-change="changeDate($event)" on-open-focus="false" disabled/></div>';
return html;
},
And then in your main file app.js, from this: 然后在您的主文件app.js中,如下所示:
editableCellTemplate: '<div><form name="inputForm"><div ui-grid-edit-datepicker row-field="MODEL_COL_FIELD" ng-class="\'colt\' + col.uid"></div></form></div>'
you change it to : 您将其更改为:
editableCellTemplate: '<div><form name="inputForm"><div ui-grid-edit-datepicker close-label="' + closeLabelTranslated + '" row-field="MODEL_COL_FIELD" ng-class="\'colt\' + col.uid"></div></form></div>'
The only thing remaining is to set your variable closeLabelTranslated to whatever you want, for instance using angular-translate module (I didn't add this to the plunker): 剩下的唯一一件事就是将变量closeLabelTranslated设置为所需的值,例如使用angular-translate模块(我没有将其添加到插件):
var closeLabelTranslated = $filter('translate')('DONE');
Like I said this is dirty solution but it seems ui-grid-edit-datepicker doesn't provide you with this option so you have to add it manually 就像我说的那样,这是肮脏的解决方案,但是ui-grid-edit-datepicker似乎没有为您提供此选项,因此您必须手动添加
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.