doesn't find messages_XX.properties
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I have an application rest in springboot and I need multi-languages. The application finds messages.properties but not messages_es.properties.
My code:
In application.properties
spring.messages.basename=i18n/messages
In controller
messageSource.getMessage("message.forgotSubject", null, new Locale(lang))
if lang is es it’s the same.
If I remove messages.properties, error is No message found under code
'message.forgotSubject' for locale 'es'.",
Thanks
java spring-boot multilingual
add a comment |
I have an application rest in springboot and I need multi-languages. The application finds messages.properties but not messages_es.properties.
My code:
In application.properties
spring.messages.basename=i18n/messages
In controller
messageSource.getMessage("message.forgotSubject", null, new Locale(lang))
if lang is es it’s the same.
If I remove messages.properties, error is No message found under code
'message.forgotSubject' for locale 'es'.",
Thanks
java spring-boot multilingual
add a comment |
I have an application rest in springboot and I need multi-languages. The application finds messages.properties but not messages_es.properties.
My code:
In application.properties
spring.messages.basename=i18n/messages
In controller
messageSource.getMessage("message.forgotSubject", null, new Locale(lang))
if lang is es it’s the same.
If I remove messages.properties, error is No message found under code
'message.forgotSubject' for locale 'es'.",
Thanks
java spring-boot multilingual
I have an application rest in springboot and I need multi-languages. The application finds messages.properties but not messages_es.properties.
My code:
In application.properties
spring.messages.basename=i18n/messages
In controller
messageSource.getMessage("message.forgotSubject", null, new Locale(lang))
if lang is es it’s the same.
If I remove messages.properties, error is No message found under code
'message.forgotSubject' for locale 'es'.",
Thanks
java spring-boot multilingual
java spring-boot multilingual
edited Jan 9 at 9:53
Liam
16.5k1678131
16.5k1678131
asked Jan 4 at 16:06
Javier ElorduyJavier Elorduy
395
395
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
You set spring.messages.basename=i18n/messages, so your multi-language properties file must base messages.properties, if you remove this file, the basename should be i18n/messages_es. But if you do this, the file suffix es is not a language but apart of the file name.
Thanks, but I cannot put i18n/messages_es because I am going to have others languages as messages_fr or messages_en. I must find a method that allows to work with any language and also messages.properties if the language doesn't exist.
– Javier Elorduy
Jan 5 at 18:24
When your JVM locale equals to the locale you set, the message.properties will take precedence. Don't remove messages.properties and set the content same as message_es.properties.
– Juey
Jan 6 at 3:22
But messages_es.properties is never read even if I put local 'es'. messages.properties will be the default language.
– Javier Elorduy
Jan 7 at 7:29
When you deploy your app at a JVM which locale is not "es" then the messages_es.properties is worked.
– Juey
Jan 7 at 12:14
add a comment |
I have found the solution.
It’s not in application.properties. I have done
@Configuration
public class CustomLocaleResolver {
@Bean
public ResourceBundleMessageSource messageSource() {
ResourceBundleMessageSource rs = new ResourceBundleMessageSource();
rs.setBasename("i18n/messages");
rs.setDefaultEncoding("UTF-8");
rs.setUseCodeAsDefaultMessage(true);
return rs;
}
}
And I use
@Autowired
private MessageSource messageSource;
messageSource.getMessage("message.salutation", null, new Locale(lang)
Thanks
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54042416%2fdoesnt-find-messages-xx-properties%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You set spring.messages.basename=i18n/messages, so your multi-language properties file must base messages.properties, if you remove this file, the basename should be i18n/messages_es. But if you do this, the file suffix es is not a language but apart of the file name.
Thanks, but I cannot put i18n/messages_es because I am going to have others languages as messages_fr or messages_en. I must find a method that allows to work with any language and also messages.properties if the language doesn't exist.
– Javier Elorduy
Jan 5 at 18:24
When your JVM locale equals to the locale you set, the message.properties will take precedence. Don't remove messages.properties and set the content same as message_es.properties.
– Juey
Jan 6 at 3:22
But messages_es.properties is never read even if I put local 'es'. messages.properties will be the default language.
– Javier Elorduy
Jan 7 at 7:29
When you deploy your app at a JVM which locale is not "es" then the messages_es.properties is worked.
– Juey
Jan 7 at 12:14
add a comment |
You set spring.messages.basename=i18n/messages, so your multi-language properties file must base messages.properties, if you remove this file, the basename should be i18n/messages_es. But if you do this, the file suffix es is not a language but apart of the file name.
Thanks, but I cannot put i18n/messages_es because I am going to have others languages as messages_fr or messages_en. I must find a method that allows to work with any language and also messages.properties if the language doesn't exist.
– Javier Elorduy
Jan 5 at 18:24
When your JVM locale equals to the locale you set, the message.properties will take precedence. Don't remove messages.properties and set the content same as message_es.properties.
– Juey
Jan 6 at 3:22
But messages_es.properties is never read even if I put local 'es'. messages.properties will be the default language.
– Javier Elorduy
Jan 7 at 7:29
When you deploy your app at a JVM which locale is not "es" then the messages_es.properties is worked.
– Juey
Jan 7 at 12:14
add a comment |
You set spring.messages.basename=i18n/messages, so your multi-language properties file must base messages.properties, if you remove this file, the basename should be i18n/messages_es. But if you do this, the file suffix es is not a language but apart of the file name.
You set spring.messages.basename=i18n/messages, so your multi-language properties file must base messages.properties, if you remove this file, the basename should be i18n/messages_es. But if you do this, the file suffix es is not a language but apart of the file name.
answered Jan 4 at 16:46
JueyJuey
385
385
Thanks, but I cannot put i18n/messages_es because I am going to have others languages as messages_fr or messages_en. I must find a method that allows to work with any language and also messages.properties if the language doesn't exist.
– Javier Elorduy
Jan 5 at 18:24
When your JVM locale equals to the locale you set, the message.properties will take precedence. Don't remove messages.properties and set the content same as message_es.properties.
– Juey
Jan 6 at 3:22
But messages_es.properties is never read even if I put local 'es'. messages.properties will be the default language.
– Javier Elorduy
Jan 7 at 7:29
When you deploy your app at a JVM which locale is not "es" then the messages_es.properties is worked.
– Juey
Jan 7 at 12:14
add a comment |
Thanks, but I cannot put i18n/messages_es because I am going to have others languages as messages_fr or messages_en. I must find a method that allows to work with any language and also messages.properties if the language doesn't exist.
– Javier Elorduy
Jan 5 at 18:24
When your JVM locale equals to the locale you set, the message.properties will take precedence. Don't remove messages.properties and set the content same as message_es.properties.
– Juey
Jan 6 at 3:22
But messages_es.properties is never read even if I put local 'es'. messages.properties will be the default language.
– Javier Elorduy
Jan 7 at 7:29
When you deploy your app at a JVM which locale is not "es" then the messages_es.properties is worked.
– Juey
Jan 7 at 12:14
Thanks, but I cannot put i18n/messages_es because I am going to have others languages as messages_fr or messages_en. I must find a method that allows to work with any language and also messages.properties if the language doesn't exist.
– Javier Elorduy
Jan 5 at 18:24
Thanks, but I cannot put i18n/messages_es because I am going to have others languages as messages_fr or messages_en. I must find a method that allows to work with any language and also messages.properties if the language doesn't exist.
– Javier Elorduy
Jan 5 at 18:24
When your JVM locale equals to the locale you set, the message.properties will take precedence. Don't remove messages.properties and set the content same as message_es.properties.
– Juey
Jan 6 at 3:22
When your JVM locale equals to the locale you set, the message.properties will take precedence. Don't remove messages.properties and set the content same as message_es.properties.
– Juey
Jan 6 at 3:22
But messages_es.properties is never read even if I put local 'es'. messages.properties will be the default language.
– Javier Elorduy
Jan 7 at 7:29
But messages_es.properties is never read even if I put local 'es'. messages.properties will be the default language.
– Javier Elorduy
Jan 7 at 7:29
When you deploy your app at a JVM which locale is not "es" then the messages_es.properties is worked.
– Juey
Jan 7 at 12:14
When you deploy your app at a JVM which locale is not "es" then the messages_es.properties is worked.
– Juey
Jan 7 at 12:14
add a comment |
I have found the solution.
It’s not in application.properties. I have done
@Configuration
public class CustomLocaleResolver {
@Bean
public ResourceBundleMessageSource messageSource() {
ResourceBundleMessageSource rs = new ResourceBundleMessageSource();
rs.setBasename("i18n/messages");
rs.setDefaultEncoding("UTF-8");
rs.setUseCodeAsDefaultMessage(true);
return rs;
}
}
And I use
@Autowired
private MessageSource messageSource;
messageSource.getMessage("message.salutation", null, new Locale(lang)
Thanks
add a comment |
I have found the solution.
It’s not in application.properties. I have done
@Configuration
public class CustomLocaleResolver {
@Bean
public ResourceBundleMessageSource messageSource() {
ResourceBundleMessageSource rs = new ResourceBundleMessageSource();
rs.setBasename("i18n/messages");
rs.setDefaultEncoding("UTF-8");
rs.setUseCodeAsDefaultMessage(true);
return rs;
}
}
And I use
@Autowired
private MessageSource messageSource;
messageSource.getMessage("message.salutation", null, new Locale(lang)
Thanks
add a comment |
I have found the solution.
It’s not in application.properties. I have done
@Configuration
public class CustomLocaleResolver {
@Bean
public ResourceBundleMessageSource messageSource() {
ResourceBundleMessageSource rs = new ResourceBundleMessageSource();
rs.setBasename("i18n/messages");
rs.setDefaultEncoding("UTF-8");
rs.setUseCodeAsDefaultMessage(true);
return rs;
}
}
And I use
@Autowired
private MessageSource messageSource;
messageSource.getMessage("message.salutation", null, new Locale(lang)
Thanks
I have found the solution.
It’s not in application.properties. I have done
@Configuration
public class CustomLocaleResolver {
@Bean
public ResourceBundleMessageSource messageSource() {
ResourceBundleMessageSource rs = new ResourceBundleMessageSource();
rs.setBasename("i18n/messages");
rs.setDefaultEncoding("UTF-8");
rs.setUseCodeAsDefaultMessage(true);
return rs;
}
}
And I use
@Autowired
private MessageSource messageSource;
messageSource.getMessage("message.salutation", null, new Locale(lang)
Thanks
answered Jan 9 at 14:20
Javier ElorduyJavier Elorduy
395
395
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54042416%2fdoesnt-find-messages-xx-properties%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown