如何本地化 YUI 的日历组件?
我在我的网站中使用 YUI 的日历组件。我已将代码作为 Javascript 插入到 ASP 页面中,如 此示例演示。此示例演示如何为一种区域设置(本例中为德语)配置日历组件。我想知道如何根据每个用户的浏览器语言配置日历?
I am using YUI's calendar component in my website. I have inserted the code into an ASP page as Javascript as this example demonstrates. This example shows how to configure the calendar component for one locale (German in this case). What I would like to know is how can I configure the calendar for each user based on the language of their browser?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
比我的其他答案中显示的更简单的解决方案是使用 ScriptManager 控件的 EnableScriptLocalization 属性:
这将自动尝试包含脚本的本地化版本,例如
yui-calendar-localization-de-DE.js
。An even easier solution than shown in my other answer would be to use the ScriptManager control's EnableScriptLocalization property:
This will automatically try to include a localized version of the script, e.g.
yui-calendar-localization-de-DE.js
.将特定于语言的初始化代码(如您链接到的页面上所示)放入每种语言的单独文件中(例如“yui-calendar-de-DE.js”)。
然后在页面的代码隐藏中,包含正确的包含文件,具体取决于用户的首选语言,例如使用如下内容:
更新:
本地化文件(您应该自己创建)可能如下所示:
然后在您的页面,您在其中创建日历,使用该函数来本地化日历:
Put the language specific initialization code (as shown on the page you linked to) into separate files per language (e.g. "yui-calendar-de-DE.js").
Then in the code-behind of your page, include the correct include file, depending on the user's preferred language, e.g using something like this:
Update:
The localization files (which you should create by yourself) might look like this:
Then on your page, where you create the calendar, use that function to localize the calendar: