-
Notifications
You must be signed in to change notification settings - Fork 26
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 #3526 from open-formulieren/feature/2958-component…
…-level-translations Component level translations
- Loading branch information
Showing
10 changed files
with
1,152 additions
and
11 deletions.
There are no files selected for viewing
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,18 @@ | ||
from ..typing import OptionDict | ||
|
||
|
||
def translate_options( | ||
options: list[OptionDict], | ||
language_code: str, | ||
enabled: bool, | ||
) -> None: | ||
for option in options: | ||
if not (translations := option.get("openForms", {}).get("translations")): | ||
continue | ||
|
||
translated_label = translations.get(language_code, {}).get("label", "") | ||
if enabled and translated_label: | ||
option["label"] = translated_label | ||
|
||
# always clean up | ||
del option["openForms"]["translations"] # type: ignore |
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
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
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
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
Oops, something went wrong.