How can I get a localized version of a YUI 3 or Al

2019-09-17 17:02发布

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

1条回答
2楼-- · 2019-09-17 17:29

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).

查看更多
登录 后发表回答