mirror of
				https://github.com/dromara/RuoYi-Vue-Plus.git
				synced 2025-11-04 16:23:42 +08:00 
			
		
		
		
	add 增加 完整国际化解决方案
This commit is contained in:
		@@ -36,6 +36,7 @@ RuoYi-Vue-Plus 是基于 RuoYi-Vue 针对 `分布式集群` 场景升级 定期
 | 
				
			|||||||
* 工具类框架 Hutool、Lombok 减少代码冗余 增加安全性
 | 
					* 工具类框架 Hutool、Lombok 减少代码冗余 增加安全性
 | 
				
			||||||
* 代码生成器 一键生成前后端代码
 | 
					* 代码生成器 一键生成前后端代码
 | 
				
			||||||
* 部署方式 Docker 容器编排 一键部署业务集群
 | 
					* 部署方式 Docker 容器编排 一键部署业务集群
 | 
				
			||||||
 | 
					* 国际化 Spring 标准国际化方解决方案
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## 参考文档
 | 
					## 参考文档
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -16,8 +16,8 @@ user.password.not.valid=
 | 
				
			|||||||
user.email.not.valid=
 | 
					user.email.not.valid=
 | 
				
			||||||
user.mobile.phone.number.not.valid=
 | 
					user.mobile.phone.number.not.valid=
 | 
				
			||||||
user.login.success=
 | 
					user.login.success=
 | 
				
			||||||
 | 
					user.register.success=register success
 | 
				
			||||||
user.notfound=
 | 
					user.notfound=
 | 
				
			||||||
user.forcelogout=
 | 
					 | 
				
			||||||
user.unknown.error=
 | 
					user.unknown.error=
 | 
				
			||||||
 | 
					
 | 
				
			||||||
##文件上传消息
 | 
					##文件上传消息
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -0,0 +1,48 @@
 | 
				
			|||||||
 | 
					package com.ruoyi.framework.config;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import cn.hutool.core.util.StrUtil;
 | 
				
			||||||
 | 
					import org.jetbrains.annotations.NotNull;
 | 
				
			||||||
 | 
					import org.springframework.context.annotation.Bean;
 | 
				
			||||||
 | 
					import org.springframework.context.annotation.Configuration;
 | 
				
			||||||
 | 
					import org.springframework.web.servlet.LocaleResolver;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import javax.servlet.http.HttpServletRequest;
 | 
				
			||||||
 | 
					import javax.servlet.http.HttpServletResponse;
 | 
				
			||||||
 | 
					import java.util.Locale;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * 国际化配置
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @author Lion Li
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					@Configuration
 | 
				
			||||||
 | 
					public class I18nConfig {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Bean
 | 
				
			||||||
 | 
						public LocaleResolver localeResolver() {
 | 
				
			||||||
 | 
							return new I18nLocaleResolver();
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * 获取请求头国际化信息
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						static class I18nLocaleResolver implements LocaleResolver {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							@NotNull
 | 
				
			||||||
 | 
							@Override
 | 
				
			||||||
 | 
							public Locale resolveLocale(HttpServletRequest httpServletRequest) {
 | 
				
			||||||
 | 
								String language = httpServletRequest.getHeader("content-language");
 | 
				
			||||||
 | 
								Locale locale = Locale.getDefault();
 | 
				
			||||||
 | 
								if (StrUtil.isNotBlank(language)) {
 | 
				
			||||||
 | 
									String[] split = language.split("_");
 | 
				
			||||||
 | 
									locale = new Locale(split[0], split[1]);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								return locale;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							@Override
 | 
				
			||||||
 | 
							public void setLocale(@NotNull HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Locale locale) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user