Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    How to get the Interface language of c4d

    Cinema 4D SDK
    python 2023
    2
    3
    470
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • chuanzhenC
      chuanzhen
      last edited by chuanzhen

      Hi,
      i want to get the interface language of c4d use python.
      Thanks for any help
      2023615-121111.jpg

      相信我,可以的!

      1 Reply Last reply Reply Quote 0
      • H
        HerrMay
        last edited by

        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,
        Sebastian

        from 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()
        
        chuanzhenC 1 Reply Last reply Reply Quote 0
        • chuanzhenC
          chuanzhen @HerrMay
          last edited by

          @HerrMay Thanks!👍

          相信我,可以的!

          1 Reply Last reply Reply Quote 0
          • First post
            Last post