How to use language properties with Spring MVC 4 and jQuery I18N?

Jessai

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:

enter image description here

My project structure is:

enter image description here

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');
...
  1. In the red square is the file required to use jquery.i18n.
  2. In the blue square I have the I18N properties files.
  3. In the pink square are the files that contains the web page

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!!!

Jessai

Just If someone is facing the same issue, after one week this is the answer:

  1. Moved the properties files to the src/main/resources folder

  2. 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" />

  1. 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!

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to load i18n Property file using jQuery.i18n.properties.js + Spring 3 mvc

From Dev

Spring Boot Application on Kubernetes How to use external message.properties file for supporting i18n and l10n?

From Dev

How to use Spring's i18n mechanism?

From Java

Rails: How to use i18n with Rails 4 enums

From Dev

How to externalize i18n properties files in spring-boot applications

From Dev

Spring MVC 3 i18n, how to store locale in session instead of URL parameter?

From Dev

Spring MVC equivalent of getText() from Struts for I18N

From Dev

Spring MVC i18n validation error messages

From Dev

Spring MVC equivalent of getText() from Struts for I18N

From Dev

How to internationalize Javascript Content with Spring I18N?

From Dev

How to use _ in mako rendering template with i18n?

From Dev

AngularJS: How to use translation (i18n) in controller for popup?

From Dev

How to use i18n with a Grails radioGroup?

From Dev

How to use I18n from controller in Rails

From Dev

How to use Vue i18n translation in .js file?

From Dev

How to use i18n with a Grails radioGroup?

From Dev

how to use @StringDef in an app with i18n

From Dev

How to use i18n in a custom attribute on Aurelia?

From Dev

How to use view model together with i18n model?

From Dev

Accessing properties with annotation approach in spring mvc 4

From Dev

How can translate umlauts with jquery.i18n-properties?

From Dev

How to use javax.validation and JSON request in Spring 4 MVC?

From Dev

How to use javax.validation and JSON request in Spring 4 MVC?

From Dev

CakePHP 3.1: Language letter codes to use with translate behaviour (i18n)

From Dev

CakePHP 3.1: Language letter codes to use with translate behaviour (i18n)

From Dev

Spring 4 i18n & l10n (Cannot change HTTP accept header)

From Dev

Spring 4 i18n & l10n (Cannot change HTTP accept header)

From Dev

Cakephp i18n how to get content in default language if translation is not available

From Dev

How to define different fonts for different language using AngularJS i18n?

Related Related

  1. 1

    How to load i18n Property file using jQuery.i18n.properties.js + Spring 3 mvc

  2. 2

    Spring Boot Application on Kubernetes How to use external message.properties file for supporting i18n and l10n?

  3. 3

    How to use Spring's i18n mechanism?

  4. 4

    Rails: How to use i18n with Rails 4 enums

  5. 5

    How to externalize i18n properties files in spring-boot applications

  6. 6

    Spring MVC 3 i18n, how to store locale in session instead of URL parameter?

  7. 7

    Spring MVC equivalent of getText() from Struts for I18N

  8. 8

    Spring MVC i18n validation error messages

  9. 9

    Spring MVC equivalent of getText() from Struts for I18N

  10. 10

    How to internationalize Javascript Content with Spring I18N?

  11. 11

    How to use _ in mako rendering template with i18n?

  12. 12

    AngularJS: How to use translation (i18n) in controller for popup?

  13. 13

    How to use i18n with a Grails radioGroup?

  14. 14

    How to use I18n from controller in Rails

  15. 15

    How to use Vue i18n translation in .js file?

  16. 16

    How to use i18n with a Grails radioGroup?

  17. 17

    how to use @StringDef in an app with i18n

  18. 18

    How to use i18n in a custom attribute on Aurelia?

  19. 19

    How to use view model together with i18n model?

  20. 20

    Accessing properties with annotation approach in spring mvc 4

  21. 21

    How can translate umlauts with jquery.i18n-properties?

  22. 22

    How to use javax.validation and JSON request in Spring 4 MVC?

  23. 23

    How to use javax.validation and JSON request in Spring 4 MVC?

  24. 24

    CakePHP 3.1: Language letter codes to use with translate behaviour (i18n)

  25. 25

    CakePHP 3.1: Language letter codes to use with translate behaviour (i18n)

  26. 26

    Spring 4 i18n & l10n (Cannot change HTTP accept header)

  27. 27

    Spring 4 i18n & l10n (Cannot change HTTP accept header)

  28. 28

    Cakephp i18n how to get content in default language if translation is not available

  29. 29

    How to define different fonts for different language using AngularJS i18n?

HotTag

Archive