Angularjs和$区域 [英] Angularjs and $locale

查看:94
本文介绍了Angularjs和$区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以手动设置$区域设置一些应用程序?

Can I set $locale for some application manually?

是否有可能只支持当地人的办法是包括角库的本地化文件当前的​​语言环境。如果有多个文化?在这种情况下,我必须动态加载本地化文件?我缺少什么?

Is it possible that only way to support locals is to include localization file from angular library for current locale. What if there are multiple cultures? In that case I have to load localization files dynamically? What am I missing?

推荐答案

老实说,在棱角分明$现场服务是pretty原始依然。这真的很不错,但似乎缺乏灵活性在这个区域。最大的问题是,即使你通过动态重新加载正确的语言环境文件切换您的语言环境,像日期过滤器不会知道,因为当他们建立他们自己的注册区域信息,你已经改变了它。所以,你有两个选择目前:1刷新所选择的语言环境的网页...或2编写您自己的语言环境提供和使用它的过滤器

Honestly, the $locale service in angular is pretty primitive still. It's really good, but it seems to lack flexibility in this area. The biggest issue is that even if you switch your locale by dynamically reloading the proper locale file, things like the date filter won't know you've changed it because they're registering their locale information when they're set up. So you have a couple of choices currently: 1. Reload the page with the selected locale... or 2. Write your own Locale Provider and Filters that use it.

它的可能的有可能创建一个将动态地加载正确的脚本文件,重新初始化所有受影响的过滤器和服务,然后刷新意见的服务,但我真的不知道这将会导致什么都在这一点上。

It might be possible create a service that would dynamically load the proper script file, reinitialize all affected filters and services, then refresh the views, but I'm not really sure what all that would involve at this point.

这篇关于Angularjs和$区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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