0

I have an old MVC 4 project that uses ASP.NET Resources in Razor views for localization.

I.e in a Razor view you may see

Views/Register.cshtml:

@Resource(() => Local.TermsAndConditions

This will go off and fine

Resources/Register.resx

And find the 'TermsAndConditions' parameter with the correct culture.

Now I don't actually know how all of this works, I've never worked on a multi-lingual application before, but I know that these resx files don't even have the correct information - what actually happens is somehow we fetch these from what looks like a complicated set of SQL tables in the database, using a built ResourceCache class.

I am trying to re-write the front-end using React, but am struggling with how to keep the localization - there are hundreds of entries and I am pulling my hair out a little here.

The only solution I can think of, is to manually find all the keys that would be required to lookup at the top of the view, and send these off to a custom API that will process these values for me, but feel like that may cause a large overhead on my application!

Any ideas?

1 Answer 1

2

So I solved this by creating a simple API method

List<string, string> LocaliseStrings (List<string> keys)
{
   // get UI culture
   // look up translated string
   // add to return list in KVP
}

This would be called on every front-end page before anything else, and return the strings necessary

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

Comments

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.