<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Localization</title><link>http://forums.asp.net/151.aspx</link><description>Discuss techniques for localizing content for different languages and locales with ASP.NET.</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Re: Getting resource name</title><link>http://forums.asp.net/thread/3104922.aspx</link><pubDate>Mon, 20 Apr 2009 15:25:15 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3104922</guid><dc:creator>joniba</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3104922.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=151&amp;PostID=3104922</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;Actually my proposed solution, after some research, to the original question, is:&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;pre class="coloredcode"&gt;&lt;span class="cmt"&gt;/// &amp;amp;lt;summary&amp;amp;gt;&lt;br /&gt;        /// Returns a dictionary of the name/value pairs of the managed resource-file&lt;br /&gt;        /// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwd"&gt;public static&lt;/span&gt; Dictionary&amp;lt;&lt;span class="kwd"&gt;string&lt;/span&gt;, &lt;span class="kwd"&gt;string&lt;/span&gt;&amp;gt; BuildResourceDictionary(ResourceManager manager)&lt;br /&gt;        {&lt;br /&gt;            Dictionary&amp;lt;&lt;span class="kwd"&gt;string&lt;/span&gt;, &lt;span class="kwd"&gt;string&lt;/span&gt;&amp;gt; resourceDict = &lt;span class="kwd"&gt;new&lt;/span&gt; Dictionary&amp;lt;&lt;span class="kwd"&gt;string&lt;/span&gt;, &lt;span class="kwd"&gt;string&lt;/span&gt;&amp;gt;();&lt;br /&gt;&lt;br /&gt;            ResourceSet resourceSet = manager.GetResourceSet(CultureInfo.CurrentUICulture, &lt;span class="kwd"&gt;true&lt;/span&gt;, &lt;span class="kwd"&gt;true&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;            IDictionaryEnumerator enumerator = resourceSet.GetEnumerator();&lt;br /&gt;            &lt;br /&gt;            &lt;span class="kwd"&gt;while&lt;/span&gt; (enumerator.MoveNext())&lt;br /&gt;            {&lt;br /&gt;                resourceDict.Add((&lt;span class="kwd"&gt;string&lt;/span&gt;)enumerator.Key, (&lt;span class="kwd"&gt;string&lt;/span&gt;)enumerator.Value);&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            &lt;span class="kwd"&gt;return&lt;/span&gt; resourceDict;&lt;br /&gt;        }&lt;/pre&gt;&lt;pre class="coloredcode"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="coloredcode"&gt;Though I implemented it as an extension method.&lt;/pre&gt;&lt;pre class="coloredcode"&gt;Of course you could also add a CultureInfo parameter rather than use the CurrentUICulture. &lt;br /&gt;&lt;/pre&gt;&amp;nbsp;&amp;nbsp;</description></item><item><title>Re: Getting resource name</title><link>http://forums.asp.net/thread/3104105.aspx</link><pubDate>Mon, 20 Apr 2009 10:19:05 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3104105</guid><dc:creator>mnemukula</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3104105.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=151&amp;PostID=3104105</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;Hi there,&lt;/p&gt;&lt;p&gt;try using something like this: Resources.YourResourceName.Name this will give you the value of the name you&amp;#39;ve selected.&lt;/p&gt;&lt;p&gt;please mark as correct if this helps you get your question right &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: Getting resource name</title><link>http://forums.asp.net/thread/3104057.aspx</link><pubDate>Mon, 20 Apr 2009 10:02:17 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3104057</guid><dc:creator>joniba</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3104057.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=151&amp;PostID=3104057</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;Good God, isn&amp;#39;t there a way to do this without running to the Xml itself?&amp;nbsp; Like with the ResourceSet or something?&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: Getting resource name</title><link>http://forums.asp.net/thread/1941717.aspx</link><pubDate>Thu, 04 Oct 2007 21:16:35 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1941717</guid><dc:creator>jamlew</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1941717.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=151&amp;PostID=1941717</wfw:commentRss><description>&lt;p&gt;Resource files are just XML, where the important part is a series of&amp;nbsp;&amp;nbsp;&lt;pre class="coloredcode"&gt;&amp;lt;&lt;span class="tag"&gt;data&lt;/span&gt;&lt;span class="attr"&gt; name=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;quot;resource name&amp;quot;&lt;/span&gt;&amp;gt;&amp;lt;&lt;span class="tag"&gt;value&lt;/span&gt;&amp;gt;localized string&amp;lt;/&lt;span class="tag"&gt;value&lt;/span&gt;&amp;gt;&amp;lt;/&lt;span class="tag"&gt;data&lt;/span&gt;&amp;gt;&lt;/pre&gt;&amp;nbsp;&amp;nbsp; (though there is a little bit of other stuff). 
&lt;p&gt;Here&amp;#39;s a sample of parsing it with C# 2.0 (hopefully I did this right, I haven&amp;#39;t worked with XML much):&lt;pre class="coloredcode"&gt;        Dictionary&amp;lt;&lt;span class="kwd"&gt;string&lt;/span&gt;, &lt;span class="kwd"&gt;string&lt;/span&gt;&amp;gt; resourceDict = &lt;span class="kwd"&gt;new&lt;/span&gt; Dictionary&amp;lt;&lt;span class="kwd"&gt;string&lt;/span&gt;,&lt;span class="kwd"&gt;string&lt;/span&gt;&amp;gt;();
        XmlDocument doc = &lt;span class="kwd"&gt;new&lt;/span&gt; XmlDocument();
        doc.Load(Server.MapPath(&lt;span class="st"&gt;&amp;quot;~/App_GlobalResources/Resources.resx&amp;quot;&lt;/span&gt;));
        XmlNodeList resourceList = doc.GetElementsByTagName(&lt;span class="st"&gt;&amp;quot;data&amp;quot;&lt;/span&gt;);
        &lt;span class="kwd"&gt;foreach&lt;/span&gt; (XmlNode node &lt;span class="kwd"&gt;in&lt;/span&gt; resourceList)
        {
            &lt;span class="kwd"&gt;string&lt;/span&gt; name = node.Attributes[&lt;span class="st"&gt;&amp;quot;name&amp;quot;&lt;/span&gt;].Value;
            &lt;span class="kwd"&gt;string value&lt;/span&gt;  = &lt;span class="st"&gt;&amp;quot;&amp;quot;&lt;/span&gt;; &lt;span class="cmt"&gt;// fallback value if for some reason it doesn&amp;#39;t have a value&lt;/span&gt;
            &lt;span class="kwd"&gt;foreach&lt;/span&gt; (XmlNode childNode &lt;span class="kwd"&gt;in&lt;/span&gt; node.ChildNodes)
                &lt;span class="kwd"&gt;if&lt;/span&gt; (childNode.Name.Equals(&lt;span class="st"&gt;&amp;quot;value&amp;quot;&lt;/span&gt;))
                {
                    &lt;span class="kwd"&gt;value&lt;/span&gt; = childNode.InnerText;
                    &lt;span class="kwd"&gt;break&lt;/span&gt;;
                }

            resourceDict.Add(name, &lt;span class="kwd"&gt;value&lt;/span&gt;);
        }&lt;/pre&gt;&lt;pre class="coloredcode"&gt;&amp;nbsp;If you&amp;#39;re using C# 3.0, this becomes a lot easier:&lt;font color="#0000ff" size="2"&gt;&lt;/pre&gt;&lt;pre class="coloredcode"&gt;&amp;nbsp;var&lt;/font&gt;&lt;font size="2"&gt; resourceDict = &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;from&lt;/font&gt;&lt;font size="2"&gt; n &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;in&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;XElement&lt;/font&gt;&lt;font size="2"&gt;.Load(Server.MapPath(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;~/App_GlobalResources/Resources.resx&amp;quot;&lt;/font&gt;&lt;font size="2"&gt;)).Elements(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;data&amp;quot;&lt;/font&gt;&lt;font size="2"&gt;)&lt;p&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;                    select&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;new&lt;/font&gt;&lt;font size="2"&gt; { Name = (&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;string&lt;/font&gt;&lt;font size="2"&gt;)n.Attribute(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;name&amp;quot;&lt;/font&gt;&lt;font size="2"&gt;), Value = (&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;string&lt;/font&gt;&lt;font size="2"&gt;)n.Element(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;value&amp;quot;&lt;/font&gt;&lt;font size="2"&gt;) };&lt;/p&gt;&lt;/font&gt;&lt;/pre&gt;&amp;nbsp;</description></item><item><title>Getting resource name</title><link>http://forums.asp.net/thread/1941571.aspx</link><pubDate>Thu, 04 Oct 2007 20:04:34 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1941571</guid><dc:creator>MADCookie</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1941571.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=151&amp;PostID=1941571</wfw:commentRss><description>&lt;p&gt;Is there a way to loop through the items in a resource file so I can get the item&amp;#39;s name and value?&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item></channel></rss>