It is necessary in the client side to create a similarity to the .resx file in c #, to determine the application resources.

At the moment, I store all the lines in MyRes.resx and pass them to the client as follows:

<script> var str = '@MyRes.SomeStr'; </script> 

Because of this approach, I have two problems:

  1. It means that the lines that I define in the resources on the backend are used only on the client side;
  2. Because of the large number of lines with resources, I get a fairly large tape from assignments like "var str = '@ MyRes.SomeStr'.

How can I organize the storage of resources on the client side? Or how can you normally transfer resources to the frontend?

  • By resources, do we mean only some localization constants or something else? - Duck Learns to Take Cover
  • yes, only constants. - Yankov Viacheslav

1 answer 1

If you need only simple localization constants only on the client, the most clumsy way to do is, for example, the Localizations folder, with files like localization.en.js, localization.ru.js, containing an object with the necessary lines.

 var Localizer = { someParam: "Локализованная строка", dosmth : "Чета сделать" }; 

Well, respectively, the server gives only the desired localization file (headers look there, or some internal project settings, or the client only asks for it based on its settings), and in the script you write Localizer.someParam when you need to access some property.

For most cases, this is sufficient, and the basic principle is as follows. On top you can navigate a full-fledged localization manager if desired.