<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Localizing an XBAP application without using LocBaml</title>
	<atom:link href="http://www.geektieguy.com/2006/12/12/localizing-an-xbap-application-without-using-locbaml/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.geektieguy.com/2006/12/12/localizing-an-xbap-application-without-using-locbaml/</link>
	<description>News and views from the geek tie guy.</description>
	<pubDate>Fri, 25 Jul 2008 16:07:05 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: Tim</title>
		<link>http://www.geektieguy.com/2006/12/12/localizing-an-xbap-application-without-using-locbaml/#comment-7368</link>
		<dc:creator>Tim</dc:creator>
		<pubDate>Tue, 13 May 2008 14:31:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.geektieguy.com/2006/12/12/localizing-an-xbap-application-without-using-locbaml/#comment-7368</guid>
		<description>Regarding the issue with the design view and the default language - you can define a RD for your default language in your App.xaml and later optionally add another RD in the described way, the new items will hide the items defined for the default language. BTW for review purposes you could also build an "identity" RD on-the-fly mapping the key value to the key value. With such a auxilary construct you can display your forms showing your keys instead of the values.</description>
		<content:encoded><![CDATA[<p>Regarding the issue with the design view and the default language - you can define a RD for your default language in your App.xaml and later optionally add another RD in the described way, the new items will hide the items defined for the default language. BTW for review purposes you could also build an &#8220;identity&#8221; RD on-the-fly mapping the key value to the key value. With such a auxilary construct you can display your forms showing your keys instead of the values.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: GeekTieGuy</title>
		<link>http://www.geektieguy.com/2006/12/12/localizing-an-xbap-application-without-using-locbaml/#comment-1368</link>
		<dc:creator>GeekTieGuy</dc:creator>
		<pubDate>Wed, 03 Oct 2007 16:23:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.geektieguy.com/2006/12/12/localizing-an-xbap-application-without-using-locbaml/#comment-1368</guid>
		<description>Sorry, I haven't had a need to look into that. So I don't know. 

However, one thing you could try is put default strings into all XAML elements (TextBox, Label, TextBlock, etc.) and then replace them at runtime, for example in the Loaded event (or something that fires earlier.)</description>
		<content:encoded><![CDATA[<p>Sorry, I haven&#8217;t had a need to look into that. So I don&#8217;t know. </p>
<p>However, one thing you could try is put default strings into all XAML elements (TextBox, Label, TextBlock, etc.) and then replace them at runtime, for example in the Loaded event (or something that fires earlier.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rick</title>
		<link>http://www.geektieguy.com/2006/12/12/localizing-an-xbap-application-without-using-locbaml/#comment-1365</link>
		<dc:creator>Rick</dc:creator>
		<pubDate>Wed, 03 Oct 2007 09:51:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.geektieguy.com/2006/12/12/localizing-an-xbap-application-without-using-locbaml/#comment-1365</guid>
		<description>Any idea how to load default language so that application won't loop crapy in design view?</description>
		<content:encoded><![CDATA[<p>Any idea how to load default language so that application won&#8217;t loop crapy in design view?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Al</title>
		<link>http://www.geektieguy.com/2006/12/12/localizing-an-xbap-application-without-using-locbaml/#comment-1006</link>
		<dc:creator>Al</dc:creator>
		<pubDate>Sat, 22 Sep 2007 10:51:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.geektieguy.com/2006/12/12/localizing-an-xbap-application-without-using-locbaml/#comment-1006</guid>
		<description>Hi,

I think this way is way better than localization with Locbaml (at least for strings). The problem we have with Locbaml (as far as I tested) is that if a new localizable (e.g. Window) is added to your project AFTER localization process, you'll need to regenerate the whole .csv file, so what will happen to all already localized content?

I've changed your code to contain fallback to default culture when a culture-specific resource is not found. Here it is :


        public static ResourceDictionary LoadExternalResourceDictionary(string xamlFilename, CultureInfo culture)
        {
            string cultureName = string.Empty;

            if (culture != null)
                cultureName = string.Concat(".", culture.Name);

            if(Path.HasExtension(xamlFilename))
            {
                string ext = Path.GetExtension(xamlFilename);
                xamlFilename = xamlFilename.Remove(xamlFilename.Length - ext.Length);
            }

            try
            {
                string looseFile = string.Format("pack://siteoforigin:,,,/{0}{1}.xaml", xamlFilename, culture != null ? cultureName : string.Empty);
                Uri uri = new Uri(looseFile, UriKind.Absolute);

                System.Windows.Markup.XamlReader reader = new System.Windows.Markup.XamlReader();
                System.Windows.Resources.StreamResourceInfo info = System.Windows.Application.GetRemoteStream(uri);

                return reader.LoadAsync(info.Stream) as ResourceDictionary;
            }
            catch
            {
                if(culture != null)
                {
                    return LoadExternalResourceDictionary(xamlFilename, null);
                }
                else
                {
                    throw;
                }
            }
        }</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I think this way is way better than localization with Locbaml (at least for strings). The problem we have with Locbaml (as far as I tested) is that if a new localizable (e.g. Window) is added to your project AFTER localization process, you&#8217;ll need to regenerate the whole .csv file, so what will happen to all already localized content?</p>
<p>I&#8217;ve changed your code to contain fallback to default culture when a culture-specific resource is not found. Here it is :</p>
<p>        public static ResourceDictionary LoadExternalResourceDictionary(string xamlFilename, CultureInfo culture)<br />
        {<br />
            string cultureName = string.Empty;</p>
<p>            if (culture != null)<br />
                cultureName = string.Concat(&#8221;.&#8221;, culture.Name);</p>
<p>            if(Path.HasExtension(xamlFilename))<br />
            {<br />
                string ext = Path.GetExtension(xamlFilename);<br />
                xamlFilename = xamlFilename.Remove(xamlFilename.Length - ext.Length);<br />
            }</p>
<p>            try<br />
            {<br />
                string looseFile = string.Format(&#8221;pack://siteoforigin:,,,/{0}{1}.xaml&#8221;, xamlFilename, culture != null ? cultureName : string.Empty);<br />
                Uri uri = new Uri(looseFile, UriKind.Absolute);</p>
<p>                System.Windows.Markup.XamlReader reader = new System.Windows.Markup.XamlReader();<br />
                System.Windows.Resources.StreamResourceInfo info = System.Windows.Application.GetRemoteStream(uri);</p>
<p>                return reader.LoadAsync(info.Stream) as ResourceDictionary;<br />
            }<br />
            catch<br />
            {<br />
                if(culture != null)<br />
                {<br />
                    return LoadExternalResourceDictionary(xamlFilename, null);<br />
                }<br />
                else<br />
                {<br />
                    throw;<br />
                }<br />
            }<br />
        }</p>
]]></content:encoded>
	</item>
</channel>
</rss>
