You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/en/docs/apidocs-mxsdk/apidocs/frontend/design-properties/design-properties-10.md
+28Lines changed: 28 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -744,6 +744,34 @@ In that situation, you can combine **Dropdown**, **Colorpicker**, **ToggleButton
744
744
745
745
When the **Small** option is selected, the `borderRadiusSmall` class will be applied to the widget. On the other hand, when **Large** is selected, the `--radius-large` variable will be assigned to the `border-radius` property of the widget.
746
746
747
+
## Translating Design Properties
748
+
749
+
Design properties can be translated to match the end-user's preferred user interface language. This includes the name of the design property, its description, and any of its options (if it has any) as shown in the **Properties** tab. The provided translations do not affect the behavior of the design property.
750
+
751
+
To provide translations for your design properties, create a file *locales/{language-code}/translation.json* in the **Styling** folder of your module. The language code can be any of the user interface languages supported by Studio Pro, such as *en-US*, *ja-JP*, *ko-KR*, or *zh-CN*. Other files in the **locales/{language-code}** folders will be ignored. As a result, custom namespaces cannot be used. As an example, a resulting structure could look like this:
752
+
753
+
{{< figure src="/attachments/apidocs-mxsdk/apidocs/design-properties/translations.png" alt="Atranslation.json file in the Styling/locales/de-DE folder" class="no-border" >}}
754
+
755
+
These JSON files follow the format used by the i18next library, specifically v3. See the [the i18next JSON format documentation](https://www.i18next.com/misc/json-format) for more information. For example to translate a design property with the name **Text align** with the options **left**, **center** and **right**, the contents of *locales/ko-KR/translation.json* might look something like this:
756
+
757
+
758
+
```json
759
+
{
760
+
"Text align": "텍스트 정렬",
761
+
"left": "왼쪽",
762
+
"center": "센터",
763
+
"right": "오른쪽"
764
+
}
765
+
```
766
+
767
+
All design properties and options with the same name will be translated the same way, even if they are defined in different modules. When two or more modules define a translation for the same design property or design property option, the one used is not guaranteed to be the same as the one outlined in [Extending or Overriding Design Properties of Other Modules](#extend-existing-design-properties). As a result, we recommend to only translate design properties and design property options in the same module in which they are defined.
768
+
769
+
If a translation is not available, the names and descriptions as defined in *design-properties.json* are used as a fallback instead. For example, the user changes their settings to work with Studio Pro in Korean, but the module does not have a *locales/ko-KR/translation.json* file. This can also happen if the name of a design property, any of its options or descriptions are missing from the corresponding *translation.json* file.
770
+
771
+
{{% alert color="warning" %}}
772
+
When adding translations for existing design properties, do not change the name of existing design properties or their options as defined in *design-properties.json*. Those names cannot be changed easily when there are apps already using them. For more information, see the [Renaming Design Properties](#old-names) section above.
Copy file name to clipboardExpand all lines: content/en/docs/apidocs-mxsdk/apidocs/studio-pro-10/pluggable-widgets/_index.md
+54Lines changed: 54 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -69,6 +69,7 @@ A widget package file is just a ZIP archive containing the following things:
69
69
**{widgetName}.tile.dark.png* sets the dark-mode equivalent to *{widgetName}.tile.png*
70
70
* Optionally, some widget-related resources, preferably located next to the file which contains the client component
71
71
* Note that all CSS files you add (except the one located in the **lib** sub-directory) will automatically be loaded in an app via the widget
72
+
* Optionally, a *locales* folder.
72
73
73
74
Naming your widget package file after the `widgetName` is best practice. Also, a widget package can include multiple widgets by putting several of the above items in the same widget package. However, creating such packages is *not recommended*.
74
75
@@ -307,6 +308,59 @@ Here is how a caption and description look in Studio Pro:
A pluggable widget can provide translations to be used within Studio Pro to match an end-user's preferred user interface language (of Studio Pro). This includes translations for:
314
+
315
+
* The name of the pluggable widget (for example, in the **Toolbox**).
316
+
* The names of properties or values of properties, (for example, in the **Properties** dialog box).
317
+
* Texts like labels used in the editor preview (for example, when editing a page in Design Mode).
318
+
319
+
If provided, the Studio Pro user interface automatically uses the translations for the name of the widget and any of its properties. However, texts shown in the pluggable widgets preview have to be translated by calling the **translate** function. The **preview** function in *{widgetName}.editorPreview.js* receives this **translate** function as a prop. It will look up the provided translation for a given key, as in the following example:
320
+
321
+
```tsx
322
+
exportfunction preview(props) {
323
+
return (
324
+
<div>
325
+
{props.translate("Hello world")}
326
+
</div>
327
+
)
328
+
}
329
+
```
330
+
331
+
Translations for a pluggable widget can be provided in two ways: in the widget package itself, or in a module. These translations do not affect the behavior of the app once deployed. If there is no translation available for a users preferred user interface language, English will be used as the fallback language.
332
+
333
+
### Providing Translations in a Pluggable Widget Package
334
+
335
+
To support a translation for a specific language and locale, create a *locales/{language-code}/{widget ID}.json* or *locales/{language-code}/translation.json* file. The language code can be any of the user interface languages supported by Studio Pro, such as *en-US*, *ja-JP*, *ko-KR*, or *zh-CN*. Other files in the **locales** folder will be ignored. As a result, custom namespaces cannot be used. We recommend using *translation.json*, unless your .MPK contains multiple pluggable widgets. Note that if you use the widget ID as the file name, you will have to replace any spaces and illegal path characters (if there are any) with underscores. The file name should be all lower case. For example, if your widget ID is *%My Pluggable Widget%*, the name of the file should be *_my_pluggable_widget_.json*.
336
+
337
+
These JSON files follow the format used by the i18next library, specifically v3. For more information, see [the i18nest JSON documentation](https://www.i18next.com/misc/json-format). For example, to translate a widget with the name *Text Box* that has a property *length*, the contents of *locales/ko-KR/translation.json* might look something like this example:
338
+
339
+
```json
340
+
{
341
+
"Text Box": "텍스트 상자",
342
+
"length": "텍스트 길이"
343
+
}
344
+
```
345
+
346
+
### Providing Translations in a Module
347
+
348
+
Translations for a pluggable widget can also be provided by a module. This can be useful when you would like to provide a module that has more than one pluggable widget, or if your pluggable widget uses one or more [/apidocs-mxsdk/apidocs/frontend/design-properties/](design properties).
349
+
350
+
To achieve this, create a *locales/{language-code}/{widget ID}.json* file in the **Styling** folder of your module. You will have to replace any spaces and illegal path characters (if there are any) with underscores. The file name should be all lower case. For example, if your widget ID is *%My Pluggable Widget%*, the name of the file should be *_my_pluggable_widget_.json*. In addition, create a *locales/metadata.json* file. The resulting structure will look something like this example:
351
+
352
+
{{< figure src="attachments/apidocs-mxsdk/apidocs/pluggable-widgets/translations.png" alt="A metadata.json file in the Styling/locales folder and a custom.widget.id.json file in the Styling/locales/ko-KR folder" class="no-border" >}}
353
+
354
+
The contents of *locales/metadata.json* should be as follows:
355
+
356
+
```json
357
+
{
358
+
"widgetsToBeTranslated": []
359
+
}
360
+
```
361
+
362
+
The value of *widgetsToBeTranslated* is a string array where each string must be a valid widget ID. If a .JSON file for a pluggable widget exists, but its widget ID is not included in this array, it will be ignored.
363
+
310
364
## Documents in this Section
311
365
312
366
Mendix offers the following APIs for pluggable widgets:
0 commit comments