Look at this string, same problem applies to the similar "Last %1" string: #. a day of the week, eg "Monday" (but translated). Refers to the soonest such day that has not already happened. #: lib/util/kformatprivate.cpp:389 #, qt-format msgctxt "KFormat|" msgid "Next %1" "%1" here is a placeholder for day of week (Monday, etc). I cannot translate this into Russian properly because the adjectives in Russian have genders and follow the gender of the noun it belongs to. So does the adjective "next" here - it should follow the grammatical gender of the particular day of week. But the form of translation of "next" cannot be changed because there is only one translatable string. With KI18n one could differentiate translations by genders/etc of %1 using translation scripting (Transcript), but the Qt translation system does not provide any similarly powerful features. Reproducible: Always
Chusslove, any advice for me on this? Is there an equivalent to Transcript with Qt5?
Nah, no such thing. Not possible to unpuzzle, since day names come from outside kcoreaddons. Must go for "least bad" translation.
Well... on the other hand, duplicating seven day name translations times two messages might not be too bad solution :)
(In reply to comment #3) > Well... on the other hand, duplicating seven day name translations times two > messages might not be too bad solution :) Perhaps, but it sounds like there would still need to be some way to decide which gendered day name translation to use, which we can't figure out from the KFormat API alone, as in this case the API simply passes a date or date-time and a "long" or "short" format type to return a translated relative date.
Hi Michael, Excuse me, I did not get your point. KFormatPrivate::formatRelativeDate() gets enough information to decide what should be translated. The code is going to look like this: switch (date.dayOfWeek()) { case Qt::Monday: return tr("Next %1", "for Monday"); case Qt::Tuesday: return tr("Next %1", "for Tuesday"); [...] }
Forgot to add .arg(...), but I guess the coding idea was already clear.
Sorry, I thought you meant it was necessary to know the gender of other words in the sentence, not of the day itself. If this can be done just by using a different i18n string for each day of the week then that would be simple enough.
Created attachment 86789 [details] Splits next/last day strings into a different context for each day of the week Would something like this work in order to allow these strings to be properly translated? The tests still pass, code still builds with this patch.
Ping? I'd like to know if this is workable for the translators before I commit. Is this still an issue?
Sorry for late response. The patch you have suggested makes things better, but I've just realized we need no "%1" in those messages, i.e. "Last %1"/"where day is Monday") can be changed to "Last Monday" which would be 1. Easier for translators to get the sense for this message. 2. Add more flexibility as you can put "Monday" in the necessary form (if needed) in this particular message. For example, in Russian the week day names are not capitalized, e.g. "Monday" is "понедельник", not "Понедельник". And I'm afraid dayName() might return a capitalized name.
Ping. Shall I do a review request myself?
Oops, tr("Last Monday") won't work as expected when format == ShortFormat. The output "Last Mon" is expected in this case, and thus the autotests break. I don't see no reason for showing a string like "Last Mon" in the UI, but we probably can't break the API by changing "Last Mon" to "Last Monday".
Git commit aeff11101f8513209f52aabfa72ee8b9349b915f by Michael Pyne. Committed on 17/01/2017 at 01:45. Pushed by mpyne into branch 'master'. kformat: Make it possible to properly translate relative dates. KFormat::formatRelativeDate allows one to obtain a human-readable date like "Last Wednesday" or "Next Thursday" for dates within a week of the current date. The returned string cannot be properly translated in all languages since it's generated using a placeholder of the form "Next %1" -- the word Next (or Last) may itself need to be modified to be correct which can't be done with the current translation system. The fix is just to return "Next $dayName" directly, based on the day name as appropriate, and allow the translators to translate the entire phrase. The auto tests are adjusted as well. They were actually incorrect before this change, since the API documentation for formatRelativeDate makes clear that the date format is only applied if the date is *not* within a week of the current date. FIXED-IN:5.31 Differential Revision: https://phabricator.kde.org/D4023 M +10 -4 autotests/kformattest.cpp M +38 -10 src/lib/util/kformatprivate.cpp https://commits.kde.org/kcoreaddons/aeff11101f8513209f52aabfa72ee8b9349b915f