Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
fuyue82
o2oa
提交
3bd37a15
o2oa
项目概览
fuyue82
/
o2oa
与 Fork 源项目一致
Fork自
浙江兰德纵横网络技术股份有限公司 / o2oa
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
o2oa
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3bd37a15
编写于
4月 16, 2021
作者:
O
o2sword
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
多语言国际化5
上级
124e84c8
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
56 addition
and
36 deletion
+56
-36
o2server/commons/language/platform_en.properties
o2server/commons/language/platform_en.properties
+1
-1
o2server/x_base_core_project/src/main/java/com/x/base/core/project/exception/LanguagePromptException.java
.../base/core/project/exception/LanguagePromptException.java
+1
-0
o2server/x_base_core_project/src/main/java/com/x/base/core/project/jaxrs/ResponseFactory.java
...n/java/com/x/base/core/project/jaxrs/ResponseFactory.java
+4
-1
o2server/x_base_core_project/src/main/java/com/x/base/core/project/tools/LanguageTools.java
...ain/java/com/x/base/core/project/tools/LanguageTools.java
+50
-34
未找到文件。
o2server/commons/language/platform_en.properties
浏览文件 @
3bd37a15
...
...
@@ -2,6 +2,6 @@ com.x.base.core.project.exception.ExceptionAccessDenied=User :{} Insufficient pe
com.x.base.core.project.exception.ExceptionAccessDenied_1
=
User :{} access object class:{}, id:{}, insufficient permission.
com.x.base.core.project.exception.ExceptionAccessDeniedOrEntityNotExist
=
User :{} Insufficient permissions or the object does not exist.
com.x.base.core.project.exception.ExceptionAccessDeniedOrEntityNotExist_1
=
User :{} Insufficient permission or object does not exist, {}.
com.x.base.core.project.exception.ExceptionEntityNotExist
=
The {
2} object identified as :{1
} does not exist.
com.x.base.core.project.exception.ExceptionEntityNotExist
=
The {
1} object identified as :{0
} does not exist.
com.x.base.core.project.exception.ExceptionEntityNotExist_1
=
The object identified as :{} does not exist.
com.x.base.core.project.exception.ExceptionEntityNotExist_2
=
Object of type: {} does not exist.
o2server/x_base_core_project/src/main/java/com/x/base/core/project/exception/LanguagePromptException.java
浏览文件 @
3bd37a15
...
...
@@ -59,4 +59,5 @@ public abstract class LanguagePromptException extends PromptException {
public
void
setLanguageKey
(
String
languageKey
)
{
this
.
languageKey
=
languageKey
;
}
}
o2server/x_base_core_project/src/main/java/com/x/base/core/project/jaxrs/ResponseFactory.java
浏览文件 @
3bd37a15
...
...
@@ -78,7 +78,10 @@ public class ResponseFactory {
if
(
result
.
getType
().
equals
(
ActionResult
.
Type
.
error
))
{
if
((
result
.
throwable
instanceof
LanguagePromptException
))
{
LanguagePromptException
e
=
(
LanguagePromptException
)
result
.
throwable
;
result
.
setMessage
((
e
.
getFormatMessage
(
result
.
getPrompt
(),
request
.
getHeader
(
Accept_Language
))));
String
message
=
e
.
getFormatMessage
(
result
.
getPrompt
(),
request
.
getHeader
(
Accept_Language
));
if
(
StringUtils
.
isNotBlank
(
message
))
{
result
.
setMessage
(
message
);
}
}
if
((
result
.
throwable
instanceof
CallbackPromptException
))
{
return
Response
.
ok
(
callbackError
(
result
)).
build
();
...
...
o2server/x_base_core_project/src/main/java/com/x/base/core/project/tools/LanguageTools.java
浏览文件 @
3bd37a15
package
com.x.base.core.project.tools
;
import
com.x.base.core.project.config.Config
;
import
com.x.base.core.project.logger.Logger
;
import
com.x.base.core.project.logger.LoggerFactory
;
import
org.apache.commons.lang3.StringUtils
;
import
java.util.Locale
;
...
...
@@ -8,6 +10,8 @@ import java.util.ResourceBundle;
public
class
LanguageTools
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
LanguageTools
.
class
);
private
final
static
String
LANGUAGE_PLATFORM
=
"language.platform"
;
public
static
String
getValue
(
String
key
)
{
...
...
@@ -15,54 +19,66 @@ public class LanguageTools {
}
public
static
String
getValue
(
String
key
,
String
locale
)
{
String
message
=
null
;
if
(
StringUtils
.
isBlank
(
key
)){
return
null
;
}
ResourceBundle
resourceBundle
=
null
;
if
(
StringUtils
.
isBlank
(
locale
)){
try
{
locale
=
Config
.
person
().
getLanguage
();
}
catch
(
Exception
e
)
{
try
{
ResourceBundle
resourceBundle
=
null
;
if
(
StringUtils
.
isBlank
(
locale
)){
try
{
locale
=
Config
.
person
().
getLanguage
();
}
catch
(
Exception
e
)
{
}
}
}
if
(
StringUtils
.
isBlank
(
locale
)){
resourceBundle
=
ResourceBundle
.
getBundle
(
LANGUAGE_PLATFORM
,
Locale
.
getDefault
());
}
else
if
(
"zh"
.
equalsIgnoreCase
(
locale
)
||
"zh_CN"
.
equalsIgnoreCase
(
locale
))
{
resourceBundle
=
ResourceBundle
.
getBundle
(
LANGUAGE_PLATFORM
,
Locale
.
SIMPLIFIED_CHINESE
);
}
else
if
(
locale
.
toLowerCase
().
startsWith
(
"en"
))
{
resourceBundle
=
ResourceBundle
.
getBundle
(
LANGUAGE_PLATFORM
,
Locale
.
ENGLISH
);
}
else
if
(
"zh_HK"
.
equalsIgnoreCase
(
locale
)
||
"zh_TW"
.
equalsIgnoreCase
(
locale
))
{
resourceBundle
=
ResourceBundle
.
getBundle
(
LANGUAGE_PLATFORM
,
Locale
.
TRADITIONAL_CHINESE
);
}
else
{
resourceBundle
=
ResourceBundle
.
getBundle
(
LANGUAGE_PLATFORM
,
Locale
.
getDefault
());
if
(
StringUtils
.
isBlank
(
locale
)){
resourceBundle
=
ResourceBundle
.
getBundle
(
LANGUAGE_PLATFORM
,
Locale
.
getDefault
());
}
else
if
(
"zh"
.
equalsIgnoreCase
(
locale
)
||
"zh_CN"
.
equalsIgnoreCase
(
locale
))
{
resourceBundle
=
ResourceBundle
.
getBundle
(
LANGUAGE_PLATFORM
,
Locale
.
SIMPLIFIED_CHINESE
);
}
else
if
(
locale
.
toLowerCase
().
startsWith
(
"en"
))
{
resourceBundle
=
ResourceBundle
.
getBundle
(
LANGUAGE_PLATFORM
,
Locale
.
ENGLISH
);
}
else
if
(
"zh_HK"
.
equalsIgnoreCase
(
locale
)
||
"zh_TW"
.
equalsIgnoreCase
(
locale
))
{
resourceBundle
=
ResourceBundle
.
getBundle
(
LANGUAGE_PLATFORM
,
Locale
.
TRADITIONAL_CHINESE
);
}
else
{
resourceBundle
=
ResourceBundle
.
getBundle
(
LANGUAGE_PLATFORM
,
Locale
.
getDefault
());
}
message
=
resourceBundle
.
getString
(
key
);
}
catch
(
Exception
e
)
{
logger
.
print
(
"LanguageTools resourceBundle error:"
+
e
.
getMessage
());
}
return
resourceBundle
.
getString
(
key
)
;
return
message
;
}
public
static
String
getValue
(
String
baseName
,
String
key
,
String
locale
)
{
String
message
=
null
;
if
(
StringUtils
.
isBlank
(
key
)){
return
null
;
}
ResourceBundle
resourceBundle
=
null
;
if
(
StringUtils
.
isBlank
(
locale
)){
try
{
locale
=
Config
.
person
().
getLanguage
();
}
catch
(
Exception
e
)
{
try
{
ResourceBundle
resourceBundle
=
null
;
if
(
StringUtils
.
isBlank
(
locale
)){
try
{
locale
=
Config
.
person
().
getLanguage
();
}
catch
(
Exception
e
)
{
}
}
}
if
(
StringUtils
.
isBlank
(
locale
)){
resourceBundle
=
ResourceBundle
.
getBundle
(
baseName
,
Locale
.
getDefault
());
}
else
if
(
"zh"
.
equalsIgnoreCase
(
locale
)
||
"zh_CN"
.
equalsIgnoreCase
(
locale
))
{
resourceBundle
=
ResourceBundle
.
getBundle
(
baseName
,
Locale
.
SIMPLIFIED_CHINESE
);
}
else
if
(
locale
.
toLowerCase
().
startsWith
(
"en"
))
{
resourceBundle
=
ResourceBundle
.
getBundle
(
baseName
,
Locale
.
ENGLISH
);
}
else
if
(
"zh_HK"
.
equalsIgnoreCase
(
locale
)
||
"zh_TW"
.
equalsIgnoreCase
(
locale
))
{
resourceBundle
=
ResourceBundle
.
getBundle
(
baseName
,
Locale
.
TRADITIONAL_CHINESE
);
}
else
{
resourceBundle
=
ResourceBundle
.
getBundle
(
baseName
,
Locale
.
getDefault
());
if
(
StringUtils
.
isBlank
(
locale
)){
resourceBundle
=
ResourceBundle
.
getBundle
(
baseName
,
Locale
.
getDefault
());
}
else
if
(
"zh"
.
equalsIgnoreCase
(
locale
)
||
"zh_CN"
.
equalsIgnoreCase
(
locale
))
{
resourceBundle
=
ResourceBundle
.
getBundle
(
baseName
,
Locale
.
SIMPLIFIED_CHINESE
);
}
else
if
(
locale
.
toLowerCase
().
startsWith
(
"en"
))
{
resourceBundle
=
ResourceBundle
.
getBundle
(
baseName
,
Locale
.
ENGLISH
);
}
else
if
(
"zh_HK"
.
equalsIgnoreCase
(
locale
)
||
"zh_TW"
.
equalsIgnoreCase
(
locale
))
{
resourceBundle
=
ResourceBundle
.
getBundle
(
baseName
,
Locale
.
TRADITIONAL_CHINESE
);
}
else
{
resourceBundle
=
ResourceBundle
.
getBundle
(
baseName
,
Locale
.
getDefault
());
}
message
=
resourceBundle
.
getString
(
key
);
}
catch
(
Exception
e
)
{
logger
.
print
(
"LanguageTools resourceBundle error:"
+
e
.
getMessage
());
}
return
resourceBundle
.
getString
(
key
)
;
return
message
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录