-
-
Notifications
You must be signed in to change notification settings - Fork 824
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
CRM_Core_I18n::setLocale should change $tsLocale for getLocale() to work correctly #13050
Conversation
(Standard links)
|
d3433a2
to
65b98aa
Compare
The test fails, as expected:
I'll add another commit that should fix it. |
@mlutfy Is there a simple way for me to test this in the UI? What would I expect to see? |
Not easily. One use-case I had run into was with cdntaxreceipts, when I edited the cdntaxreceipt message template with, for example:
(this is not a great practice, an alternative is to use and then:
Normally the cdntaxreceipt extension should setLocale to fr_FR, so that it generates a receipt in French for that contact. The PDF will be in French, but the email with the text based on I was working on:
I was encountering situations where 3rd-party extensions, such as cdntaxreceipts, were generating UIs that are part English, part French. setLocale isn't used much in CiviCRM. It mostly has two use-cases: when sending mailings in another language (on multilingual sites), and for cdntaxreceipts (although it should be used in more places, but it's somewhat recent, and users have the habit of working around those limitations, such as by switching the interface language when communicating to a user in their language). setLocale would correctly switch the gettext language and db language, but by not changing the |
This is a simple change and it's well explained and makes a lot of technical sense. The global $tsLocale var seems a bit smelly but since we use it making it right makes sense. We have just cut an rc today so merging this now gives it 2 full months before release which seems good since I don't feel any testing we do is particularly meaningful. Merging |
Overview
Adds a test for getLocale/setLocale, which I suspect is not working as intended, since
setLocale
does not change thetsLocale
, butgetLocale
reads from it (it still changes the UI strings, because it changes the gettext configuration, but other things such as smarty templates checking againsttsLocale
might be confused).