我希望能够使用 angular-gettext 翻译 angular 生成的下拉列表选项中的内容。
我有两种不同的解决方案,但它们都不起作用:
在这个我使用 ng-repeat 并在 js 中有 textKeys:
$scope.categories = ['category.Art', 'category.Automotive'];
<select class="form-control" ng-model="category" >
<option value="{{category}}" ng-repeat="category in categories" translate="">category.{{category}}</option>
</select>
在这一个中,我category.{{category}}
在 ng-repeat 选项标签的选项中使用。
$scope.categories = ['Art', 'Automotive'];
<select class="form-control" ng-model="category" >
<option value="{{category}}" ng-repeat="category in categories" translate="">category.{{category}}</option>
</select>
结果是显示了 textKey 本身,但没有显示翻译。如果我更改语言,则会出现 [MISSING]。
根据angular-gettext,最后一个应该可以工作:https://angular-gettext.rocketeer.be/dev-guide/annotate/ <- interpolation
这可能吗?如果是这样,怎么办?