2

I have a asp.net core web application. My application has some reactjs components, that runs client side.

In my asp.net core views, i use IViewLocalizer to localize my pages and it works just fine.

I have found some projects like react-localization to handle this on reactjs. To use it, I need to do one of the following:

  1. In my view create an object with my resources and give it to react-localization
  2. Create an endpoint that return my resources, call it inside reactjs component and give it to react-localization

My question is, what is the best approach to bring localization to reactjs components?

1 Answer 1

2

When i posted this question, i had a simple react application with less than ten resources. I chose the number one option, in my view create an object with my resources and give it to react because it is a more simple solution.

On another big react project, i chose the number two option: create an endpoint that return my resources and call it inside reactjs. It is a bit more complex, but all logic is inside reactjs and the html does not have a giant script object with all resources.

Sign up to request clarification or add additional context in comments.

2 Comments

Am I right in assuming the second approach is faster in total? So you grouped your resources per (react) component, or how did you select the resources a component needs?
Can't tell you if option one is faster than option two, because one had less than ten resources and other had less than two hundred. It is an unfair comparison. Answering you second question, all my react components used the same resources. The endpoint returned all resources for a single language. Also, that second project wasn't an spa. React was used only on a specific part of it. Changing language was outside of the react, was in mvc.net (and, by design, that reloaded the page). In a typical spa application, this isn't the best approach.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.