# bb-i18n **Repository Path**: RemoteControl/bb-i18n ## Basic Information - **Project Name**: bb-i18n - **Description**: Spring Boot 国际化组件,基于DB! - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-05-13 - **Last Updated**: 2024-06-17 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # bb-i18n #### 介绍 Spring Boot 国际化组件,基于DB!国际化数据将优先从db提取,其次从本地提取(由配置决定),在本地无国际化数据时将反向同步至db,后期用户可以将无国际化(message=null)数据统一再翻译一份即可。 #### 系统要求 - 基于 spring-boot 开发(spring-boot2.x) - 需要 db(mysql or 其他) #### 模块说明(暂未写) #### 使用说明 1. 创建表以配置相关国际化数据 ```mysql CREATE TABLE `config_i18n_message` ( `code` varchar(128) NOT NULL, `module` varchar(64) NOT NULL COMMENT '模块/应用,为空字符则全局', `message` varchar(512) DEFAULT NULL COMMENT '显示值', `language` varchar(128) NOT NULL COMMENT '语言,如:zh-CN/en', `remark` varchar(128) DEFAULT NULL COMMENT '备注', `create_time` datetime DEFAULT NULL, `update_time` datetime DEFAULT NULL, PRIMARY KEY (`code`,`module`,`language`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='国际化配置表'; ``` 2. 添加maven依赖(目前未添加到公用maven库,请自行打包到私服或者 mvn install 至本地) 引入依赖条件: - mvn install 至本地 - deploy 至私服 - 使用作者的gitee 版本库,pom添加如下 ```yaml jin-gitee-maven https://gitee.com/RemoteControl/maven-repository/raw/master ``` 添加依赖 ```xml cn.bblocks.common bb-i18n-starter-springboot 1.0.2-SNAPSHOT ``` 3. 配置以启动(全部参数如下) ```yaml spring: # 应用名称,bb-i18n系统中上报未定义code有用 application: name: xxx #bb-i18n配置 ex: i18n: # 启动开关 enable: true # request,cookie提取语言名称name,默认:lang,head固定提取:Accept-Language name-of-language-key: lang # 同步配置方案,建议每天整点同步一次 cron: 0 0 */1 * * ? # 未找到i18n的code时,是否将其记录到表中,以便统一处理 mark: true # 限制语言-否则可能出现大量错误码转义需求(en/zh)-仅限mark=true生效 mark-limit-languages: - en - zh # i18n配置表的名称 config-table: config_i18n_message data-source: primary # i18nDataSource 配置 db: driver-class-name: com.mysql.cj.jdbc.Driver password: 000000 url: jdbc:mysql://127.0.0.1:3306/test?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true&allowPublicKeyRetrieval=true username: root # 默认语言 default-locale: zh-CN # 未找到配置时,再使用Spring默认方案 use-locale: true #本地i18n配置(自行百度) messages: basename: i18n/messages always-use-message-format: false encoding: UTF-8 fallback-to-system-locale: false #Whether to use the message code as the default message instead of throwing a "NoSuchMessageException". Recommended during development only. use-code-as-default-message: false ``` #### 缺陷/待改进 暂无 #### 参与贡献 1. Fork 本仓库 2. 新建 Feat_xxx 分支 3. 提交代码 4. 新建 Pull Request #### 特技 1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md 2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com) 3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目 4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目 5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) 6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)