How can I get a localized version of a YUI 3 or AlloyUI component?

旧街凉风 提交于 2019-12-12 01:45:18

问题


As an example, how could I render an AlloyUI scheduler which has the days in Japanese rather than English?


回答1:


To access a localized version of a YUI 3 component you must use the YUI config object's lang property. When specifying a YUI sandbox, pass it the language code(s) which you want the component(s) to be localized for:

YUI({ lang : 'ja-JP' }).use( // your code here...

Here is a specific example with the AlloyUI scheduler:

YUI({ lang : 'ja-JP' }).use('aui-scheduler', function(Y) {
    new Y.Scheduler({
        boundingBox: '#myScheduler',
        items: [],
        render: true,
        views: [new Y.SchedulerWeekView()]
    });
});

You may also need to internationalize the strings attribute of your components yourself. For example, the Scheduler has many strings that are not internationalized by changing the YUI lang attribute. If you want to fully internationalize it, you'll need to translate each string.

For more information see the YUI Internationalization documentation (specifically the Requesting Preferred Languages section).



来源:https://stackoverflow.com/questions/25151139/how-can-i-get-a-localized-version-of-a-yui-3-or-alloyui-component

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!