Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
S
sentinel
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
曲欣亮
sentinel
Commits
c17a0b70
Commit
c17a0b70
authored
Oct 09, 2018
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加国际化配置
parent
1f81f6df
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
41 additions
and
0 deletions
+41
-0
FilmApplication.java
src/main/java/com/egolm/film/FilmApplication.java
+4
-0
DefaultMessages.java
src/main/java/com/egolm/film/messages/DefaultMessages.java
+27
-0
Messages.java
src/main/java/com/egolm/film/messages/Messages.java
+7
-0
application.properties
src/main/resources/application.properties
+3
-0
message.properties
src/main/resources/i18n/message.properties
+0
-0
message_en_US.properties
src/main/resources/i18n/message_en_US.properties
+0
-0
message_zh_CN.properties
src/main/resources/i18n/message_zh_CN.properties
+0
-0
No files found.
src/main/java/com/egolm/film/FilmApplication.java
View file @
c17a0b70
package
com
.
egolm
.
film
;
package
com
.
egolm
.
film
;
import
java.util.Locale
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.cache.annotation.EnableCaching
;
import
org.springframework.cache.annotation.EnableCaching
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.i18n.LocaleContextHolder
;
import
org.springframework.transaction.annotation.EnableTransactionManagement
;
import
org.springframework.transaction.annotation.EnableTransactionManagement
;
...
@@ -18,6 +21,7 @@ public class FilmApplication {
...
@@ -18,6 +21,7 @@ public class FilmApplication {
private
static
ApplicationContext
applicationContext
;
private
static
ApplicationContext
applicationContext
;
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
LocaleContextHolder
.
setDefaultLocale
(
Locale
.
CHINA
);
applicationContext
=
SpringApplication
.
run
(
FilmApplication
.
class
,
args
);
applicationContext
=
SpringApplication
.
run
(
FilmApplication
.
class
,
args
);
}
}
...
...
src/main/java/com/egolm/film/messages/DefaultMessages.java
0 → 100644
View file @
c17a0b70
package
com
.
egolm
.
film
.
messages
;
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
;
import
com.egolm.film.config.XException
;
@Component
public
class
DefaultMessages
implements
Messages
{
@Autowired
protected
MessageSource
messageSource
;
public
String
get
(
String
name
,
String
...
args
)
{
try
{
return
messageSource
.
getMessage
(
name
,
args
,
LocaleContextHolder
.
getLocale
());
}
catch
(
NoSuchMessageException
e
)
{
return
name
;
}
catch
(
Exception
e
)
{
throw
new
XException
(
""
,
e
);
}
}
}
src/main/java/com/egolm/film/messages/Messages.java
0 → 100644
View file @
c17a0b70
package
com
.
egolm
.
film
.
messages
;
public
interface
Messages
{
public
String
get
(
String
name
,
String
...
args
);
}
src/main/resources/application.properties
View file @
c17a0b70
...
@@ -13,3 +13,6 @@ spring.http.encoding.force=true
...
@@ -13,3 +13,6 @@ spring.http.encoding.force=true
spring.http.encoding.enabled
=
true
spring.http.encoding.enabled
=
true
spring.http.encoding.charset
=
utf-8
spring.http.encoding.charset
=
utf-8
spring.messages.basename
=
classpath:i18n/messages
spring.messages.cache-seconds
=
3600
spring.messages.encoding
=
UTF-8
\ No newline at end of file
src/main/resources/i18n/message.properties
0 → 100644
View file @
c17a0b70
src/main/resources/i18n/message_en_US.properties
0 → 100644
View file @
c17a0b70
src/main/resources/i18n/message_zh_CN.properties
0 → 100644
View file @
c17a0b70
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