开发者

External Translations in .NET

Good morning,

I am interested in developing an application which supports external GUI translation files to be added as desired by the users. I thought about using the localization methods built into .NET, but I think this way I cannot distribute isolated files with tran开发者_JS百科slations (can I?) after the application is built.

What is the better way to achieve localization using external files in C#?

Thank you very much.


I've seen a lot of people implementing their own localization system for .net, but personally, I would stay with the built in structure.

Now, you can just add additional .resx files and recompile the app afterwards. But I guess this is not what you want?

Or you can implement your own Resource Provider and for example get all localization strings from a DB.

Example:
http://msdn.microsoft.com/en-us/library/aa905797.aspx#exaspnet20rpm_topic4


You can use .NET localizations without any issues.

After you sucessfully localized yopur appliation files, in your application folder will contain subfolders for you localized versions of assembly resources. So after adding new language into localizations, you can distrubute these new DLLs to your castomers from folder for your newly added localizations.

Cheers ;)


If you don't want to recompile the files later you can use something like the folowing.

  1. Create multiple xml files with the same keys and different values for different locations. Or make one big file. Save that file's path somewhere in app settings (or embed during build)
  2. Build your application with default language on forms (for e, english)
  3. On startup (or first startup) ask user to specify the language to use.
  4. On each form/window in constructor (after InitializeComponent() called) replace the texts on the form with values in XML.

Example xml:

<doc>
  <loc name="English">
    <form name = "main">
      <okButton>OK</okButton>
      ....
    </form>
    <form name = "about">
      <lblAuthorName>Author's name: </lblAuthorName>
      ....
    </form>
  </loc>
  <loc name="Ukrainian">
    <form name = "main">
      <okButton>Добре</okButton>
      ....
    </form>
  </loc>

</doc>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜