How can I serve the corresponding .resx file for the http client locale in ASP.NET?
eg.
GET /App_LocalResources/MeshModdler.resx
Background
I have a client-side binary that the web server should ask for the corresponding language resources (i.e. it does not have all the possible translations, it requests the one that it needs).
Currently, the client-side binary prefers to receive an xml file containing all localized resources (strings, etc.). This XML file has a format that looks curious, like the Microsoft resx format (you might think that the format was copied - and they are not mistaken).
Ideally, we can use the capabilities of the ASP.NET web server to search for the corresponding resx file based on the Accept-Language http client, for example.
GET /App_LocalResources/MeshModdler.resx Accept-Language: az-Cyrl-AZ
Ideally, the web server will try to return in order of preference:
MeshModdler.az-Cyrl-AZ.resxMeshModdler.az-AZ.resxMeshModdler.az.resxMeshModdler.resx
But instead, the server returns:
HTTP/1.1 404 Not Found
Bonus Chat
I know this is not possible. So in addition to the answer cannot be done I also agree with the answer, which just does what I want:
- leverages the power of the ASP.NET web server to perform resource resolution and backup.
- allows you to delete new
resx localization resx in a folder and receive them you donβt need to resort to creating a dummy page that builds what looks like a resx file, but must process each entry with:
<root> <data name="TesselateMesh.Caption"> <value><%$ Resources:MeshModdler, TesselateMesh.Caption1 %></value> </data> ... </root>
Additional chatter
Now hacking will rename resx files to xml :
MeshModdler.az-Cyrl-AZ.xmlMeshModdler.az-AZ.xmlMeshModdler.az.xmlMeshModdler.xml
And recreate the backup code:
GET /MeshModdler.az-Cyrl-AZ.xml 404 Not found GET /MeshModdler.az-AZ.xml 404 Not found GET /MeshModdler.az.xml 200 Ok
But it would be nice to work with ASP.NET, and not against it.