From dce6dcd302f7ca88cae03bc7183f3737ecaf16c8 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Wed, 29 Jul 2026 16:41:14 +0200 Subject: [PATCH] tdf#172952 uitabpage: Use separate strings for the Apply to X button MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The dialog for choosing a UI has a button at the bottom to apply the setting only to the current module and it has the text “Apply to %MODULE” where %MODULE gets replaced with a non-translatable name for the module. For better or worse, some translations (such as Esperanto) have different names for the modules. For example Writer is Verkilo. For the sake of consistency, it would be nice to be able to translate these strings. It is also difficult translate this string in languages that have a lot of grammatical cases. For example, in Slovakian the translator might ideally want to translate the string as “Použiť vo Writeri” and “Použiť v Calcu” etc, but they currently can’t do this because they would need to be able to add a different suffix depending on which module is being used. In order to fix both problems there is now a specific string with the whole text for each module. Change-Id: I7c478790d89bf33f26b53642a076f9e308d1e64a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208800 Tested-by: Jenkins Reviewed-by: Heiko Tietze --- cui/inc/strings.hrc | 7 ++++++- cui/source/dialogs/uipickerdlg.cxx | 30 ++++++++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/cui/inc/strings.hrc b/cui/inc/strings.hrc index 91b3ad373520..685c22b75ec7 100644 --- a/cui/inc/strings.hrc +++ b/cui/inc/strings.hrc @@ -387,7 +387,12 @@ #define RID_CUISTR_ADDITIONS_THEMES NC_("RID_SVXSTR_ADDITIONS_THEMES", "Extensions: Color Themes") #define RID_CUISTR_ADDITIONS_TEMPLATES NC_("RID_SVXSTR_ADDITIONS_TEMPLATES", "Extensions: Templates") -#define RID_CUISTR_UI_APPLY NC_("RID_SVXSTR_UI_APPLY", "Apply to %MODULE") +// Application names for the “Apply to X” button in the UI chooser dialog +#define RID_CUISTR_UI_APPLY_TO_WRITER NC_("RID_CUISTR_UI_APPLY_TO_WRITER", "Apply to Writer") +#define RID_CUISTR_UI_APPLY_TO_CALC NC_("RID_CUISTR_UI_APPLY_TO_CALC", "Apply to Calc") +#define RID_CUISTR_UI_APPLY_TO_IMPRESS NC_("RID_CUISTR_UI_APPLY_TO_IMPRESS", "Apply to Impress") +#define RID_CUISTR_UI_APPLY_TO_DRAW NC_("RID_CUISTR_UI_APPLY_TO_DRAW", "Apply to Draw") + #define RID_CUISTR_UI_APPLYALL NC_("RID_SVXSTR_UI_APPLYALL", "Apply to All") #define RID_CUISTR_OLE_INSERT NC_("RID_SVXSTR_OLE_INSERT", "Inserting OLE object...") diff --git a/cui/source/dialogs/uipickerdlg.cxx b/cui/source/dialogs/uipickerdlg.cxx index 69a3df6a3b67..c8837ae0ab3a 100644 --- a/cui/source/dialogs/uipickerdlg.cxx +++ b/cui/source/dialogs/uipickerdlg.cxx @@ -22,6 +22,33 @@ #include #include +namespace +{ +OUString lcl_GetApplyToText() +{ + if (std::optional sApp = UITabPage::GetCurrentAppEnum()) + { + switch (*sApp) + { + case vcl::EnumContext::Application::Writer: + return CuiResId(RID_CUISTR_UI_APPLY_TO_WRITER); + case vcl::EnumContext::Application::Calc: + return CuiResId(RID_CUISTR_UI_APPLY_TO_CALC); + case vcl::EnumContext::Application::Impress: + return CuiResId(RID_CUISTR_UI_APPLY_TO_IMPRESS); + case vcl::EnumContext::Application::Draw: + return CuiResId(RID_CUISTR_UI_APPLY_TO_DRAW); + default: + break; + } + } + + assert(!"UI picker dialog used for unsupported application"); + + return OUString(); +} +} + UIPickerDialog::UIPickerDialog(weld::Window* pParent) : SfxTabDialogController(pParent, u"cui/ui/uipickerdialog.ui"_ustr, u"UIPickerDialog"_ustr) , m_xOKBtn(m_xBuilder->weld_button(u"ok"_ustr)) @@ -39,8 +66,7 @@ UIPickerDialog::UIPickerDialog(weld::Window* pParent) // it's mandatory for gtk3 to set the icon before changing the label m_xApplyBtn->set_from_icon_name("sw/res/sc20558.png"); - m_xApplyBtn->set_label( - CuiResId(RID_CUISTR_UI_APPLY).replaceFirst("%MODULE", UITabPage::GetCurrentApp())); + m_xApplyBtn->set_label(lcl_GetApplyToText()); m_xResetBtn->set_label(CuiResId(RID_CUISTR_UI_APPLYALL)); m_xApplyBtn->connect_clicked(LINK(this, UIPickerDialog, OnApplyClick)); m_xResetBtn->connect_clicked(LINK(this, UIPickerDialog, OnApplyClick));