怎么国际化

1、配置属性文件

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

2、freemarker模板中使用国际化

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

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

(1)、模块菜单国际化

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

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

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

(3)、字段提示国际化

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

(4)、分组视图国际化

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

(5)POJO模型名称国际化

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

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

  1. //配置:nameKey、descKey
  2. //如:
  3. public enum ConvertStatus implements EnumInterface{
  4. NEW(1,"dodo.privilege.enums.ConvertStatus.name.new","dodo.privilege.enums.ConvertStatus.desc.new"),
  5. ING(2,"dodo.privilege.enums.ConvertStatus.name.ing","dodo.privilege.enums.ConvertStatus.desc.ing"),
  6. OK(3,"dodo.privilege.enums.ConvertStatus.name.ok","dodo.privilege.enums.ConvertStatus.desc.ok"),
  7. ERROR(4,"dodo.privilege.enums.ConvertStatus.name.error","dodo.privilege.enums.ConvertStatus.desc.error"),
  8. NOFILE(5,"dodo.privilege.enums.ConvertStatus.name.nofile","dodo.privilege.enums.ConvertStatus.desc.nofile"),
  9. NOTSUPPORT(6,"dodo.privilege.enums.ConvertStatus.name.nosupport","dodo.privilege.enums.ConvertStatus.desc.nosupport"),
  10. EXCEPTION(7,"dodo.privilege.enums.ConvertStatus.name.exception","dodo.privilege.enums.ConvertStatus.desc.exception");
  11. private ConvertStatus(Integer seq,String nameKey,String descKey) {
  12. this.nameKey = nameKey;
  13. this.descKey = descKey;
  14. this.seq = seq;
  15. }
  16. private Integer seq;
  17. private String name;
  18. private String nameKey;
  19. private String desc;
  20. private String descKey;
  21. public String getName() {
  22. return name;
  23. }
  24. public String getNameKey() {
  25. return nameKey;
  26. }
  27. public String getDesc() {
  28. return desc;
  29. }
  30. public String getDescKey() {
  31. return descKey;
  32. }
  33. @Override
  34. public Integer getSeq() {
  35. return seq;
  36. }
  37. public static class Converter extends EnumAttributeConverter<ConvertStatus> {
  38. @Override
  39. public Class<ConvertStatus> getClazz() {
  40. return ConvertStatus.class;
  41. }
  42. }
  43. }

4、国际化效果

登录图片