Using the correct “.resx” file according to the culture info

后端 未结 1 1796
一整个雨季
一整个雨季 2020-12-11 04:43

I want to use localization in my project so I\'m using \".resx\" files.

I have two files \"StringRes.resx\" and \"StringRes.fr.resx\". As you can guess, I want that

相关标签:
1条回答
  • 2020-12-11 04:59

    I have created my own test projected an I used "fr-FR" as a culture tag. The test project can be found on my skydrive.

    Works perfect.

    Culture test

    In short:

    I set the culture in the Properties of the project to be en-US as that is what I would want my Resource.resx to be.

    Then I created Resource.resx, Resource.fr-FR.resx and Resource.nl-NL.resx.

    I filled them with the TestData string. And the created a window with 3 buttons with events hooked to them. Next to the buttons I created a textblock, the textblock is binded to a Text string field.

    In the button events I change the culture and the Text field. And you can then see the change happen.


    You first need to create your Resource.resx then in the same folder you need to create Resource.fr-FR.resx. The Resource.resx will get a codebehind file, all the cultured resource files should not. If your Resource.fr-FR.resx does have a culture file you did something wrong and it is best to delete that resources file and recreate it so it loses it's codebehind.

    0 讨论(0)
提交回复
热议问题