dev/translation#71 getFullMonthNames: do not rely on the OS for translation #21157
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
https://lab.civicrm.org/dev/translation/-/issues/71
Overview
This kind of question comes up from time to time:
https://civicrm.stackexchange.com/questions/35468/date-in-english-even-when-page-is-set-to-french/40170
The main issue is because currently translating the month name relies on the operating system. The non-English locale must be enabled so that strftime outputs the correct month name (ex: "janvier" not "January").
Most people somewhat control their hosting environment, and can enable it once they know how, but since the default CiviCRM date format uses %B (full month name), it gives a bad first impression. Considering we already have those strings in Transifex, it would be easy to just hardcode the list of months and translate using 'ts'.
Before
Month names are not translated unless a root does
dpkg-reconfigure locales
and enables the correctxx_YY.utf8
and then restarts fpm or apache. Or a few hours of fiddling on Docker images.After
Month names are translated out of the box.
Technical Details
Relies on Transifex translations (using
ts
) instead ofstrftime
.Comments
I did not bother for now with month abbreviations and other names in
CRM_Utils_Date
, because they are not used out of the box and would require adding more strings to Transifex.