sc/inc/globstr.hrc             |    9 ++++++++-
 sc/source/core/data/table3.cxx |   26 +++++++++++++++++++++++++-
 2 files changed, 33 insertions(+), 2 deletions(-)

New commits:
commit f5b3bfbded8ea8d4a0b854a62c82b66747b45833
Author:     Rafael Lima <rafael.palma.l...@gmail.com>
AuthorDate: Wed Dec 21 14:10:32 2022 +0000
Commit:     Olivier Hallot <olivier.hal...@libreoffice.org>
CommitDate: Thu Dec 22 08:11:29 2022 +0000

    tdf#152535 Provide better localization for "Grand" subtotal strings
    
    As discussed in the bug report, having the word "Grand" hardcoded first in 
subtotals is not great for translation, since for some languages the 
translation of "grand" would come second.
    
    This patch creates separate strings for each case of Grand, f.i. "Grand 
Count", "Grand Sum" and so on. Now each of them will have their own translation.
    
    Change-Id: Ib875bc1a7b2fcc8934ad85bfe09374f8d9d9a179
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144666
    Tested-by: Jenkins
    Reviewed-by: Olivier Hallot <olivier.hal...@libreoffice.org>

diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc
index e1f1a485eed0..19e99d1c47d0 100644
--- a/sc/inc/globstr.hrc
+++ b/sc/inc/globstr.hrc
@@ -138,7 +138,6 @@
 #define STR_MSSG_SOLVE_2                        NC_("STR_MSSG_SOLVE_2", "Goal 
Seek failed.\n\n")
 #define STR_MSSG_SOLVE_3                        NC_("STR_MSSG_SOLVE_3", 
"Insert the closest value (")
 #define STR_MSSG_SOLVE_4                        NC_("STR_MSSG_SOLVE_4", ") 
into the variable cell anyway?")
-#define STR_TABLE_GRAND                         NC_("STR_TABLE_GRAND", "Grand")
 #define STR_TABLE_ERGEBNIS                      NC_("STR_TABLE_ERGEBNIS", 
"Result")
 #define STR_UNDO_SPELLING                       NC_("STR_UNDO_SPELLING", 
"Spellcheck")
 #define STR_TABLE_AND                           NC_("STR_TABLE_AND", "AND")
@@ -196,6 +195,14 @@
 #define STR_FUN_TEXT_PRODUCT                    NC_("STR_FUN_TEXT_PRODUCT", 
"Product")
 #define STR_FUN_TEXT_STDDEV                     NC_("STR_FUN_TEXT_STDDEV", 
"StDev")
 #define STR_FUN_TEXT_VAR                        NC_("STR_FUN_TEXT_VAR", "Var")
+#define STR_TABLE_GRAND_AVG                     NC_("STR_TABLE_GRAND_AVG", 
"Grand Average")
+#define STR_TABLE_GRAND_COUNT                   NC_("STR_TABLE_GRAND_COUNT", 
"Grand Count")
+#define STR_TABLE_GRAND_MAX                     NC_("STR_TABLE_GRAND_MAX", 
"Grand Max")
+#define STR_TABLE_GRAND_MIN                     NC_("STR_TABLE_GRAND_MIN", 
"Grand Min")
+#define STR_TABLE_GRAND_PRODUCT                 NC_("STR_TABLE_GRAND_PRODUCT", 
"Grand Product")
+#define STR_TABLE_GRAND_STDDEV                  NC_("STR_TABLE_GRAND_STDDEV", 
"Grand StdDev")
+#define STR_TABLE_GRAND_SUM                     NC_("STR_TABLE_GRAND_SUM", 
"Grand Sum")
+#define STR_TABLE_GRAND_VAR                     NC_("STR_TABLE_GRAND_VAR", 
"Grand Var")
 #define STR_NOCHARTATCURSOR                     NC_("STR_NOCHARTATCURSOR", "No 
chart found at this position.")
 #define STR_PIVOT_NOTFOUND                      NC_("STR_PIVOT_NOTFOUND", "No 
pivot table found at this position.")
 #define STR_EMPTYDATA                           NC_("STR_EMPTYDATA", "(empty)")
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index bdf16a69aad4..a535726fd8fc 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -2058,6 +2058,30 @@ static TranslateId lcl_GetSubTotalStrId(int id)
     }
 }
 
+// Gets the string used for "Grand" results
+static TranslateId lcl_GetGrandSubTotalStrId(int id)
+{
+    switch ( id )
+    {
+        case SUBTOTAL_FUNC_AVE:     return STR_TABLE_GRAND_AVG;
+        case SUBTOTAL_FUNC_CNT:
+        case SUBTOTAL_FUNC_CNT2:    return STR_TABLE_GRAND_COUNT;
+        case SUBTOTAL_FUNC_MAX:     return STR_TABLE_GRAND_MAX;
+        case SUBTOTAL_FUNC_MIN:     return STR_TABLE_GRAND_MIN;
+        case SUBTOTAL_FUNC_PROD:    return STR_TABLE_GRAND_PRODUCT;
+        case SUBTOTAL_FUNC_STD:
+        case SUBTOTAL_FUNC_STDP:    return STR_TABLE_GRAND_STDDEV;
+        case SUBTOTAL_FUNC_SUM:     return STR_TABLE_GRAND_SUM;
+        case SUBTOTAL_FUNC_VAR:
+        case SUBTOTAL_FUNC_VARP:    return STR_TABLE_GRAND_VAR;
+        default:
+        {
+             return STR_EMPTYDATA;
+            // added to avoid warnings
+        }
+    }
+}
+
 //      new intermediate results
 //      rParam.nRow2 is changed!
 
@@ -2264,7 +2288,7 @@ bool ScTable::DoSubTotals( ScSubTotalParam& rParam )
                 DBShowRow(aRowEntry.nDestRow, true);
 
                 // insert label
-                OUString label = ScResId(STR_TABLE_GRAND) + " " + 
ScResId(lcl_GetSubTotalStrId(pResFunc[0]));
+                OUString label = 
ScResId(lcl_GetGrandSubTotalStrId(pResFunc[0]));
                 SetString(nGroupCol[aRowEntry.nGroupNo], aRowEntry.nDestRow, 
nTab, label);
                 ApplyStyle(nGroupCol[aRowEntry.nGroupNo], aRowEntry.nDestRow, 
pStyle);
             }

Reply via email to