简体   繁体   中英

Localization. Use React or Spring Boot?

I am new to Web Development and I am currently writing my first web app. I am trying to implement localization and I am not sure what option I should use. I am using both spring boot and react. With spring I could use LocaleResolver and thymeleaf. And with React I could use the i18next package. So I am asking myself with would make more sense to use and why.

Thanks in advance.

Short answer: React.

Long answer:

If you are using React, probably you are not using thymeleaf . In other words, you will probably create a big Javascript package which displays the UI, and the Spring backend will do nothing but providing some raw data .

For example, say you are building a blog. Your Spring may do something like -

  • if someone asks me at url mydomain.com/posts/42 , I will return him {"title": "Hello", "author": "Tom"}

And your React will do something like -

  • when I am initializing, I should ask the server about the content of this blog post with id=42. Thus I should make a http query fetch('mydomain.com/posts/42')
  • then I see data from my server. I got {"title": "Hello", "author": "Tom"} .
  • now I should render it to the screen so the users can see it. For example, it will be rendered as <h1>TITLE: Hello</h1> <p>AUTHOR: Tom</p> .

Now you see that, your UI goes within the frontend. Thus it is reasonable to do localization with your UI.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM