How to get the Interface language of c4d
-
Hi,
i want to get the interface language of c4d use python.
Thanks for any help
-
Hi @chuanzhen,
to get a specific installed language via python you can use
c4d.GeGetLanguage(index)
.When you want to retrieve all installed langauges you must iterate them yourself.
See the code example below. Meant to be executed from the script manager.
Cheers,
Sebastianfrom typing import Optional, Generator import c4d doc: c4d.documents.BaseDocument # The active document op: Optional[c4d.BaseObject] # The active object, None if unselected def iter_language(start: int=0) -> Generator[dict, None, None]: """Yield all installed languages. Paramameters ------------ start int: The index to start with Returns ------- Generator[dict] Example ------- >>> for language in iter_language(): print(language) {'extensions': 'en-US', 'name': 'English', 'default_language': True} """ while True: lang = c4d.GeGetLanguage(start) if lang is None: break yield lang start += 1 def main() -> None: # Called when the plugin is selected by the user. Similar to CommandData.Execute. for language in iter_language(): print(language) """ def state(): # Defines the state of the command in a menu. Similar to CommandData.GetState. return c4d.CMD_ENABLED """ if __name__ == '__main__': main()
-
@HerrMay Thanks!