2015-03-21 2 views
0

Я пытаюсь создать приложение Spring MVC 4 с помощью AngularJs. Моя проблема в том, что AngularJs не поддерживает интернационализацию. Я хочу использовать jquery.i18n-свойства, но я не могу загрузить messages_% s.properties.Spring MVC - свойства jquery-i18n не могут загрузить свойства сообщений

Я получаю сообщение об ошибке: GET http://localhost:8081/base/resources/i18n/messages.properties?_=1426936125703 404 (Not Found) jquery.js: 7845 ПОЛУЧИТЬ http://localhost:8081/base/resources/i18n/messages_en.properties?_=1426936125704 404 (Not Found)

приложений контекстно-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> 

А вот что на самом деле Лоа ds файлы:

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'); 

});

Я не использую JSP-s, я просто работаю с HTML-файлами. Вот моя файловая структура:

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

Я пробовал много вещей, чтобы решить эту проблему, но ничего не получилось. Может ли кто-нибудь помочь мне, пожалуйста?

Спасибо!

ответ

0

Пример из их homepage:

Возьмем в качестве примера следующий messages.properties, Messages_pt.properties и Messages_pt_PT.properties:

Messages.properties

# This line is ignored by the plugin 
msg_hello = Hello 
msg_world = World 
msg_complex = Good morning {0}! 

Messages_pt. свойства

# We only provide a translation for the 'msg_hello' key 
msg_hello = Bom dia 

Messages_pt_PT.properties

# We only provide a translation for the 'msg_hello' key 
msg_hello = Olá 

Итак, как вы можете видеть, этот плагин загружает три файла: файл по умолчанию (например, Messages.properties), а затем локали определенные файлы (Сообщения _pt .properties, затем Сообщения _pt_PT .properties).

Смежные вопросы