angularjs 过滤器“日期"和 $locale 服务 [英] angularjs filter 'date' and $locale service

查看:28
本文介绍了angularjs 过滤器“日期"和 $locale 服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎angularjs嵌入了一些国际化的资源:

it seems that angularjs embed some internationalized resources:

Angular 支持 i18n/l10n 的日期、数字和货币过滤器.此外,Angular 支持可本地化的多元化支持通过 ngPluralize 指令.所有可本地化的 Angular 组件取决于由 $locale 服务管理的特定于语言环境的规则集.

Angular supports i18n/l10n for date, number and currency filters. Additionally, Angular supports localizable pluralization support through the ngPluralize directive. All localizable Angular components depend on locale-specific rule sets managed by the $locale service.

如果找到 $locale 服务但不知道如何在 fr-fr 中指定语言环境...

If found the $locale service but don't kwnow how to specify the locale in fr-fr...

以下代码:

{{article.date_collected | date:'EEEE dd MMMM yyyy'}}

给:

2014 年 10 月 6 日星期一

Monday 06 October 2014

但我想要:

隆迪 2014 年 10 月 6 日

Lundi 06 Octobre 2014

有什么建议吗?

推荐答案

终于在angular github页面上找到了回复:https://github.com/angular/bower-angular-i18n#bower-angular-i18n

Finally I found the response on the angular github page: https://github.com/angular/bower-angular-i18n#bower-angular-i18n

关于什么对我有用的更多信息

EDIT : more info for what worked for me

在你的应用根目录中,从 bower 安装资源

In your root app directory, install resources from bower

bower install angular-i18n

如果您使用 bower/buildjs 将所有脚本压缩到 vendor.js 文件,请在此注释标记之间添加 <script> 到您的 index.html :

Add a <script> to your index.html between this comments tags if you use bower/buildjs to compact all your scripts to vendor.js file :

<!-- endbower -->
<script src="bower_components/angular-i18n/angular-locale_fr-fr.js"></script>
<!-- endbuild -->

就是这样.

这篇关于angularjs 过滤器“日期"和 $locale 服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆