samedi 21 mars 2015

Spring MVC - jquery-i18n-properties can not load messages properties

I am trying to make a Spring MVC 4 application with AngularJs. My problem is that AngularJs does not support internationalization. I want to use jquery.i18n-properties, but I can not load messages_%s.properties.


I get this error message: GET http://localhost:8081/base/resources/i18n/messages.properties?_=1426936125703 404 (Not Found) jquery.js:7845 GET http://localhost:8081/base/resources/i18n/messages_en.properties?_=1426936125704 404 (Not Found)


application-context-config.xml:



<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/WEB-INF/resources/ directory -->
<mvc:resources mapping="/resources/**" location="/WEB-INF/resources/" />

<mvc:view-controller path="/" view-name="/resources/html/templates/index.html"/>

<!-- Saves a locale change using a cookie -->
<bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver" />

<bean class="org.springframework.context.support.ReloadableResourceBundleMessageSource"
id="messageSource" p:defaultEncoding="UTF-8"
p:basenames="resources/i18n/messages"
p:fallbackToSystemLocale="false" />


web.xml



<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spring/security-context-config.xml
/WEB-INF/spring/persistence-context-config.xml
/WEB-INF/spring/application-context-config.xml
</param-value>
</context-param>
<!-- Processes application requests -->
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value></param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>


And here is what actually loads the files:



app.service('i18n', function () {
var self = this;
this.setLanguage = function (language) {
$.i18n.properties({
name: 'messages',
path: 'resources/i18n/',
mode: 'map',
language: language,
callback: function () {
self.language = language;
}
});
};
this.setLanguage('en');


});


I dont use JSP-s, I just work with HTML-s. Here is my file structure:



src
|_main
|_webapp
|_WEB-INF
|_resources
|_...
|_html
|_... here are my .html files
|_i18n
|_messages_en.proerties
|_images
|_...
|_js
|_...


I tried a lot of things to resolve this problem, but nothing worked. Could somebody help me please?


Thank you!


Aucun commentaire:

Enregistrer un commentaire