Skip to content

Commit eef2bb1

Browse files
authored
Merge pull request #688 from Mara3l/master
STL-169: Translations PySDK support
2 parents 9d40327 + 11bce4f commit eef2bb1

13 files changed

Lines changed: 548 additions & 0 deletions

File tree

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
title: "Metadata Localization"
3+
linkTitle: "Metadata Localization"
4+
weight: 20
5+
---
6+
7+
Manage metadata localization for workspaces.
8+
9+
## Methods
10+
11+
* [get_metadata_localization](./get_metadata_localization/)
12+
* [set_metadata_localization](./set_metadata_localization/)
13+
* [clean_metadata_localization](./clean_metadata_localization/)
14+
* [add_metadata_locale](./add_metadata_locale/)
15+
* [save_metadata_locale_to_disk](./save_metadata_locale_to_disk/)
16+
* [set_metadata_locale_from_disk](./set_metadata_locale_from_disk/)
17+
18+
## Example
19+
20+
```python
21+
from gooddata_sdk import GoodDataSdk
22+
from pathlib import Path
23+
24+
# GoodData base URL, e.g. "https://www.example.com"
25+
host = "https://www.example.com"
26+
# GoodData user token
27+
token = "some_user_token"
28+
sdk = GoodDataSdk.create(host, token)
29+
30+
# Example usage for getting metadata localization
31+
localization = sdk.catalog_workspace.get_metadata_localization(
32+
workspace_id="123",
33+
target_language="de-DE"
34+
)
35+
36+
# Example usage for setting metadata localization
37+
sdk.catalog_workspace.set_metadata_localization(
38+
workspace_id="123",
39+
encoded_xml=b"<xml>...</xml>"
40+
)
41+
42+
# Example usage for cleaning metadata localization
43+
sdk.catalog_workspace.clean_metadata_localization(
44+
workspace_id="123",
45+
target_language="de-DE"
46+
)
47+
48+
# Example usage for adding metadata locale
49+
sdk.catalog_workspace.add_metadata_locale(
50+
workspace_id="123",
51+
target_language="de-DE",
52+
translator_func=my_translation_function,
53+
set_locale=True
54+
)
55+
56+
# Example usage for saving metadata locale to disk
57+
sdk.catalog_workspace.save_metadata_locale_to_disk(
58+
workspace_id="123",
59+
target_language="de-DE",
60+
file_path=Path("/path/to/file.xliff")
61+
)
62+
63+
# Example usage for setting metadata locale from disk
64+
sdk.catalog_workspace.set_metadata_locale_from_disk(
65+
workspace_id="123",
66+
file_path=Path("/path/to/file.xliff")
67+
)
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
title: "add_metadata_locale"
3+
linkTitle: "add_metadata_locale"
4+
weight: 25
5+
superheading: "catalog_workspace."
6+
---
7+
8+
``add_metadata_locale(workspace_id: str, target_language: str, translator_func: Callable, set_locale: bool = True) -> None``
9+
10+
Add and optionally set the metadata localization for a workspace in a target language.
11+
12+
{{% parameters-block title="Parameters" %}}
13+
{{< parameter p_name="workspace_id" p_type="string" >}}
14+
The ID of the workspace.
15+
{{< /parameter >}}
16+
{{< parameter p_name="target_language" p_type="string" >}}
17+
The target language for the metadata localization.
18+
{{< /parameter >}}
19+
{{< parameter p_name="translator_func" p_type="Callable" >}}
20+
A function to translate the source text.
21+
{{< /parameter >}}
22+
{{< parameter p_name="set_locale" p_type="bool" >}}
23+
Flag to indicate if the locale settings should be updated in the workspace.
24+
{{< /parameter >}}
25+
{{% /parameters-block %}}
26+
27+
{{% parameters-block title="Returns" None="yes" %}}
28+
{{% /parameters-block %}}
29+
30+
## Example
31+
32+
```python
33+
# Add and set the metadata localization for a workspace using a translation function.
34+
sdk.catalog_workspace.add_metadata_locale(
35+
workspace_id="123",
36+
target_language="de-DE",
37+
translator_func=my_translation_function,
38+
set_locale=True
39+
)
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
title: "add_metadata_locale"
3+
linkTitle: "add_metadata_locale"
4+
weight: 55
5+
superheading: "catalog_workspace."
6+
---
7+
8+
``add_metadata_locale(workspace_id: str, target_language: str, translator_func: Callable, set_locale: bool = True) -> None``
9+
10+
Add and optionally set the metadata localization for a workspace in a target language.
11+
12+
{{% parameters-block title="Parameters" %}}
13+
{{< parameter p_name="workspace_id" p_type="string" >}}
14+
The ID of the workspace.
15+
{{< /parameter >}}
16+
{{< parameter p_name="target_language" p_type="string" >}}
17+
The target language for the metadata localization.
18+
{{< /parameter >}}
19+
{{< parameter p_name="translator_func" p_type="Callable" >}}
20+
A function to translate the source text.
21+
{{< /parameter >}}
22+
{{< parameter p_name="set_locale" p_type="bool" >}}
23+
Flag to indicate if the locale settings should be updated in the workspace.
24+
{{< /parameter >}}
25+
{{% /parameters-block %}}
26+
27+
{{% parameters-block title="Returns" None="yes" %}}
28+
{{% /parameters-block %}}
29+
30+
## Example
31+
32+
```python
33+
# Add and set the metadata localization for a workspace using a translation function.
34+
sdk.catalog_workspace.add_metadata_locale(
35+
workspace_id="123",
36+
target_language="de-DE",
37+
translator_func=my_translation_function,
38+
set_locale=True
39+
)
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
title: "get_metadata_localization"
3+
linkTitle: "get_metadata_localization"
4+
weight: 52
5+
superheading: "catalog_workspace."
6+
---
7+
8+
``get_metadata_localization(workspace_id: str, target_language: str) -> bytes``
9+
10+
Retrieve the metadata localization for a workspace.
11+
12+
{{% parameters-block title="Parameters" %}}
13+
{{< parameter p_name="workspace_id" p_type="string" >}}
14+
The ID of the workspace for which to retrieve the metadata localization.
15+
{{< /parameter >}}
16+
{{< parameter p_name="target_language" p_type="string" >}}
17+
The target language code for the localization.
18+
{{< /parameter >}}
19+
{{% /parameters-block %}}
20+
21+
{{% parameters-block title="Returns" %}}
22+
{{< parameter p_type="bytes" >}}
23+
Object Containing declarative Analytical Model.
24+
{{< /parameter >}}The encoded metadata localization in the target language.
25+
{{% /parameters-block %}}
26+
27+
## Example
28+
29+
```python
30+
# Retrieve metadata localization for a workspace in the specified language.
31+
localization = sdk.catalog_workspace.get_metadata_localization(
32+
workspace_id="123",
33+
target_language="de-DE"
34+
)
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
title: "save_metadata_locale_to_disk"
3+
linkTitle: "save_metadata_locale_to_disk"
4+
weight: 56
5+
superheading: "catalog_workspace."
6+
---
7+
8+
``save_metadata_locale_to_disk(workspace_id: str, target_language: str, file_path: Path) -> None``
9+
10+
Save the metadata localization for a workspace to a file.
11+
12+
{{% parameters-block title="Parameters" %}}
13+
{{< parameter p_name="workspace_id" p_type="string" >}}
14+
The ID of the workspace.
15+
{{< /parameter >}}
16+
{{< parameter p_name="target_language" p_type="string" >}}
17+
The target language for the metadata localization.
18+
{{< /parameter >}}
19+
{{< parameter p_name="file_path" p_type="Path" >}}
20+
The path to the file where the XLIFF content will be saved.
21+
{{< /parameter >}}
22+
{{% /parameters-block %}}
23+
24+
{{% parameters-block title="Returns" None="yes" %}}
25+
{{% /parameters-block %}}
26+
27+
## Example
28+
29+
```python
30+
# Save the metadata localization for a workspace to a file.
31+
sdk.catalog_workspace.save_metadata_locale_to_disk(
32+
workspace_id="123",
33+
target_language="de-DE",
34+
file_path=Path("/path/to/file.xliff")
35+
)
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
title: "set_metadata_locale_from_disk"
3+
linkTitle: "set_metadata_locale_from_disk"
4+
weight: 57
5+
superheading: "catalog_workspace."
6+
---
7+
8+
``set_metadata_locale_from_disk(workspace_id: str, file_path: Path) -> None``
9+
10+
Load and set the metadata localization for a workspace from a file.
11+
12+
{{% parameters-block title="Parameters" %}}
13+
{{< parameter p_name="workspace_id" p_type="string" >}}
14+
The ID of the workspace to which the metadata localization applies.
15+
{{< /parameter >}}
16+
{{< parameter p_name="file_path" p_type="Path" >}}
17+
The path to the file containing the encoded XML metadata.
18+
{{< /parameter >}}
19+
{{% /parameters-block %}}
20+
21+
{{% parameters-block title="Returns" None="yes" %}}
22+
{{% /parameters-block %}}
23+
24+
## Example
25+
26+
```python
27+
# Load and set the metadata localization for a workspace from a file.
28+
from pathlib import Path
29+
30+
sdk.catalog_workspace.set_metadata_locale_from_disk(
31+
workspace_id="123",
32+
file_path=Path("/path/to/file.xliff")
33+
)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
title: "set_metadata_localization"
3+
linkTitle: "set_metadata_localization"
4+
weight: 53
5+
superheading: "catalog_workspace."
6+
---
7+
8+
``set_metadata_localization(workspace_id: str, encoded_xml: bytes) -> None``
9+
10+
Set the metadata localization for a workspace.
11+
12+
{{% parameters-block title="Parameters" %}}
13+
{{< parameter p_name="workspace_id" p_type="string" >}}
14+
The ID of the workspace to which the metadata localization applies.
15+
{{< /parameter >}}
16+
{{< parameter p_name="encoded_xml" p_type="bytes" >}}
17+
The encoded XML metadata to be set.
18+
{{< /parameter >}}
19+
{{% /parameters-block %}}
20+
21+
{{% parameters-block title="Returns" None="yes" %}}
22+
{{% /parameters-block %}}
23+
24+
## Example
25+
26+
```python
27+
# Set the metadata localization for a workspace using encoded XML.
28+
sdk.catalog_workspace.set_metadata_localization(
29+
workspace_id="123",
30+
encoded_xml=b"<xml>...</xml>"
31+
)

0 commit comments

Comments
 (0)