From 82bf562c34204d585df67594feab844cf9b599a1 Mon Sep 17 00:00:00 2001 From: Lasse Liehu Date: Fri, 10 Apr 2015 02:53:05 +0300 Subject: [PATCH] Enable translation scripting for date groups This allows to work around limitations in Qt's date formatting. Examples: * Uppercasing the first character in a string because it's a title: Day of the week and month names returned by QDateTime::toString are usually lowercase. * Correcting the noun case of a month name from "of [month]" to "in [month]" in Finnish: "of [month]" is correct when talking about a specific day, but wrong when talking about a specific month. REVIEW: 123278 --- src/kitemviews/kfileitemmodel.cpp | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/kitemviews/kfileitemmodel.cpp b/src/kitemviews/kfileitemmodel.cpp index 705b325b6..5f6fed0dc 100644 --- a/src/kitemviews/kfileitemmodel.cpp +++ b/src/kitemviews/kfileitemmodel.cpp @@ -1943,7 +1943,9 @@ QList > KFileItemModel::dateRoleGroups() const case 1: newGroupValue = i18nc("@title:group Date", "Yesterday"); break; default: newGroupValue = modifiedTime.toString( - i18nc("@title:group The week day name: dddd", "dddd")); + i18nc("@title:group Date: The week day name: dddd", "dddd")); + newGroupValue = i18nc("Can be used to script translation of \"dddd\"" + "with context @title:group Date", "%1", newGroupValue); } break; case 1: @@ -1971,32 +1973,53 @@ QList > KFileItemModel::dateRoleGroups() const newGroupValue = modifiedTime.toString(i18nc("@title:group Date: " "MMMM is full month name in current locale, and yyyy is " "full year number", "'Yesterday' (MMMM, yyyy)")); + newGroupValue = i18nc("Can be used to script translation of " + "\"'Yesterday' (MMMM, yyyy)\" with context @title:group Date", + "%1", newGroupValue); } else if (daysDistance <= 7) { - newGroupValue = modifiedTime.toString(i18nc("@title:group " + newGroupValue = modifiedTime.toString(i18nc("@title:group Date: " "The week day name: dddd, MMMM is full month name " "in current locale, and yyyy is full year number", "dddd (MMMM, yyyy)")); + newGroupValue = i18nc("Can be used to script translation of " + "\"dddd (MMMM, yyyy)\" with context @title:group Date", + "%1", newGroupValue); } else if (daysDistance <= 7 * 2) { newGroupValue = modifiedTime.toString(i18nc("@title:group Date: " "MMMM is full month name in current locale, and yyyy is " "full year number", "'One Week Ago' (MMMM, yyyy)")); + newGroupValue = i18nc("Can be used to script translation of " + "\"'One Week Ago' (MMMM, yyyy)\" with context @title:group Date", + "%1", newGroupValue); } else if (daysDistance <= 7 * 3) { newGroupValue = modifiedTime.toString(i18nc("@title:group Date: " "MMMM is full month name in current locale, and yyyy is " "full year number", "'Two Weeks Ago' (MMMM, yyyy)")); + newGroupValue = i18nc("Can be used to script translation of " + "\"'Two Weeks Ago' (MMMM, yyyy)\" with context @title:group Date", + "%1", newGroupValue); } else if (daysDistance <= 7 * 4) { newGroupValue = modifiedTime.toString(i18nc("@title:group Date: " "MMMM is full month name in current locale, and yyyy is " "full year number", "'Three Weeks Ago' (MMMM, yyyy)")); + newGroupValue = i18nc("Can be used to script translation of " + "\"'Three Weeks Ago' (MMMM, yyyy)\" with context @title:group Date", + "%1", newGroupValue); } else { newGroupValue = modifiedTime.toString(i18nc("@title:group Date: " "MMMM is full month name in current locale, and yyyy is " "full year number", "'Earlier on' MMMM, yyyy")); + newGroupValue = i18nc("Can be used to script translation of " + "\"'Earlier on' MMMM, yyyy\" with context @title:group Date", + "%1", newGroupValue); } } else { newGroupValue = modifiedTime.toString(i18nc("@title:group " "The month and year: MMMM is full month name in current locale, " "and yyyy is full year number", "MMMM, yyyy")); + newGroupValue = i18nc("Can be used to script translation of " + "\"MMMM, yyyy\" with context @title:group Date", + "%1", newGroupValue); } } -- 2.47.3