8

I'm working on a C# .NET application and I'm performing localization with resource files. I have culture specific resource files like:

  • MyResource.resx;
  • MyResource.fr-FR.resx;
  • MyResource.ja-JP.resx;

After building, in the application root folder there are folders like fr-FR, ja-JP and so on.

Is it possible to move all localization resource files and folders into the same folder, for example Languages?

Update 1:

I solved this with the code below. it seems that when i copy the application to another place, it can't load resources. As i can see, application.config file need to be there also. And if i make app.config as embeded resource, it doesnt working.

Is there a way, how to make this without the .config file needed in same directory?

Thanks

2
  • Is it a libray project, e.g. dll?
    – Remy
    Dec 15, 2011 at 22:25
  • No, it's desktop application. Dec 15, 2011 at 22:26

2 Answers 2

11

By default the satellite assemblies are placed in the sub-directories directly below the executable file. If you want to move all the fr-FR, ja-JP and remaining folders for other cultures into the same folder Languages you can do it by adding the following entry into the application configuration file:

<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <probing privatePath="Languages"/>
    </assemblyBinding>
  </runtime>
</configuration>

This will indicate that when searching for assemblies the CLR should search in the default locations and also in the directory or directories specified by the privatePath attribute of the probing element. You can specify any directories that exists below the application executable file. When specifying more than one sub-directory you need to delimit each one with a semicolon.

1
  • Does not work for me: there are 22 language folders (+ the lib folder) inside the build/release/ directory. Even with an empty build/release/ dir, right before you hit F6 to build the solution. Absolutely unnecessary. (just need 1 lang)
    – Flo Bayer
    Aug 19, 2022 at 12:21
1

My ResX files under Properties are below:

  • Resources.resx
  • Resources.tr-TR.resx

I put the runtime information into application configuration file as described above but no change. still creating a tr-TR folder under the executable path, not under Languages folder. What possibly I'm doing wrong here? Thanks

<configuration>
...
<runtime>
...
</runtime>
</configuration>
1
  • You need to move the folder yourself (I did it with a post-build step). The edit to your configuration settings only controls how extra assemblies are searched, not where they are written to.
    – Seanba
    Jun 23, 2016 at 19:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.