Blender – Development – Learning – #2

Aim: to change the Language view in the splash screen. When we grep Quick Setup, we can find that the relevant code that we are lookin for here is in the file

release/scripts/startup/bl_operators/wm.py

The relevant code is:

        if bpy.app.build_options.international:
            prefs = context.preferences
            # fun-hacks - changing case
            col.prop(prefs.view, "language", text="LANGUAGE")
            col.separator()

We look at
dir(prefs.view)

The result is:

[‘__doc__’, ‘__module__’, ‘__slots__’, ‘bl_rna’, ‘color_picker_type’, ‘factor_display_type’, ‘filebrowser_display_type’, ‘font_path_ui’, ‘font_path_ui_mono’, ‘gizmo_size’, ‘gizmo_size_navigate_v3d’, ‘header_align’, ‘language’, ‘lookdev_sphere_size’, ‘mini_axis_brightness’, ‘mini_axis_size’, ‘mini_axis_type’, ‘open_sublevel_delay’, ‘open_toplevel_delay’, ‘pie_animation_timeout’, ‘pie_initial_timeout’, ‘pie_menu_confirm’, ‘pie_menu_radius’, ‘pie_menu_threshold’, ‘pie_tap_timeout’, ‘render_display_type’, ‘rna_type’, ‘rotation_angle’, ‘show_addons_enabled_only’, ‘show_column_layout’, ‘show_developer_ui’, ‘show_gizmo’, ‘show_navigate_ui’, ‘show_object_info’, ‘show_playback_fps’, ‘show_splash’, ‘show_statusbar_memory’, ‘show_statusbar_stats’, ‘show_statusbar_version’, ‘show_statusbar_vram’, ‘show_tooltips’, ‘show_tooltips_python’, ‘show_view_name’, ‘smooth_view’, ‘text_hinting’, ‘timecode_style’, ‘ui_line_width’, ‘ui_scale’, ‘use_directional_menus’, ‘use_mouse_over_open’, ‘use_save_prompt’, ‘use_text_antialiasing’, ‘use_translate_interface’, ‘use_translate_new_dataname’, ‘use_translate_tooltips’, ‘use_weight_color_range’, ‘view2d_grid_spacing_min’, ‘view_frame_keyframes’, ‘view_frame_seconds’, ‘view_frame_type’, ‘weight_color_range’]

Here we find the ‘langugage’ attribute. We can set it’s value. We need to find the code corresponding to different languages available in Blender. We do another grep. We find the following file: release/datafiles/locale/languages

The file looks like this:

0:Complete: 0:Automatic (Automatic):DEFAULT 1:English (English):en_US 9:Spanish (Español):es 2:Japanese (日本語):ja_JP 47:Slovak (Slovenčina):sk_SK 41:Vietnamese (tiếng Việt):vi_VN 13:Simplified Chinese (简体中文):zh_CN

Now let us change the language back to Japanese. The code is ja_JP. We set the language as:

context.preferences.view.language="ja_JP"

Before we test it, we also make the value of following attribute is se to True, otherwise only part of some descriptions will be translated.

context.preferences.view.use_translate_interface=True

The final result is:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s