Page 1 of 3

Multi-language and translation

Posted: 21 Mar 2013, 12:44
by karics
I read the "Is it possible use korean language?" topic and I was thinking a little.

Can I translate text with NoesisGUI? ( Like Qt or CEGUI )

Re: Multi-language and translation

Posted: 21 Mar 2013, 16:04
by jsantos
what do you mean by "translating text" ? multilingual support?

Re: Multi-language and translation

Posted: 21 Mar 2013, 18:31
by karics
yes.

I add text in english, french etc. with editor (like QtLingiust), after that when I am change the language from english to french, then all text switch to french equivalent.

Re: Multi-language and translation

Posted: 22 Mar 2013, 13:36
by sfernandez
The correct way to do this in WPF is following this guide in the MSDN:
http://msdn.microsoft.com/en-us/library/ms788718.aspx

You can read this article too to understand how localization works:
http://timheuer.com/blog/archive/2012/0 ... m+Heuer%29

This feature is complex and we decided to leave it out of 1.0 version, but it's planned for version 1.1 because we consider it very important for real production.

Until that feature is implemented we thought of a simpler approximation to application localization by using external ResourceDictionaries that define application texts for each language. Application code can select which dictionary to add to the Application.Resources (or Window.Resources) depending on the selected language.

A language dictionary could look like this:
<!-- Languages/EnglishResources.xaml -->
<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:sys="clr-namespace:System;assembly=mscorlib">

    <sys:String x:Key="Welcome">Welcome to my application</sys:String>
    <sys:String x:Key="Accept">OK</sys:String>
    <sys:String x:Key="Cancel">Cancel</sys:String>

</ResourceDictionary>
And in your window XAML you refer to the localized strings as follows:
<!-- MainWindow.xaml -->
<Window
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:sys="clr-namespace:System;assembly=mscorlib">

    <StackPanel Margin="10">
        <TextBlock Text="{DynamicResource Welcome}"/>
        <StackPanel Orientation="Horizontal">
            <Button x:Name="Ok" Content="{DynamicResource Accept}" Margin="10"/>
            <Button x:Name="Cancel" Content="{DynamicResource Cancel}" Margin="10"/>
        </StackPanel>
    </StackPanel>

</Window>
You cannot use <sys:String> objects in the current beta but will be available for the 1.0 release.

Re: Multi-language and translation

Posted: 22 Mar 2013, 14:07
by karics
Thanks the informations!

Re: Multi-language and translation

Posted: 12 May 2014, 17:54
by walhore
Hi guys, as a follow up, is Globalization/Localization supported yet? I see you're shooting for 1.1. Are you feeling good about that? And do you have a timeframe? This is pretty important for our application. Thanks!

Re: Multi-language and translation

Posted: 12 May 2014, 18:36
by jsantos
For now, the only alternative is using external ResourceDictionaries as shown above. The proper implementation has been delayed, we expect to have it along v1.2.X.

Is the implementation based on ResourceDictionaries enough for you? If not, could you please file us a bug demanding this feature?

Thanks.

Re: Multi-language and translation

Posted: 14 Aug 2014, 22:26
by PandaChuZero
Just like to chime in and say how important this is. Please do add it to the roadmap.

Re: Multi-language and translation

Posted: 16 Aug 2014, 12:01
by sfernandez
Just like to chime in and say how important this is. Please do add it to the roadmap.
Have you seen how it can be done right now? viewtopic.php?f=12&t=485#p2386

Using data binding and string dictionaries is quite easy for localizing an application.

Re: Multi-language and translation

Posted: 18 Aug 2014, 16:23
by PandaChuZero
Excellent, thank you!

Actually of those samples are excellent for seeing how to put things together. I would be even better if you could add more samples.

The one line in quest and localize example makes the preview in blend break.. anyway to fix that?
<local:DraggablePanel x:Name="WoodPanel" Style="{StaticResource WoodPanelStyle}" Margin="50">
error : "DraggablePanel does not exist in the namespace ..."