How do I...Override the default language (US English)

Using Microsoft Windows Presentation Foundation and Syncfusion WPF Libraries

How do I...Override the default language (US English)

Postby Fiona|Dyalog on Wed Jul 30, 2014 10:29 am

When you use data binding and the target property is a string, WPF formats the value using US English irrespective of the user-defined language preference on Microsoft Windows. To force WPF to use the user-defined language preference, add the following code before loading any GUI (the Application.Startup event is a good place):

      FrameworkElement.LanguageProperty.OverrideMetadata(
typeof(FrameworkElement),
new FrameworkPropertyMetadata(
XmlLanguage.GetLanguage(
CultureInfo.CurrentCulture.IetfLanguageTag)));
User avatar
Fiona|Dyalog
 
Posts: 74
Joined: Mon Apr 22, 2013 12:59 pm

Re: How do I...Override the default language (US English)

Postby PGilbert on Wed Jul 30, 2014 11:58 am

Hello Fiona, your code is written in C#. What would be the equivalent in Dyalog Apl ?

Thanks.
User avatar
PGilbert
 
Posts: 440
Joined: Sun Dec 13, 2009 8:46 pm
Location: Montréal, Québec, Canada

Re: How do I...Override the default language (US English)

Postby Fiona|Dyalog on Thu Jul 31, 2014 7:25 am

My apologies – there is an APL function to do this for you in #.WPF.Xaml (courtesey of Michael Hughes):

      FixLocale ra;⎕USING;fpm;CultureInfo
⍝ Fixes the locale for Xaml StringFormat etc.
⍝ MUST be used before any Show - fixes a bug in WPF which assumes US locale settings
⍝ ra ←→ Locale indicator, currently only '' supported - choose system locale

⎕USING←'' 'System.Windows,WPF/PresentationFramework.dll'
⎕USING,←'System.Globalization' 'System.Windows,WPF/PresentationCore.dll' 'System.Windows.Markup'
fpm←⎕NEW FrameworkPropertyMetadata(XmlLanguage.GetLanguage(⊂CultureInfo.CurrentCulture.IetfLanguageTag))
:Trap 90
FrameworkElement.LanguageProperty.OverrideMetadata FrameworkElement fpm
:EndTrap
⍝ c mjh 30Apr2013


Used as #.WPF.Xaml.FixLocale '' (as soon as you start).
User avatar
Fiona|Dyalog
 
Posts: 74
Joined: Mon Apr 22, 2013 12:59 pm


Return to WPF & Syncfusion

Who is online

Users browsing this forum: No registered users and 1 guest