Skip to content
This repository was archived by the owner on Dec 12, 2018. It is now read-only.

Commit bcb7792

Browse files
committed
Updated i18n section.
1 parent ce8f9d8 commit bcb7792

1 file changed

Lines changed: 36 additions & 4 deletions

File tree

docs/source/i18n.rst

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,35 @@ All of the default views are fully internationalized using a standard `Java Reso
99

1010
#else
1111

12-
All of the |project| default views are fully internationalized using standard Spring ``MessageSource`` internationalization support. Spring Boot makes this even easier by supporting a default ``MessageSource`` as a ``messages`` resource bundle at the root of the classpath. For example, assuming a Maven/Gradle project layout:
12+
All of the |project| default views are fully internationalized using standard Spring ``MessageSource`` internationalization support.
13+
14+
#if( $springboot)
15+
16+
Spring Boot makes this even easier by supporting a default ``MessageSource`` as a ``messages`` resource bundle at the root of the classpath.
17+
18+
#elseif( $spring )
19+
20+
You can support a default ``MessageSource`` as a ``messages`` resource bundle at the root of the classpath.
21+
22+
Create a configuration somewhere in your project like so:
23+
24+
.. code-block:: java
25+
26+
@Configuration
27+
public class MessageConfig {
28+
29+
@Bean
30+
public MessageSource messageSource() {
31+
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
32+
messageSource.setBasename("messages");
33+
messageSource.setDefaultEncoding("UTF-8");
34+
return messageSource;
35+
}
36+
}
37+
38+
#end
39+
40+
Assuming a Maven/Gradle project layout, here's the structure for your internationalization properties files:
1341

1442
.. parsed-literal::
1543
@@ -21,7 +49,6 @@ All of the |project| default views are fully internationalized using standard Sp
2149
\|-- messages_de.properties
2250
\|-- ... etc ...
2351
24-
2552
#end
2653

2754
Languages
@@ -47,8 +74,13 @@ You can add other languages as follows:
4774

4875
#else
4976

50-
1. Create one or more ``messages_LOCALE.properties`` files to the root package (as shown above), for example ``messages_es.properties`` for Spanish (or even ``messages_es_ES.properties`` for Spain's dialect of Spanish and ``messages_es_MX.properties`` for Mexican dialect of Spanish, etc).
51-
2. In each locale-specific file, re-define each Stormpath :ref:`i18n property <i18n-properties-file>` value in that language.
77+
1. Create a ``messages.properties`` file in the root package (as shown above). Even if you do not put anything inside of it, other languages will not work unless the base file exists.
78+
2. Create one or more ``messages_LOCALE.properties`` files to the root package (as shown above), for example ``messages_es.properties`` for Spanish (or even ``messages_es_ES.properties`` for Spain's dialect of Spanish and ``messages_es_MX.properties`` for Mexican dialect of Spanish, etc).
79+
3. In each locale-specific file, re-define each Stormpath :ref:`i18n property <i18n-properties-file>` value in that language.
80+
81+
.. caution::
82+
83+
Even if there are no English properties you wish to override, you must have a ``messages.properties`` file (can be empty) if you intend to provide properties in other languages
5284

5385
#end
5486

0 commit comments

Comments
 (0)