跳转至

多语言支持

基本用法

现在,Valine开始支持多语言。默认内置:

  • zh-cn
  • en
var valine = new Valine();
valine.init({
    el:'.comment',
    appId:'your leancloud appid',
    appKey:'your leancloud appkey',
    lang:'en' // 设置这里就ok
})

Warning

如果有需要支持其他语言,请严格按照下面的localeMode格式书写内容:

var localeName = 'en',
    localeMode = {
        head:{
            nick:'NickName',
            mail:'E-Mail',
            link:'Website(http://)',
        },
        tips:{
            comments:'Comments',
            sofa:'No comments yet.',
            busy:'Submit is busy, please wait...',
            again:'Sorry, this is a wrong calculation.',
            limit:'The largest number of words %d'
        },
        ctrl:{
            reply:'Reply',
            ok:'Ok',
            sure:'Sure',
            cancel:'Cancel',
            confirm:'Confirm',
            continue:'Continue',
            more:'Load More...',
            try:'Once More?',
        },
        error:{
            99:'Initialization failed, Please check the `el` element in the init method.',
            100:'Initialization failed, Please check your appId and appKey.',
            401:'Unauthorized operation, Please check your appId and appKey.',
            403:'Access denied by api domain white list, Please check your security domain.',
        },
        timeago:{
            seconds:'seconds ago',
            minutes:'minutes ago',
            hours:'hours ago',
            days:'days ago',
            now:'just now'
        }
    };

var valine = new Valine();
// 1.安装语言
valine.installLocale(localeName,localeMode)
// 2.初始化Valine
valine.init({
    el:'.comment',
    appId:'your leancloud appid',
    appKey:'your leancloud appkey',
    lang:localeName
})

Info

该配置从v1.1.8-beta9开始支持。

评论