0

We have a big live site that uses Asp.Net WebForms and a lot of client side JS, with a lot of hard coding and dynamically created content on the client side.

We need to convert it to be multilingual using resource files on the server side. What is the best way - AJAX calls, or maybe create a JS file that will be populated with all necessary multilingual content for every page? Or another technique?

1 Answer 1

1

The best way would be for your .NET application to manage all this. The FE shouldn't care about the language the site is. So the best thing to to would be to check where ever you have text populated by the JS and make you .NET application to render it instead. It is quite a bite of work but it is the most efficient and flexible way to do it.

If you really can't take this time, as a solution I would get the JS files have translated sentences as it would be easier in the future to roll everything out in the Back-End solution.

If you start using the Ajax requests you will end up having lots of Ajax calls and dependencies to your APIs and stuff, that will be a lot harder to maintain.

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

6 Comments

Well, after many discussions in our Dev dpt, it seems the decision has been made... Despite your well-described recommendation that one hears so often, we're gonna do it all client-side - load all dictionary values to a JS array or JSON and replace the DOM values from there using innerHTML. What are the pros and cons of this?
The pros: that'll be faster for you to implement. Using a JSON file structure will give you more flexibility in the future. The cons: your site will be heavier so will take a bit more time to load and you will have more JavaScript to run which might cause problems for mobiles devices + you will have to synchronize both technologies every time you will have to make changes while 1 would been enought. Then, using the innerHTML is the best and easiest way to do it.
Hmmm. Well adapting the site to mobile isn't in the workplan anytime soon since the site is a website creation system. Thank you for your helpful input. It seems now we'll have a dilemma how to maintain the values of the translations - one suggestion is to have the semi-professional personnel update the JSON using JSON viewer or something. Another is to keep it in the DB and have a SP to create the client side JSON every time. Another good question is what about caching - how to avoid a situation where on each site load the entire JSON will be parsed and accessed.
You could maybe try to create a job in the DB for each time a value is updated, you re-generate a the cached files so it is easy to use for the FE.
Yep, that's the plan more or less. But the question about the cache is how to avoid parsing of the whole JSON on the client's computer every time the user loads the site.
|

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.