I have multiple configuration files describing Addins to my system. I'm looking for a way to globalize some of the tags in the configuration file (i.e - support multiple languages)
for example: in the file activity.xml i want to globalize some of the attributes:
<?xml version="1.0" encoding="UTF-8"?>
<Resource
type="Activity"
id="123456.ConcatenateStrings"
version="1.0.0"
group="String Manipulation"
shortName="$$Concatenate_Strings"
description="$$Concatenates_Strings_Description"
assembly="VTDBasicActivities.dll"
className="ConcatenateStringsActivity"
visible="true">
</Resource>
I want the values of some of the attributes (shotName, description) to be taken from a different configuration file (resx probably) where the values could be written in any language.
I need a way to mark the values of some attributes, so that the xml parser would know to take their value from a configuration file (in my example I wrote "$$" before those values)
what is the best way for doing this? I'm parsing t开发者_StackOverflow社区he xml file with C#
Thanks!
From my conversations with my IT/Support friend. Typically configuration files are kept in English. Its not the most friendly solution, however the configuration mapping is specified information that is hard coded into the program its self. (The keys are, not the values)
Also you have to remember: The people who are working with the configuration file are typically informed users, so your user base that is modifying the files are smaller.
Use Resource files instead
Instead of providing the actual string in configuration, rather provide Resource key and keep strings in resource files with different translations. That's what Resource files are for and you should use them as well. Don't reinvent the wheel.
How Resources work (in a nutshell)?
Have Resources.resx
with default translation that all non localised languages will default to. Then create separate resource files for each language you'd like to support:
Resources.sl.resx
Resources.en-ie.resx
Resources.de.resx
etc...
So when a spanish person would access your application they will get default language, Slovenians will get their own translation, so will Irish and German users... All of these files will have the same resource keys but provide different translations. All you need to do is to use these keys inside of your configuration file. Single one - language neutral.
You need to use resource files. See here: http://ondotnet.com/pub/a/dotnet/2002/09/30/manager.html
精彩评论