Skip to main content

Microsoft Silverlight

Answered Question Beta2 Resource LocalizationRSS Feed

(1)

tr-jfroman
tr-jfroman

Member

Member

2 points

12 Posts

Beta2 Resource Localization

I'm trying to get the localization to work within my Silverlight application.  I created a resource file along with the other language files  (eg:  Resource1.resx, Resource1.de-DE.resx, Resource1.fr-FR.resz, etc...).  When setting the culture and uiculture using the parameter tags on the page, the numbers and dates change as expected according to the specified language, but when using the resource files to read a string (eg: Resource1.String2), this just uses the default resource file and not the selected language.

This was working in Beta1, but does not work in Beta2.  Is there something that has changed or something else I need to do to make this function properly?

Any assistance would be greatly appreciated.

Thank You,
Jarred Froman

slyi
slyi

Participant

Participant

810 points

247 Posts

Re: Beta2 Resource Localization

I had the same issue: http://silverlight.net/forums/p/12709/58722.aspx#5872In the new beta2 the language eg:de folder does not get automatically pushed into the web project SilverlightApplication1Web\ClientBin folder.
Even thought it does get generated in the local debug folder eg: SilverlightApplication\bin\debug\de\SilverlightApplication1.resources.dll
To get around this you can:  
1. Update the Properties\AppManifest.xml
2. Add <AssemblyPart Source="de/SilverlightApplication1.resources.dll" /> into Deployment.Parts section
3. In the properties of the SilverlightApplication1, Click build events and in the post build events add

xcopy /SY  "$(TargetDir)de" "$(SolutionDir)$(ProjectName)Web\ClientBin\de\"
4. Click save and re-compile
  

BTW: How are you doing the string binding, something like below, Im curious to how best to accomplish this?

<Grid x:Name="LayoutRoot" Background="White"><StackPanel Orientation="Vertical">           
<TextBlock x:Name="String1" Text="english text1" Loaded="BindLocResources" />           
<TextBlock x:Name="String2" Text="english text2" Loaded="BindLocResources" />           
</StackPanel></Grid> 

 

public partial class Page : UserControl    {                public Page()        {

            System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("de");

            InitializeComponent();    

}

        private void BindLocResources (object sender, RoutedEventArgs e)        {           

((TextBlock)sender).Text = Resource1.ResourceManager.GetString(((TextBlock)sender).Name, System.Threading.Thread.CurrentThread.CurrentCulture);         }    } 

 

tr-jfroman
tr-jfroman

Member

Member

2 points

12 Posts

Re: Beta2 Resource Localization

I gave this a try and it seems to work somewhat.  The behovior is very odd as sometimes it only changes the culture sometimes as if there is some sort of timing issue with it.  Have you tried it with multiple cultures?

I set up two different ways of switching the culture...  1) Directly through the thread as you have set up above... 2) By causing a Postback and changing the culture param on the object tag of the web page.   Each of these produces different results and using different binding methodologies:

The binding that works for #1 is by just setting the value directly similarly to how you do it above:
    MyString2.Text = Resource1.String2.ToString();

For #2, I managed to be able to get the binding tag and DataContext to work somewhat.  I did the following:
On the App.xaml.cs, I added in:
    private static Resource1 _cultureResource = new Resource1();

    public static Resource1 CultureResource
    {
        get { return _cultureResource; }
    }

Within the Page.xaml.cs, I added in the line to the load:
     this.DataContext = App.CultureResource;

Within the Page.xaml, on the controls that required binding:
    <TextBlock Text="{Binding String2}" x:Name="MyString2" />
    <TextBlock Text="{Binding String3}" x:Name="MyString3" />

These seem to produce erratic results and I'm not quite happy with the way it's functioning.  What I'd like to do is just figure out a way to just bind to a static variable using the #2 method without having to instantiate the object in the App class.  This to me seems like the way it should be done... however, I can't get it to work.  (ie: Text="{Binding String2, Source=Resource1}" ... or something to that effect)

Thanks for your prompt reply and the suggestions... it seems as though while quite a bit of the culture binding has been fixed in Beta2... other functionality now seems to be broken.

-Jarred Froman

slyi
slyi

Participant

Participant

810 points

247 Posts

Re: Beta2 Resource Localization

Your correct there seems to be some strange bug on resource loading, if you a page refresh 5 times.

I like your method and i was tryng something similar to work for beta1 but had no luck.
But setting the Resource file to public, gave me idea if you set the resources as a usercontrol.resource, but Resource1.Designer.cs need a little update from internal Resource1() { to public Resource1() {

This allows

<UserControl x:Class="SilverlightApplication5.Page"  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Loc="clr-namespace:SilverlightApplication5.Resources"  Width="400" Height="300" >
<UserControl.Resources><Loc:Resource1 x:Name="LocStrings" /></UserControl.Resources>
<Grid x:Name="LayoutRoot" Background="White"><StackPanel Orientation="Vertical">
<TextBlock x:Name="String1" Text="{Binding String1, Source={StaticResource LocStrings}}" />
<TextBlock x:Name="String2" Text="{Binding String2, Source={StaticResource LocStrings}}" />
<TextBlock x:Name="String3" Text="{Binding String3, Source={StaticResource LocStrings}}" />
<TextBlock x:Name="String4" Text="{Binding String4, Source={StaticResource LocStrings}}" />
</StackPanel></Grid></UserControl>

 

jordanhammond
jordanha...

Member

Member

190 points

104 Posts

Re: Beta2 Resource Localization

Can anyone recommend a good application for managing language resource files?  

I know Visual Studio can be used to edit the resource files for each individual language, but is there an app that can simplify the proces (i.e. adding new resources to English and ensuring that they are also created for the many other languages your app supports).

tr-jfroman
tr-jfroman

Member

Member

2 points

12 Posts

Re: Beta2 Resource Localization

That's exactly what I've been looking for... and seems like the logical way to set it up... however, it seems odd that we would have to change the function to public.  I wonder if this was intended or if it's a bug.  I tried creating a separate class that would inherit off of the Resource file to see if that would work and exposing it as public but while I did manage to get the page to load without error, it wasn't reading the properties.

Something else that occurred to me was that while both of our methods seem to work somewhat, I think there might be something inherently wrong with how it is functioning to begin with.  The idea that we are binding to static properties from an object that is instantiated should technically not be allowed and I wonder if that is a flaw within .NET.  If you were to try to access one of the static properties from LocStrings on the code-behind, you'll see that the properties aren't exposed and it won't let you compile.

It seems like there is also a bug in the ResourceManager.  The refreshing of the page is the same behavior I was experiencing as well.

-Jarred Froman

tr-jfroman
tr-jfroman

Member

Member

2 points

12 Posts

Re: Beta2 Resource Localization

Hi Jordan,

I am looking for a similar tool for our office as well.  I've been hoping that after all these years, that something like this would have already been built into the Resource management tools within Visual Studio. 

If you happen to come across something like this, please let me know.

Thanks,
-Jarred Froman

slyi
slyi

Participant

Participant

810 points

247 Posts

Answered Question

Re: Beta2 Resource Localization

This artical helps explain why it doesnt work with multiple dll's but getting difficulties implementing it one xap per locale

http://blogs.msdn.com/webdevtools/archive/2008/06/10/localizing-a-silverlight-application.aspx

tr-jfroman
tr-jfroman

Member

Member

2 points

12 Posts

Re: Beta2 Resource Localization

Great find!  Big Smile

It's not quite as erratic as it was before, but for some reason, I can only get english (en-US) and french (fr-FR) to work.  German (de-DE) won't...  Actually, I also found that if I create a separate resource file for en-US rather than using that as the default, it gets stuck on that language.  Are you able to get the multiple languages working?

-Jarred Froman

slyi
slyi

Participant

Participant

810 points

247 Posts

Re: Beta2 Resource Localization

No i still have not managed to get multi lang working, but i have documented what we have found so far on blog post on silverlight localization.

Im getting the feeling multi-lang may not be possible from http://blogs.msdn.com/silverlight_sdk/archive/2008/06/04/what-s-new-in-silverlight-2-beta-2.aspx ? Has anyone got any examples on this?

 Localization
1.        Changes in application model for multilingual apps (one xap per supported locale)

slyi
slyi

Participant

Participant

810 points

247 Posts

Re: Beta2 Resource Localization

For resx syncing, did you try http://www.screwturn.eu/Default.aspx?Page=ResxSync&AspxAutoDetectCookieSupport=1

tr-jfroman
tr-jfroman

Member

Member

2 points

12 Posts

Re: Beta2 Resource Localization

According to the MSDN blog post you found earlier, it sounds as if it does allow you to compile multiple cultures into one XAP file: 

--------------------------
1. In the solution explorer unload the Silverlight project and edit the project file. There is pre-created tag of “SupportedCultures” in the first property group tag. Fill in the culture value of “ja-jp”, so you get “<SupportedCultures>ja-jp</SupportedCultures>”. Note, you can also fill in a culture list separated by “,” or “;” to support multiple cultures/languages in the same xap file. For example you can fill in a string of “ja-JP;fr-FR”. VS reads this list and only packs related satellite assembly folders.
--------------------------

Further down the blog also demonstrates how to split them out into multiple XAPs.  I have been having a little trouble with the method above however... it seems to allow switching between english and whatever the last language in the list (sorted alphabetically) is supplied.  For example, if the list was de-DE;ja-JP;fr-FR... it will only allow you to switch between the default (english) and ja-JP.

I was also trying to find a way to be able to read through the supported cultures.  I think Beta1 had a property for this and I think they removed it in Beta2.

BTW, nice find on the command line tool!  Smile

-Jarred Froman

eric_delahaye@hotmail.com
eric_del...

Member

Member

181 points

43 Posts

Re: Beta2 Resource Localization

I discovered something. I suspect that does not support more than 2 languages (bug?)
You must edit the project file *.csproj and change the order of EmbeddedResource tags
 
First of all:
 <SupportedCultures>fr;es;en</SupportedCultures>
 
Then:
Big Smile
    <EmbeddedResource Include="Resources\Resource.resx">
      <Generator>PublicResXFileCodeGenerator</Generator>
      <LastGenOutput>Resource.Designer.cs</LastGenOutput>
      <SubType>Designer</SubType>
    </EmbeddedResource>
Big Smile
    <EmbeddedResource Include="Resources\Resource.es.resx">
      <Generator>PublicResXFileCodeGenerator</Generator>
      <LastGenOutput>FenixExplorerResource.es.Designer.cs</LastGenOutput>
      <SubType>Designer</SubType>
    </EmbeddedResource>
Angry
    <EmbeddedResource Include="Resources\Resource.fr.resx">
      <Generator>PublicResXFileCodeGenerator</Generator>
      <LastGenOutput>Resource.fr.Designer.cs</LastGenOutput>
      <SubType>Designer</SubType>
    </EmbeddedResource>
 
First the default resx, then the second resx, the thirdly never works, no matter what resx is it.
 
Always i need "clean solution" after edit manually the project file.
 
Can anyone else confirm this? Embarrassed
 
 
 

EriC#

jordanhammond
jordanha...

Member

Member

190 points

104 Posts

Re: Beta2 Resource Localization

 Hi Eric,

Working from both Syli's blog (http://wpf-e.spaces.live.com/blog/cns!2B248D261D0E0035!203.entry) and the one on MSDN (http://blogs.msdn.com/webdevtools/archive/2008/06/10/localizing-a-silverlight-application.aspx) I have managed to get a solution working that seems to support any number of languages. 

However I would say it is anything but elegant.  If this is what the final release of 2.0 is going to be like then I am going to have to sadly use Flex for my project.

To change between each language (cannot be done whilst in runtime due to One Language Per Xap), I had to change the params as mentioned in Syli's post, and also set a new CultureInfo for the Strings Resrouce in App.xaml.cs.

<param name="culture" value="de" />
<param name="uiculture" value="de" />

SilverlightLoc.Resources.Strings.Culture = new CultureInfo("de");

This last line could receive the "de" from QueryString params, App must also be able to read the culture params that are part of the html Object tag, though I haven't looked into it.

MS really needs to sort out this localization mess.

I've added my solution here: http://cid-e0f26f7a54cfc7b0.skydrive.live.com/self.aspx/Documents/SilverlightLoc.zip

 

jordanhammond
jordanha...

Member

Member

190 points

104 Posts

Re: Beta2 Resource Localization

 this should work: http://cid-e0f26f7a54cfc7b0.skydrive.live.com/self.aspx/Documents/SilverlightLoc.zip

 

jordanhammond
jordanha...

Member

Member

190 points

104 Posts

Re: Beta2 Resource Localization

I've been adding the resource binding to my generic.xaml, all seems to work fine until I try to bind to the Header value of a DataGridTextColumn.  This crashes the app when the grid is added to the canvas.

<Grid.Resources>
    <loc:Strings x:Name="LocStrings"/>
</Grid.Resources>

 ....

<data:DataGridTextColumn Header="{Binding Market, Source={StaticResource LocStrings}}" DisplayMemberBinding="{Binding Name, Mode=OneWay}" MinWidth="200" /> 

 

Anyone else tried to use localization on a DataGrid?

 

Eric_delahaye@hotmail.com
Eric_del...

Member

Member

181 points

43 Posts

Re: Beta2 Resource Localization

jordanhammond  

thanks for your reply and example

Unfortunately I continue with the same bug, you solution only work with French and English. I think that this issue could be my default language (spanish) "es-AR". I don't know really.
I shall continue waiting for the RTM Silverlight.
 
 

EriC#

tr-jfroman
tr-jfroman

Member

Member

2 points

12 Posts

Re: Beta2 Resource Localization

Hi Eric,

I tried changing the order of the EmbeddedResources as you mentioned and didn't have too much luck... actually, the results produced the reverse of what I have been finding.  Only two resources from the list still load... however, instead of it selecting the last in the list of other languages (sorted alphabetically), it selects the first in the list.

For those that are still a little confused by what I mean, try adding in these 3 languages... de-DE;fr-FR;ja-JP ... if the default embeddedresource is the last in the list, it allows you to switch between the default (english) and ja-JP.  If it's first in the list, default (english) and de-DE.  Remove either of those languages from the list and watch what happens.  It appears that there is some sort of bug with the way it is loading up the resource files for multiple languages.

-Jarred Froman

tr-jfroman
tr-jfroman

Member

Member

2 points

12 Posts

Re: Beta2 Resource Localization

Hi Jordan,

I haven't had much luck with setting the culture directly in the resource class.  This was working in Beta1 but I'm having trouble with it in Beta2.  Regardless, instead of reading the params... you could also do the following:

SilverlightLoc.Resources.Strings.Culture = System.Globalization.CultureInfo.CurrentCulture;

That should at least help you set it a bit more generically.  In Beta1, this was automatically selecting that value if it wasn't set... not sure if this is a bug with Beta2 now.

-Jarred Froman

jordanhammond
jordanha...

Member

Member

190 points

104 Posts

Re: Beta2 Resource Localization

 I've pretty much got it all working, the only thing I don't know how to do is the asp.net server controls.  I want to use an aspx page rather than html, and I don't know how to create dynamic asp server controls. 

Can anyone help with this?

Need the Source property to be dynamic:

<asp:Silverlight ID="Xaml1" runat="server" Source="~/ClientBin/JaXap/SilverlightLoc.xap" MinimumVersion="2.0.30523" Width="100%" Height="100%" />

 

jordanhammond
jordanha...

Member

Member

190 points

104 Posts

Re: Beta2 Resource Localization

OK, I RTFM on ASP.NET and found the asp.PlaceHolder.  Handy control.

I've updated the same to:

  • Accept the language as a querystring param (i.e. default.aspx?l=de)
  • Added a Silverlight Controls library to test localizing such setup (who would really put everything in the main package?)
  • That's about it.

Issues:  I don't know how to set the Silverlight control's width & height to 100% with code.  See default.aspx, hopefully someone can help out.

The source has been replaced and located here.

slyi
slyi

Participant

Participant

810 points

247 Posts

Re: Beta2 Resource Localization

Hi Jarred,

I found a solution to the erratic resource loading issues with multi language resources, the resource dlls must be in the xap itself and not loose in the clientbin folder. Once they are in the xap, it always loads the correct culture. But it doesnt work when supportcultures values are set. I dont really like creating multiple xap's per culture anyway unless it we were dynamiclly downloading. Heres what i needed to do

1. Create a addfiletozip.vbs and add it to the root of your SL project
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.NameSpace(Wscript.arguments(0))
objFolder.CopyHere Wscript.arguments(1), &H10&
WScript.Sleep 500

2. Add <AssemblyPart Source="de/SilverlightApplication1.resources.dll" /><AssemblyPart Source="fr/SilverlightApplication1.resources.dll" /> into Deployment.Parts section in file Properties\AppManifest.xml

3.
In the properties of the SilverlightApplication1, Click build events and in the post build events add
move "$(TargetDir)$(ProjectName).xap" "$(TargetDir)$(ProjectName).zip"
cscript /nologo "$(SolutionDir)$(ProjectName)\addfiletozip.vbs"   "$(TargetDir)$(ProjectName).zip" "$(TargetDir)de"
cscript /nologo "$(SolutionDir)$(ProjectName)\addfiletozip.vbs"   "$(TargetDir)$(ProjectName).zip" "$(TargetDir)fr"
move "$(TargetDir)$(ProjectName).zip" "$(TargetDir)$(ProjectName).xap"

4. Compile and DE resources always load
 Regards
slyi

slyi
slyi

Participant

Participant

810 points

247 Posts

Re: Beta2 Resource Localization

Sorry my mistake the culture assemebly's must not in sub-folders but in the root

eg add <AssemblyPart Source="SilverlightApplication1.de.resources.dll" /><AssemblyPart Source="SilverlightApplication1.fr.resources.dll" /> into Deployment.Parts section in file Properties\AppManifest.xml

Sample on http://cid-2b248d261d0e0035.skydrive.live.com/self.aspx/Public/SL-Loc.zip

slyi
slyi

Participant

Participant

810 points

247 Posts

Re: Beta2 Resource Localization

Hi All, 

Ive created a second blog article on how  to create a Multi Langauge Silverlight 2.0 Application and string replacement.

I hope this helps.

slyi

anandav200
anandav200

Member

Member

53 points

56 Posts

Re: Re: Beta2 Resource Localization

Hi,

 I have been trying Slyi methods forDanish. I created Strings.da.resx and did the methods as said in his blog. But when i click the button for Danish resource it loads English resource..Please help me to fix this

Regards,
Anand

slyi
slyi

Participant

Participant

810 points

247 Posts

Re: Re: Beta2 Resource Localization

I get no error on Danish. See sample http://cid-2b248d261d0e0035.skydrive.live.com/self.aspx/Public/danish.zip

Please remember to use da-dk or just da rather than da-da for CultureInfo

anandav200
anandav200

Member

Member

53 points

56 Posts

Re: Re: Beta2 Resource Localization

 

Hello Slyi,

 Thanks for your reply..Your sample is working for me..But mine still doesnt work despite any changes...

Please download the sample from the below link and plz let me know where i went wrong...

http://www.yuntaa.com/FileManager/Download.aspx?ContentID=5169A427EB17551CE04400144FB7B71E

 

Regards,

Anand

Regards,
Anand

slyi
slyi

Participant

Participant

810 points

247 Posts

Re: Re: Beta2 Resource Localization

You are missing the reference to your danish dll in Properties\AppManifest.xml. Please review http://wpf-e.spaces.live.com/blog/cns!2B248D261D0E0035!230.entry . This is only an issue for beta 2 this will be fixed in a later release.

eg:

<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment"

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >

<Deployment.Parts>

<AssemblyPart Source="SilverlightApplication8.de.resources.dll" />

<AssemblyPart Source="SilverlightApplication8.ja.resources.dll" />

<AssemblyPart Source="SilverlightApplication8.fr.resources.dll" />

<AssemblyPart Source="SilverlightApplication8.da.resources.dll" />

</Deployment.Parts>

</Deployment>

anandav200
anandav200

Member

Member

53 points

56 Posts

Re: Re: Beta2 Resource Localization

Hello Slyi,

  Thanks for your support. It still didnt work for me. Crying Once i change the xml adding

 <AssemblyPart Source="SilverlightApplication8.da.resources.dll" />

 and rebuilding again it disappeared. I am using notepad to edit it.

Thi is my current manifest file. Also i am attaching the build output. Please let me know whether i went wrong.

<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" EntryPointAssembly="SilverlightApplication8" EntryPointType="SilverlightApplication8.App" RuntimeVersion="2.0.30523.6">
  <Deployment.Parts>
    <AssemblyPart x:Name="SilverlightApplication8" Source="SilverlightApplication8.dll" />
    <AssemblyPart Source="SilverlightApplication8.de.resources.dll" />
    <AssemblyPart Source="SilverlightApplication8.fr.resources.dll" />
    <AssemblyPart Source="SilverlightApplication8.ja.resources.dll" />
  </Deployment.Parts>
</Deployment>

 

------ Rebuild All started: Project: SilverlightApplication8, Configuration: Debug Any CPU ------

C:\WINDOWS\Microsoft.NET\Framework\v3.5\Csc.exe /noconfig /nowarn:1701,1702 /nostdlib+ /errorreport:prompt /warn:4 /define:DEBUG;TRACE;SILVERLIGHT /reference:"C:\Program Files\Microsoft SDKs\Silverlight\v2.0\Reference Assemblies\mscorlib.dll" /reference:"C:\Program Files\Microsoft SDKs\Silverlight\v2.0\Reference Assemblies\System.Core.dll" /reference:"C:\Program Files\Microsoft SDKs\Silverlight\v2.0\Reference Assemblies\system.dll" /reference:"C:\Program Files\Microsoft SDKs\Silverlight\v2.0\Reference Assemblies\System.Net.dll" /reference:"C:\Program Files\Microsoft SDKs\Silverlight\v2.0\Reference Assemblies\System.Windows.Browser.dll" /reference:"C:\Program Files\Microsoft SDKs\Silverlight\v2.0\Reference Assemblies\System.Windows.dll" /reference:"C:\Program Files\Microsoft SDKs\Silverlight\v2.0\Reference Assemblies\System.Xml.dll" /debug+ /debug:full /optimize- /out:obj\Debug\SilverlightApplication8.dll /resource:obj\Debug\SilverlightApplication8.g.resources /resource:obj\Debug\SilverlightApplication8.Strings.resources /target:library App.xaml.cs convertor.cs Page.xaml.cs Properties\AssemblyInfo.cs Strings.Designer.cs C:\_WorkArea\Study\SilverLight\SL-Multi-Loc\SilverlightApplication8\obj\Debug\App.g.cs C:\_WorkArea\Study\SilverLight\SL-Multi-Loc\SilverlightApplication8\obj\Debug\Page.g.cs

Compile complete -- 0 errors, 0 warnings

C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\AL.exe /culture:da /out:obj\Debug\da\SilverlightApplication8.resources.dll /template:obj\Debug\SilverlightApplication8.dll /embed:obj\Debug\SilverlightApplication8.Strings.da.resources

C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\AL.exe /culture:ja /out:obj\Debug\ja\SilverlightApplication8.resources.dll /template:obj\Debug\SilverlightApplication8.dll /embed:obj\Debug\SilverlightApplication8.Strings.ja.resources

C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\AL.exe /culture:fr /out:obj\Debug\fr\SilverlightApplication8.resources.dll /template:obj\Debug\SilverlightApplication8.dll /embed:obj\Debug\SilverlightApplication8.Strings.fr.resources

C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\AL.exe /culture:de /out:obj\Debug\de\SilverlightApplication8.resources.dll /template:obj\Debug\SilverlightApplication8.dll /embed:obj\Debug\SilverlightApplication8.Strings.de.resources

SilverlightApplication8 -> C:\_WorkArea\Study\SilverLight\SL-Multi-Loc\SilverlightApplication8\Bin\Debug\SilverlightApplication8.dll

Begin application manifest generation

Application manifest generation completed successfully

Begin Xap packaging

Packaging SilverlightApplication8.dll

Packaging AppManifest.xaml

Xap packaging completed successfully

Creating test page

Test page created successfully

move "C:\_WorkArea\Study\SilverLight\SL-Multi-Loc\SilverlightApplication8\Bin\Debug\SilverlightApplication8.xap" "C:\_WorkArea\Study\SilverLight\SL-Multi-Loc\SilverlightApplication8\Bin\Debug\SilverlightApplication8.zip"

for %%i in (de fr ja da) do (

move "C:\_WorkArea\Study\SilverLight\SL-Multi-Loc\SilverlightApplication8\Bin\Debug\%%i\SilverlightApplication8.resources.dll" "C:\_WorkArea\Study\SilverLight\SL-Multi-Loc\SilverlightApplication8\Bin\Debug\SilverlightApplication8.%%i.resources.dll"

cscript /nologo "C:\_WorkArea\Study\SilverLight\SL-Multi-Loc\SilverlightApplication8\addfiletozip.vbs" "C:\_WorkArea\Study\SilverLight\SL-Multi-Loc\SilverlightApplication8\Bin\Debug\SilverlightApplication8.zip" "C:\_WorkArea\Study\SilverLight\SL-Multi-Loc\SilverlightApplication8\Bin\Debug\SilverlightApplication8.%%i.resources.dll"

)

move "C:\_WorkArea\Study\SilverLight\SL-Multi-Loc\SilverlightApplication8\Bin\Debug\SilverlightApplication8.zip" "C:\_WorkArea\Study\SilverLight\SL-Multi-Loc\SilverlightApplication8\Bin\Debug\SilverlightApplication8.xap"

------ Rebuild All started: Project: C:\...\SilverlightApplication8Web\, Configuration: Debug .NET ------

Validating Web Site

Building directory '/SilverlightApplication8Web/'.

Validation Complete

========== Rebuild All: 2 succeeded, 0 failed, 0 skipped ==========

 

Regards,
Anand

slyi
slyi

Participant

Participant

810 points

247 Posts

Re: Re: Beta2 Resource Localization

Your properties\appmanifest.xaml still doesnt contain a reference to the DA dll, you need to add the line, like i stated in my previous reply.

If you are see a blank screen please set SilverlightApplication8TestPage.html as start page

http://blufiles.storage.live.com/y1pm4rBe-tLaoJOWdI9Fn7AuRnzhzXK4zPyD4zVSMWHqaPag_ydDRS7FkOxnn4_Rsxd

anandav200
anandav200

Member

Member

53 points

56 Posts

Re: Re: Beta2 Resource Localization

I did that. But on next build it disappeared from appmanifest.xaml that is located on SL-Multi-Loc\SilverlightApplication8\Bin\Debug folder and the Danish resx is not working

Also i am using notepad to edit the manidfest.xml . Is ther any other way to do that.

Thanks for your support.

 

Regards,
Anand

slyi
slyi

Participant

Participant

810 points

247 Posts

Re: Re: Beta2 Resource Localization

Please edit the file inside your Visual studio project not externally, but i dont how this makes a difference. eg: C:\_WorkArea\Study\SilverLight\SL-Multi-Loc\SilverlightApplication8\properties\appmanifest.xml

Also i have updated that one line in http://cid-2b248d261d0e0035.skydrive.live.com/self.aspx/Public/da.zip to show it works.

jordanhammond
jordanha...

Member

Member

190 points

104 Posts

Re: Re: Beta2 Resource Localization

I like the idea of changing the localization on the fly, however have you tried to do this in a solution where a controls library is in a separate project, which is downloaded by the initial app?

Also what about downloading language resource strings on demand before using?

 

slyi
slyi

Participant

Participant

810 points

247 Posts

Re: Re: Beta2 Resource Localization

Exactly, this will be my next blog article as a just said on http://silverlight.net/forums/t/19929.aspx, as the app size could grow unscalable, if you 20 languages each with a 1000 strings. I should have something available this weekend on http://wpf-e.spaces.live.com/

What im thinking is packaging the generated dll's into a xap as a post build event, rather than seperate projects per culture dll, and then using the on demand library functionality http://msdn.microsoft.com/en-us/library/cc296243(VS.95).aspx to download and create a new instance of the usercontrol once you select a different language in the listbox.

Have you had issues trying this method?

jordanhammond
jordanha...

Member

Member

190 points

104 Posts

Re: Re: Beta2 Resource Localization

 I'm only looking at it now.  Though I have issues with assigning the culture of a controls dll that is not part of the main app.  It downloads whilst the login screen is shown, then once downloaded I try to set the culture but it doesn't pick it up.  The control library has its own string resources, this could be what's going wrong.

 

anandav200
anandav200

Member

Member

53 points

56 Posts

Re: Re: Beta2 Resource Localization

Thanks Slyi..I got it working..

But i have all my usercontrols in SIlverLight Class Library which i am refering in SL application. I am planning to implement one resx per xaml control .(If i create a usercontrol FilterBox.xaml my plan is to create FilterBoxResource.da.resx for Danish). How is it possible?

Regards,
Anand

jordanhammond
jordanha...

Member

Member

190 points

104 Posts

Re: Re: Beta2 Resource Localization

 Hi Slyi, I tried applying your post build script to a new project - to test the multi language xap (http://wpf-e.spaces.live.com/blog/cns!2B248D261D0E0035!230.entry) and the vbs file keeps throwing an error:  "The compressed (Zipped) folder is invalid or corrupted."

Have you seen this before?

I put a MsgBox in the vbs to show the arguments and they're correct.  I am using Vista.

Simbalight
Simbalight

Member

Member

245 points

87 Posts

Re: Re: Beta2 Resource Localization

Hi!

I've recognized that sometimes the xap's zip archive is not fully compatible with windows "zip compressed folder". I suppose this is the same issue. Try to open the zip (xap) file with explorer (and the zip compressed folder dll). It will work. But then try to remove a file or add one manually. It will fail.

A possible solution could be to use another tool to copy the file into the archive. Thus you must change the script Slyi provided.

Hope that helps!

jordanhammond
jordanha...

Member

Member

190 points

104 Posts

Re: Re: Beta2 Resource Localization

 thanks, not worth the effort, I don't really need multi-language xaps.  more important to be able to load the language resource dynamically.

 

slyi
slyi

Participant

Participant

810 points

247 Posts

Re: Re: Beta2 Resource Localization

I'll have a post ready for the weekend using dyncmically creating the culture xaps using post build events, but the ondemand loading works see crude sample at http://cid-2b248d261d0e0035.skydrive.live.com/self.aspx/Public/ondemand.zip

For the folks having issues with the zip/xaps vbs script. Can you confirm if have some other zip technolgy installed (i dont) eg: winzip, winrar etc... which may interfere with windows zip compression, also is the issues happening on win2k3 or Vista 64 or any other non standard config?  

 

jordanhammond
jordanha...

Member

Member

190 points

104 Posts

Re: Re: Beta2 Resource Localization

 thanks slyi, will have a look at the sample.

 I have 7zip intalled.

Simbalight
Simbalight

Member

Member

245 points

87 Posts

Re: Re: Beta2 Resource Localization

I think that the zip/xap problem is independent of additional zip tools. Please check this xap http://www.vortexeu.com/simba/SL2_B2_LocTest.xap.

It is exactly as it was emitted by VS2008. I cannot erase any file using the windows "zip compressed folder". Can you reproduce the issue on your system?

slyi
slyi

Participant

Participant

810 points

247 Posts

Re: Re: Beta2 Resource Localization

Your correct, i cant add or delete to that compressed folder either.

Try setting the timeout WScript.Sleep 500 to 5 seconds eg: WScript.Sleep 5000, to give extra time to add the file to the compressed folder in the VB Script also try using a different compression tool eg: winzip

Can you tell if your using a german OS or Visual Studio ?

Simbalight
Simbalight

Member

Member

245 points

87 Posts

Re: Re: Beta2 Resource Localization

My manual tests with WinZip do work.

It's VS2008 Pro, WinXP Pro and SL2B2 Tollkit for VS2008, all german versions.

 

Simbalight
Simbalight

Member

Member

245 points

87 Posts

Re: Re: Beta2 Resource Localization

I'm pretty sure people from MS are following this thread. I would really like to know how localization is going to be fixed for RTM. What to do till then? Use Slyi's "Friend-to-Public-Hack"? How can we minimize the necessary changes for RTM?

bPlaTyPuS
bPlaTyPuS

Member

Member

2 points

1 Posts

Re: Re: Re: Beta2 Resource Localization

Hi everyone!

When I try your solutions, I have always the same problem -> it doesn't work in Blend... (it's only displaying an error in Blend :

"The DependencyProperty target is invalid: myProject.Strings"

Do you have an idea how to solve this ?

Thx for help!

andrevieiradematos
andrevie...

Member

Member

6 points

3 Posts

Re: Re: Re: Beta2 Resource Localization

hello

i started adding multilanguage support to my silverlight 2 beta 2 application today. i am using different resx files as usual (.pt-BR.resx, .fr-FR.resx, etc) in other applications i write, and it works fine.

I tryed the same thing with the silverlight app, but i started getting the errors related in this post (only the default language, in my case, loads). I've searched the web and found:

- 1 post (http://wpf-e.spaces.live.com/blog/cns!2B248D261D0E0035!230.entry) telling that this is some sort of bug that will be fixed in final version;

- another post (http://blogs.msdn.com/webdevtools/archive/2008/06/10/localizing-a-silverlight-application.aspx) telling that this is [the new Silverlight runtime localization model, which essentially is “one language, one xap”.];

- this discussion with a few alternatives to have multilanguage silverlight 2 application.

The silverlight app i'm writing is only a small part of a bigger project, and i'm still 6 months way from "releasing it in the world", so trying all of these approaches to find out that this problem will be fixed in RTM would be a waist of time.

My question is "who is right"? The guy telling that this is a known bug that will be fixed or the other one telling that this is the new runtime localization model (aka microsoft's new way of spending developer's time)?

Thanks

roshvallyara
roshvall...

Member

Member

2 points

1 Posts

Re: Beta2 Resource Localization

i'm able to bind page with multiple resource check my blog http://roshworldoftechnologies.blogspot.com/2008/07/multiple-resource-support-in.html

anandav200
anandav200

Member

Member

53 points

56 Posts

Re: Re: Beta2 Resource Localization

Thanks Rosh for your post 

But i have all my usercontrols in SIlverLight Class Library which i am refering in SL application. I am planning to implement one resx per xaml control .(If i create a usercontrol FilterBox.xaml my plan is to create FilterBoxResource.da.resx for Danish). How is it possible to use the resource file fro danish when my culture is Danish?

Regards,
Anand

Regards,
Anand

jordanhammond
jordanha...

Member

Member

190 points

104 Posts

Re: Re: Beta2 Resource Localization

 

anandav200:

But i have all my usercontrols in SIlverLight Class Library which i am refering in SL application. I am planning to implement one resx per xaml control .(If i create a usercontrol FilterBox.xaml my plan is to create FilterBoxResource.da.resx for Danish). How is it possible to use the resource file fro danish when my culture is Danish?

If all your controls are in one class library, why don't you put all the xaml in one file - generic.xaml.   By creating language resource files per control would imply that you would also want to have each control in its own library, downloaded only as when needed.

 

anandav200
anandav200

Member

Member

53 points

56 Posts

Re: Re: Beta2 Resource Localization

jordanhammond:
If all your controls are in one class library, why don't you put all the xaml in one file - generic.xaml.

 

Could you please tell me how i can implement that

Regards,
Anand

jordanhammond
jordanha...

Member

Member

190 points

104 Posts

Re: Re: Beta2 Resource Localization

anandav200:

Could you please tell me how i can implement that

 

I've created a very basic sample of a project that utilises generic.xaml.

Available here

anandav200
anandav200

Member

Member

53 points

56 Posts

Re: Re: Beta2 Resource Localization

Hi Guys,

    I would like to know how we can implement multiple localisation on SilverLight Class Library.

My scenario is like this.

1. SL class libraray having controls that can be reused in the silverlight application. These controls need to load resources either in Danish or in English based on the CultureInfo.

 For eg. By default the Content of Button is Browse. But if the user culture info is Dnaish i need to load the content in Danish that is stored in MyUserControl.da.resources. Default need to be loaded from MyUserControl.resources.

2. The complied SL class libraray dlls will be used in SL application

 Any help will be appreciated...

 Regards,

Anand

Regards,
Anand

nzeyimana
nzeyimana

Member

Member

2 points

1 Posts

Re: Re: Beta2 Resource Localization

 Hello, I have an free web-application at http://www.sprakor.com that helps me in localizing applications. Try it and your comments are welcome

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities