-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #688 from Mara3l/master
STL-169: Translations PySDK support
- Loading branch information
Showing
13 changed files
with
548 additions
and
0 deletions.
There are no files selected for viewing
67 changes: 67 additions & 0 deletions
67
docs/content/en/latest/workspace-content/localization/_index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
--- | ||
title: "Metadata Localization" | ||
linkTitle: "Metadata Localization" | ||
weight: 20 | ||
--- | ||
|
||
Manage metadata localization for workspaces. | ||
|
||
## Methods | ||
|
||
* [get_metadata_localization](./get_metadata_localization/) | ||
* [set_metadata_localization](./set_metadata_localization/) | ||
* [clean_metadata_localization](./clean_metadata_localization/) | ||
* [add_metadata_locale](./add_metadata_locale/) | ||
* [save_metadata_locale_to_disk](./save_metadata_locale_to_disk/) | ||
* [set_metadata_locale_from_disk](./set_metadata_locale_from_disk/) | ||
|
||
## Example | ||
|
||
```python | ||
from gooddata_sdk import GoodDataSdk | ||
from pathlib import Path | ||
|
||
# GoodData base URL, e.g. "https://www.example.com" | ||
host = "https://www.example.com" | ||
# GoodData user token | ||
token = "some_user_token" | ||
sdk = GoodDataSdk.create(host, token) | ||
|
||
# Example usage for getting metadata localization | ||
localization = sdk.catalog_workspace.get_metadata_localization( | ||
workspace_id="123", | ||
target_language="de-DE" | ||
) | ||
|
||
# Example usage for setting metadata localization | ||
sdk.catalog_workspace.set_metadata_localization( | ||
workspace_id="123", | ||
encoded_xml=b"<xml>...</xml>" | ||
) | ||
|
||
# Example usage for cleaning metadata localization | ||
sdk.catalog_workspace.clean_metadata_localization( | ||
workspace_id="123", | ||
target_language="de-DE" | ||
) | ||
|
||
# Example usage for adding metadata locale | ||
sdk.catalog_workspace.add_metadata_locale( | ||
workspace_id="123", | ||
target_language="de-DE", | ||
translator_func=my_translation_function, | ||
set_locale=True | ||
) | ||
|
||
# Example usage for saving metadata locale to disk | ||
sdk.catalog_workspace.save_metadata_locale_to_disk( | ||
workspace_id="123", | ||
target_language="de-DE", | ||
file_path=Path("/path/to/file.xliff") | ||
) | ||
|
||
# Example usage for setting metadata locale from disk | ||
sdk.catalog_workspace.set_metadata_locale_from_disk( | ||
workspace_id="123", | ||
file_path=Path("/path/to/file.xliff") | ||
) |
39 changes: 39 additions & 0 deletions
39
docs/content/en/latest/workspace-content/localization/add_metadata_locale.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
title: "add_metadata_locale" | ||
linkTitle: "add_metadata_locale" | ||
weight: 25 | ||
superheading: "catalog_workspace." | ||
--- | ||
|
||
``add_metadata_locale(workspace_id: str, target_language: str, translator_func: Callable, set_locale: bool = True) -> None`` | ||
|
||
Add and optionally set the metadata localization for a workspace in a target language. | ||
|
||
{{% parameters-block title="Parameters" %}} | ||
{{< parameter p_name="workspace_id" p_type="string" >}} | ||
The ID of the workspace. | ||
{{< /parameter >}} | ||
{{< parameter p_name="target_language" p_type="string" >}} | ||
The target language for the metadata localization. | ||
{{< /parameter >}} | ||
{{< parameter p_name="translator_func" p_type="Callable" >}} | ||
A function to translate the source text. | ||
{{< /parameter >}} | ||
{{< parameter p_name="set_locale" p_type="bool" >}} | ||
Flag to indicate if the locale settings should be updated in the workspace. | ||
{{< /parameter >}} | ||
{{% /parameters-block %}} | ||
|
||
{{% parameters-block title="Returns" None="yes" %}} | ||
{{% /parameters-block %}} | ||
|
||
## Example | ||
|
||
```python | ||
# Add and set the metadata localization for a workspace using a translation function. | ||
sdk.catalog_workspace.add_metadata_locale( | ||
workspace_id="123", | ||
target_language="de-DE", | ||
translator_func=my_translation_function, | ||
set_locale=True | ||
) |
39 changes: 39 additions & 0 deletions
39
...content/en/latest/workspace-content/localization/clean_metadata_localization.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
title: "add_metadata_locale" | ||
linkTitle: "add_metadata_locale" | ||
weight: 55 | ||
superheading: "catalog_workspace." | ||
--- | ||
|
||
``add_metadata_locale(workspace_id: str, target_language: str, translator_func: Callable, set_locale: bool = True) -> None`` | ||
|
||
Add and optionally set the metadata localization for a workspace in a target language. | ||
|
||
{{% parameters-block title="Parameters" %}} | ||
{{< parameter p_name="workspace_id" p_type="string" >}} | ||
The ID of the workspace. | ||
{{< /parameter >}} | ||
{{< parameter p_name="target_language" p_type="string" >}} | ||
The target language for the metadata localization. | ||
{{< /parameter >}} | ||
{{< parameter p_name="translator_func" p_type="Callable" >}} | ||
A function to translate the source text. | ||
{{< /parameter >}} | ||
{{< parameter p_name="set_locale" p_type="bool" >}} | ||
Flag to indicate if the locale settings should be updated in the workspace. | ||
{{< /parameter >}} | ||
{{% /parameters-block %}} | ||
|
||
{{% parameters-block title="Returns" None="yes" %}} | ||
{{% /parameters-block %}} | ||
|
||
## Example | ||
|
||
```python | ||
# Add and set the metadata localization for a workspace using a translation function. | ||
sdk.catalog_workspace.add_metadata_locale( | ||
workspace_id="123", | ||
target_language="de-DE", | ||
translator_func=my_translation_function, | ||
set_locale=True | ||
) |
34 changes: 34 additions & 0 deletions
34
docs/content/en/latest/workspace-content/localization/get_metadata_localization.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
title: "get_metadata_localization" | ||
linkTitle: "get_metadata_localization" | ||
weight: 52 | ||
superheading: "catalog_workspace." | ||
--- | ||
|
||
``get_metadata_localization(workspace_id: str, target_language: str) -> bytes`` | ||
|
||
Retrieve the metadata localization for a workspace. | ||
|
||
{{% parameters-block title="Parameters" %}} | ||
{{< parameter p_name="workspace_id" p_type="string" >}} | ||
The ID of the workspace for which to retrieve the metadata localization. | ||
{{< /parameter >}} | ||
{{< parameter p_name="target_language" p_type="string" >}} | ||
The target language code for the localization. | ||
{{< /parameter >}} | ||
{{% /parameters-block %}} | ||
|
||
{{% parameters-block title="Returns" %}} | ||
{{< parameter p_type="bytes" >}} | ||
Object Containing declarative Analytical Model. | ||
{{< /parameter >}}The encoded metadata localization in the target language. | ||
{{% /parameters-block %}} | ||
|
||
## Example | ||
|
||
```python | ||
# Retrieve metadata localization for a workspace in the specified language. | ||
localization = sdk.catalog_workspace.get_metadata_localization( | ||
workspace_id="123", | ||
target_language="de-DE" | ||
) |
35 changes: 35 additions & 0 deletions
35
...ontent/en/latest/workspace-content/localization/save_metadata_locale_to_disk.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
title: "save_metadata_locale_to_disk" | ||
linkTitle: "save_metadata_locale_to_disk" | ||
weight: 56 | ||
superheading: "catalog_workspace." | ||
--- | ||
|
||
``save_metadata_locale_to_disk(workspace_id: str, target_language: str, file_path: Path) -> None`` | ||
|
||
Save the metadata localization for a workspace to a file. | ||
|
||
{{% parameters-block title="Parameters" %}} | ||
{{< parameter p_name="workspace_id" p_type="string" >}} | ||
The ID of the workspace. | ||
{{< /parameter >}} | ||
{{< parameter p_name="target_language" p_type="string" >}} | ||
The target language for the metadata localization. | ||
{{< /parameter >}} | ||
{{< parameter p_name="file_path" p_type="Path" >}} | ||
The path to the file where the XLIFF content will be saved. | ||
{{< /parameter >}} | ||
{{% /parameters-block %}} | ||
|
||
{{% parameters-block title="Returns" None="yes" %}} | ||
{{% /parameters-block %}} | ||
|
||
## Example | ||
|
||
```python | ||
# Save the metadata localization for a workspace to a file. | ||
sdk.catalog_workspace.save_metadata_locale_to_disk( | ||
workspace_id="123", | ||
target_language="de-DE", | ||
file_path=Path("/path/to/file.xliff") | ||
) |
33 changes: 33 additions & 0 deletions
33
...ntent/en/latest/workspace-content/localization/set_metadata_locale_from_disk.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- | ||
title: "set_metadata_locale_from_disk" | ||
linkTitle: "set_metadata_locale_from_disk" | ||
weight: 57 | ||
superheading: "catalog_workspace." | ||
--- | ||
|
||
``set_metadata_locale_from_disk(workspace_id: str, file_path: Path) -> None`` | ||
|
||
Load and set the metadata localization for a workspace from a file. | ||
|
||
{{% parameters-block title="Parameters" %}} | ||
{{< parameter p_name="workspace_id" p_type="string" >}} | ||
The ID of the workspace to which the metadata localization applies. | ||
{{< /parameter >}} | ||
{{< parameter p_name="file_path" p_type="Path" >}} | ||
The path to the file containing the encoded XML metadata. | ||
{{< /parameter >}} | ||
{{% /parameters-block %}} | ||
|
||
{{% parameters-block title="Returns" None="yes" %}} | ||
{{% /parameters-block %}} | ||
|
||
## Example | ||
|
||
```python | ||
# Load and set the metadata localization for a workspace from a file. | ||
from pathlib import Path | ||
|
||
sdk.catalog_workspace.set_metadata_locale_from_disk( | ||
workspace_id="123", | ||
file_path=Path("/path/to/file.xliff") | ||
) |
31 changes: 31 additions & 0 deletions
31
docs/content/en/latest/workspace-content/localization/set_metadata_localization.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
title: "set_metadata_localization" | ||
linkTitle: "set_metadata_localization" | ||
weight: 53 | ||
superheading: "catalog_workspace." | ||
--- | ||
|
||
``set_metadata_localization(workspace_id: str, encoded_xml: bytes) -> None`` | ||
|
||
Set the metadata localization for a workspace. | ||
|
||
{{% parameters-block title="Parameters" %}} | ||
{{< parameter p_name="workspace_id" p_type="string" >}} | ||
The ID of the workspace to which the metadata localization applies. | ||
{{< /parameter >}} | ||
{{< parameter p_name="encoded_xml" p_type="bytes" >}} | ||
The encoded XML metadata to be set. | ||
{{< /parameter >}} | ||
{{% /parameters-block %}} | ||
|
||
{{% parameters-block title="Returns" None="yes" %}} | ||
{{% /parameters-block %}} | ||
|
||
## Example | ||
|
||
```python | ||
# Set the metadata localization for a workspace using encoded XML. | ||
sdk.catalog_workspace.set_metadata_localization( | ||
workspace_id="123", | ||
encoded_xml=b"<xml>...</xml>" | ||
) |
Oops, something went wrong.