翻译 Angular-UI 分页 [英] Translate Angular-UI pagination
本文介绍了翻译 Angular-UI 分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何翻译 Bootstrap UI 分页指令中的文本?
How can I translate text in Bootstrap UI pagination directive?
对于法语翻译,我已经覆盖了这样的常量:
I've overrided the constants like this for french translation:
angular.module('myapp', ['ui.bootstrap'])
.constant('paginationConfig', {
itemsPerPage: 10,
boundaryLinks: false,
directionLinks: true,
firstText: 'Premier',
previousText: 'Précédent',
nextText: 'Suivant',
lastText: 'Dernier',
rotate: true
})
但是覆盖常量似乎是个坏主意...
But overriding constants seems to be a bad idea...
这样做的正确方法(如果有的话)是什么?
What is the correct way (if any) to do this?
推荐答案
您可以在 run
方法中修改它的属性,而不是覆盖整个常量对象
Rather than overiding the whole constant object you can modify properties of it within the run
method
var app=angular.module('myapp', ['ui.bootstrap']);
app.run(function(paginationConfig){
paginationConfig.firstText='MY FIRST';
paginationConfig.previousText='YOUR TEXT';
})
在新版本的 ui.bootstrap
中你应该使用
In new version of ui.bootstrap
you should use
uibPaginationConfig
插入
paginationConfig
这篇关于翻译 Angular-UI 分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文