Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev/translation#71 getFullMonthNames: do not rely on the OS for translation #21157

Merged
merged 1 commit into from
Sep 4, 2021

Conversation

mlutfy
Copy link
Member

@mlutfy mlutfy commented Aug 16, 2021

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 date is always uses English month and day names regardless of the interface language. How do I fix this?"

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 correct xx_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 of strftime.

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.

image

@civibot
Copy link

civibot bot commented Aug 16, 2021

(Standard links)

@civibot civibot bot added the master label Aug 16, 2021
@demeritcowboy
Copy link
Contributor

There's a couple weird things in the surrounding code but focusing on the important part: How is He-Man translated in other languages? Looks like "Musclor" in French, which unfortunately loses something in translation. But matches up with Skeletor, except Skeletor has muscles too. Wild.

I might suggest though at least switching the function to use Civi::statics instead of the static keyword which doesn't play as nice with unit tests.

@mlutfy
Copy link
Member Author

mlutfy commented Sep 4, 2021

Good point, updated to use a static.

til: Musclor, scary...I'm only a fan because of old queer memes ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants