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
Show 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;
...
@@ -5,6 +5,7 @@ import java.util.Locale;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.MessageSource
;
import
org.springframework.context.MessageSource
;
import
org.springframework.context.NoSuchMessageException
;
import
org.springframework.context.i18n.LocaleContextHolder
;
import
org.springframework.context.i18n.LocaleContextHolder
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
...
@@ -45,6 +46,7 @@ public class I18NUtils {
...
@@ -45,6 +46,7 @@ public class I18NUtils {
* @date 2018年4月11日 下午8:35:15
* @date 2018年4月11日 下午8:35:15
*/
*/
public
static
String
getMessage
(
String
LangID
,
String
key
,
Object
...
values
){
public
static
String
getMessage
(
String
LangID
,
String
key
,
Object
...
values
){
try
{
if
(
StringUtil
.
isEmpty
(
LangID
)){
//为空默认为中文
if
(
StringUtil
.
isEmpty
(
LangID
)){
//为空默认为中文
Locale
.
setDefault
(
Locale
.
CHINA
);
Locale
.
setDefault
(
Locale
.
CHINA
);
}
else
{
}
else
{
...
@@ -58,6 +60,9 @@ public class I18NUtils {
...
@@ -58,6 +60,9 @@ public class I18NUtils {
System
.
out
.
println
(
"locale---------------"
+
locale
);
System
.
out
.
println
(
"locale---------------"
+
locale
);
String
msg
=
source
.
getMessage
(
key
,
null
,
locale
);
String
msg
=
source
.
getMessage
(
key
,
null
,
locale
);
return
MessageFormat
.
format
(
msg
,
values
);
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