This repository has been archived on 2023-01-27. You can view files and clone it, but cannot push or open issues or pull requests.
cad/ref/xcad/docs/localization/index.md
2022-10-15 19:16:08 +02:00

2.4 KiB

title caption description image order
Localizing SOLIDWORKS add-ins using xCAD.NET framework Localization How to support multi language SOLIDWORKS add-ins by using of localized resources in xCAD framework menu-localized.png 7

xCAD frameworks supports resources in .NET applications to enable localization of the add-in, e.g. supporting multiple languages.

This technique allows to load localized string at runtime based on the Windows settings in the control panel.

Region and language page in Control Panel{ width=300 }

Resources should be added to the corresponding localized .resx file (e.g. Resources.resx for default, Resources.ru.resx for Russian, Resources.fr.resx for French, etc.)

Resource files in the solutions

In order to reference the string from the resource, use the overloads of the constructors for the TitleAttribute and SummaryAttribute which allows to define title, tooltips, hint string for all elements across xCAD framework (i.e. menu commands, property page controls, macro feature, etc.)

Below is an example which demonstrates this technique. Text is localized as per resources below:

Localized resource files in the Visual Studio{ width=800 }

Menu

Two commands in menu are localized for Russian and English versions of the add-in.

Localized menu commands

{% code-snippet { file-name: ~LocalizationAddIn.*, regions: [Commands] } %}

Property Manager Page

Property Manager page title and tooltips for the controls are localized for Russian and English versions of the add-in.

Localized Property Manager Page

{% code-snippet { file-name: ~LocalizationAddIn.*, regions: [PMPage] } %}

Macro Feature

Macro feature base name is localized to Russian and English versions of the add-in.

Note. Base name is only assigned while feature creation, feature won't be renamed after locale has changed.

Localized Macro Feature base name

In a similar way it is possible to use strings from the resources to return another data, e.g. text of the error for macro feature.

Localized macro feature error

{% code-snippet { file-name: ~LocalizationAddIn.*, regions: [MacroFeature] } %}