Dynamic localization of Actipro strings with .resx files

WPF Studio, Themes, and Shared Library for WPF Forum

The latest build of this product (v25.1.2) was released 2 days ago, which was before this thread was created.
Posted 12 hours ago by BenjaminLopVic - France
Version: 25.1.1
Avatar

Hello,

In our app, we need to handle multiple languages, so we use the .resx files to automaticly localize our strings.

Is it possible to achieve this with Actipro strings?

I know we can redefine strings like this : 

ActiproSoftware.Products.Shared.SR.SetCustomString(ActiproSoftware.Products.Shared.SRName.UICommandCloseWindowText.ToString(), "Fermer");
ActiproSoftware.Products.Shared.SR.SetCustomString(ActiproSoftware.Products.Shared.SRName.UICommandMaximizeWindowText.ToString(), "Maximiser");
ActiproSoftware.Products.Shared.SR.SetCustomString(ActiproSoftware.Products.Shared.SRName.UICommandMinimizeWindowText.ToString(), "Minimiser");

But this is static — if the language changes, the strings won’t update automatically.

Thanks.

Comments (1)

Posted 7 hours ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

Behind the scenes, all our string resources are also defined using standard Visual Studio string resources, which create .resx files.  Our SR classes do have the SetCustomString method, which creates an override in memory for the string resource value.  When we go to retrieve strings, we use the custom override if it is provided.  Otherwise our default string resource from the .resx is used.

Some static dependency properties in UI controls require string resources set for default values.  Since they are static, those defaults can't be updated unless you recreate the control or update the property values.  In other cases, string resources are used in the XAML templates for various UI controls.  Those also can only be updated when a new template is applied, such as when the related control is created.

In summary, if you are updating the language, it is probably best to restart your application or at least recreate the UI controls so that the updated values have a chance to take effect.


Actipro Software Support

Add Comment

Please log in to a validated account to post comments.