I am trying to create a multi-language application. I am using separate resource files for each language like:
app.nl-NL.resx
app.en-GB.resx
etc.
But when I compile, it will create sub-directories for each resource file with the compiled resource file.
example:
app\bin\Debug\nl-NL\app.resources.dll
app\开发者_如何学编程bin\Debug\en-GB\app.resources.dll
etc.
How do I put it all in a separate directories like _app\bin\Debug\Lang\nl-NL_ ?
You can put them all to separate folder. Here is similar question with solution. I although had this problem, and this is how I solved it: First of all you need to add your "Lang" folder to list of folders where the program will search for localized resources. For that you should add such lines to .config file of your project:
<configuration>
...
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="Lang"/>
</assemblyBinding>
</runtime>
</configuration>
info about probing element on msdn
Than, after rebuild you can move your generated "xx-YY\app.resources.dll" folders to Lang folder by hands, or you can add small script to Post-build event command line, to move them automatically. I used such commands:
robocopy $(TargetDir) $(TargetDir)\Lang "$(TargetName).resources.dll" /CREATE /S /XD Lang /IS /IT
robocopy $(TargetDir) $(TargetDir)\Lang "$(TargetName).resources.dll" /MOVE /S /XD Lang /XL /IS /IT
But be aware that robocopy's return code 1 is normal behavior, and visual studio will assume that it is an error. So if you have any other commands used on post-build, just put robocopy before them. Or check %errorlevel% like it is suggested here.
Maybe, there is a better solution, but it works well for me.
If you want localization to work, you should leave the satellite assemblies as they are.
This is how they work, finding the resource according to the directory name.
See the "Directory Locations for Satellite Assemblies Not Installed in the Global Assembly Cache" section on this MSDN page (Creating Satellite Assemblies).
精彩评论