Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
S
shop
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
曲欣亮
shop
Commits
5ff10c80
Commit
5ff10c80
authored
Sep 17, 2019
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x
parent
3596836a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
11 deletions
+16
-11
I18NUtils.java
src/main/java/com/egolm/shop/util/I18NUtils.java
+16
-11
No files found.
src/main/java/com/egolm/shop/util/I18NUtils.java
View file @
5ff10c80
...
...
@@ -5,6 +5,7 @@ import java.util.Locale;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.MessageSource
;
import
org.springframework.context.NoSuchMessageException
;
import
org.springframework.context.i18n.LocaleContextHolder
;
import
org.springframework.stereotype.Component
;
...
...
@@ -45,19 +46,23 @@ public class I18NUtils {
* @date 2018年4月11日 下午8:35:15
*/
public
static
String
getMessage
(
String
LangID
,
String
key
,
Object
...
values
){
if
(
StringUtil
.
isEmpty
(
LangID
)){
//为空默认为中文
Locale
.
setDefault
(
Locale
.
CHINA
);
}
else
{
if
(
LangID
.
equals
(
"900"
)){
//英文
Locale
.
setDefault
(
Locale
.
ENGLISH
);
}
else
{
try
{
if
(
StringUtil
.
isEmpty
(
LangID
)){
//为空默认为中文
Locale
.
setDefault
(
Locale
.
CHINA
);
}
else
{
if
(
LangID
.
equals
(
"900"
)){
//英文
Locale
.
setDefault
(
Locale
.
ENGLISH
);
}
else
{
Locale
.
setDefault
(
Locale
.
CHINA
);
}
}
}
Locale
locale
=
LocaleContextHolder
.
getLocale
();
System
.
out
.
println
(
"locale---------------"
+
locale
);
String
msg
=
source
.
getMessage
(
key
,
null
,
locale
);
return
MessageFormat
.
format
(
msg
,
values
);
Locale
locale
=
LocaleContextHolder
.
getLocale
();
System
.
out
.
println
(
"locale---------------"
+
locale
);
String
msg
=
source
.
getMessage
(
key
,
null
,
locale
);
return
MessageFormat
.
format
(
msg
,
values
);
}
catch
(
Exception
e
)
{
return
key
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment