Reputation: 947
I'm developing a web app with Spring MVC 4 and jQuery I18N. I have already checked the following links without success:
How to dynamically change language using jquery-i18n-properties and JavaScript?
How to load i18n Property file using jQuery.i18n.properties.js + Spring 3 mvc
But when I access to the page, I'm getting 404 Not found error in the developer's chrome console:
My project structure is:
In cheque.js (Brown square in structure) I have the following code:
function loadBundles(lang) {
jQuery.i18n.properties({
name:'messages',
path:'i18n/',
mode:'both',
language:lang,
callback: function(){
console.log(jQuery.i18n.prop('check_receiver'))
}
});
}
...
loadBundles('es');
...
In the webmvc-config.xml I have the following code:
<mvc:resources location="/, classpath:/META-INF/web-resources/"
mapping="/resources/**" />
<bean class="org.springframework.context.support.ReloadableResourceBundleMessageSource" p:defaultEncoding="ISO-8859-1"
id="messageSource" p:basenames="WEB-INF/i18n/messages"
p:fallbackToSystemLocale="false" />
<!-- Store preferred language configuration in a cookie -->
<bean class="org.springframework.web.servlet.i18n.CookieLocaleResolver"
id="localeResolver">
<property name="defaultLocale" value="es" />
</bean>
Does the path in the javascript function is incorrect?
Is there any other file required by jQuery I18N?
Thanks in advance!!!
Upvotes: 2
Views: 2589
Reputation: 947
Just If someone is facing the same issue, after one week this is the answer:
Moved the properties files to the src/main/resources folder
Changed the webmvc-config.xml ReloadableResourceBundleMessageSource code like this:
< bean class="org.springframework.context.support.ReloadableResourceBundleMessageSource" p:defaultEncoding="ISO-8859-1" id="messageSource" p:basenames="messages" p:fallbackToSystemLocale="false" />
And finally the javascript function is like this:
jQuery.i18n.properties({
name:'messages',
path:'../resources/',
mode:'both',
language:lang,
callback: function(){
console.log(jQuery.i18n.prop('check_receiver'))
}
});
That was all folks!
Upvotes: 1