diff options
author | Damien Picard <pioverfour> | 2022-08-23 12:43:39 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2022-08-23 12:54:34 +0300 |
commit | 4ac96a483bf1567d37ec0357c5430c731c4f884e (patch) | |
tree | 376ced2dae9f4b288707574be1a84d7fdf4cbfda /source/blender | |
parent | 22fdb88be525fbefb77c17fe69956e1e367c747e (diff) |
I18n: make workspaces translatable
This makes workspaces more translatable:
- New Workspace menu
- header
- preset menus
- preset entries
- workspace names upon factory file template load
- new workspace name upon workspace addition
To properly translate those names, an extraction function for
workspace names from app templates was added as well.
(Do not do anything when loading a user-saved file!)
Reviewed By: mont29
Differential Revision: https://developer.blender.org/D15727
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/screen/workspace_edit.c | 12 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_files.c | 7 |
2 files changed, 16 insertions, 3 deletions
diff --git a/source/blender/editors/screen/workspace_edit.c b/source/blender/editors/screen/workspace_edit.c index fc3ac53ef0b..e1ebd3932d1 100644 --- a/source/blender/editors/screen/workspace_edit.c +++ b/source/blender/editors/screen/workspace_edit.c @@ -359,6 +359,11 @@ static int workspace_append_activate_exec(bContext *C, wmOperator *op) BLO_LIBLINK_APPEND_RECURSIVE); if (appended_workspace) { + if (BLT_translate_new_dataname()) { + /* Translate workspace name */ + BKE_libblock_rename(bmain, &appended_workspace->id, CTX_DATA_(BLT_I18NCONTEXT_ID_WORKSPACE, idname)); + } + /* Set defaults. */ BLO_update_defaults_workspace(appended_workspace, NULL); @@ -442,7 +447,7 @@ static void workspace_append_button(uiLayout *layout, PointerRNA opptr; uiItemFullO_ptr( - layout, ot_append, workspace->id.name + 2, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, &opptr); + layout, ot_append, CTX_DATA_(BLT_I18NCONTEXT_ID_WORKSPACE, workspace->id.name + 2), ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, &opptr); RNA_string_set(&opptr, "idname", id->name + 2); RNA_string_set(&opptr, "filepath", filepath); } @@ -495,7 +500,8 @@ static void workspace_add_menu(bContext *UNUSED(C), uiLayout *layout, void *temp static int workspace_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { - uiPopupMenu *pup = UI_popup_menu_begin(C, op->type->name, ICON_ADD); + uiPopupMenu *pup = UI_popup_menu_begin(C, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, + op->type->name), ICON_ADD); uiLayout *layout = UI_popup_menu_layout(pup); uiItemMenuF(layout, IFACE_("General"), ICON_NONE, workspace_add_menu, NULL); @@ -507,7 +513,7 @@ static int workspace_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS char *template = link->data; char display_name[FILE_MAX]; - BLI_path_to_display_name(display_name, sizeof(display_name), template); + BLI_path_to_display_name(display_name, sizeof(display_name), IFACE_(template)); /* Steals ownership of link data string. */ uiItemMenuFN(layout, display_name, ICON_NONE, workspace_add_menu, template); diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index cbf492fc582..fd0e09be3b0 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -699,6 +699,13 @@ static void wm_file_read_post(bContext *C, const struct wmFileReadPost_Params *p } } + if (is_factory_startup && BLT_translate_new_dataname()) { + /* Translate workspace names */ + LISTBASE_FOREACH_MUTABLE (WorkSpace *, workspace, &bmain->workspaces) { + BKE_libblock_rename(bmain, &workspace->id, CTX_DATA_(BLT_I18NCONTEXT_ID_WORKSPACE, workspace->id.name + 2)); + } + } + if (use_data) { /* important to do before NULL'ing the context */ BKE_callback_exec_null(bmain, BKE_CB_EVT_VERSION_UPDATE); |