怎么国际化

1、配置属性文件

(1)后台国际化文件目录:/dodo/src/main/webapp/WEB-INF/languages/back
(2)前台国际化文件目录:/dodo/src/main/webapp/WEB-INF/languages/front

2、freemarker模板中使用国际化

[@s.m "{属性key}"/]
如:
[@s.m "dodo.entity.list.name"/]

3、生成代码的国际化配置

(1)、模块菜单国际化

    // 配置 @DodoMenu.nameKey
    //如:
    @DodoMenu(nameKey = "dodo.privilege.admin.menuNameKey", level = DodoMenuLevel.LEVEL1, sortSeq = 1)

(2)、字段显示名称国际化

    // 配置 @DodoField.nameKey
    //如:
    @DodoField(nameKey = "dodo.privilege.admin.base.Admin.namekey.addBy", sortSeq = -1, isAdmin = true, queryOnList = true)
    private Admin                        addBy;

(3)、字段提示国际化

    //配置 @DodoField.infoTipKey
    //如:
    @DodoField(name = "密码", sortSeq = 1, listable = false, ispassword = true, infoTipKey = "dodo.privilege.admin.base.Admin.infoTip.adminPassword")
    private String                       adminPassword;

(4)、分组视图国际化

    //配置:@DodoViewGroup.groupNameKey
    //如:
    @DodoViewGroup(groupSeq = 0, groupNameKey = "dodo.privilege.admin.base.Admin.groupName.0")
    private String                       mobile;

(5)POJO模型名称国际化

    //配置:@DodoRight.nameKey
    //如:
    @DodoRight(nameKey = "dodo.privilege.admin.base.Admin.entityKey")

(6)枚举显示名称、描述国际化

//配置:nameKey、descKey
//如:
public enum ConvertStatus implements EnumInterface{
    NEW(1,"dodo.privilege.enums.ConvertStatus.name.new","dodo.privilege.enums.ConvertStatus.desc.new"),
    ING(2,"dodo.privilege.enums.ConvertStatus.name.ing","dodo.privilege.enums.ConvertStatus.desc.ing"),
    OK(3,"dodo.privilege.enums.ConvertStatus.name.ok","dodo.privilege.enums.ConvertStatus.desc.ok"),
    ERROR(4,"dodo.privilege.enums.ConvertStatus.name.error","dodo.privilege.enums.ConvertStatus.desc.error"),
    NOFILE(5,"dodo.privilege.enums.ConvertStatus.name.nofile","dodo.privilege.enums.ConvertStatus.desc.nofile"),
    NOTSUPPORT(6,"dodo.privilege.enums.ConvertStatus.name.nosupport","dodo.privilege.enums.ConvertStatus.desc.nosupport"),
    EXCEPTION(7,"dodo.privilege.enums.ConvertStatus.name.exception","dodo.privilege.enums.ConvertStatus.desc.exception");
    private ConvertStatus(Integer seq,String nameKey,String descKey) {
        this.nameKey = nameKey;
        this.descKey = descKey;
        this.seq = seq;
    }

    private Integer seq;
    private String name;
    private String nameKey;
    private String desc;
    private String descKey;
    public String getName() {
        return name;
    }
    public String getNameKey() {
        return nameKey;
    }
    public String getDesc() {
        return desc;
    }
    public String getDescKey() {
        return descKey;
    }
    @Override
    public Integer getSeq() {
        return seq;
    }    
    public static class Converter extends EnumAttributeConverter<ConvertStatus> {

        @Override
        public Class<ConvertStatus> getClazz() {
            return ConvertStatus.class;
        }
    }
}

4、国际化效果

登录图片

Copyright © Dodo Framework 2019 all right reservedModify At: 2019-12-17 13:51:27