(dev/core#1546) Fix translation of seed data
authorTim Otten <totten@civicrm.org>
Thu, 23 Jan 2020 03:31:17 +0000 (19:31 -0800)
committerTim Otten <totten@civicrm.org>
Thu, 23 Jan 2020 03:47:07 +0000 (19:47 -0800)
commit04f32c6f06dd1df131210be594cc6e80bf85a09b
treebff378e5f35a7b5397649c906e43fa60c7477697
parentf2b9a6fb2ba632bcb52ad763b37c38230bb56039
(dev/core#1546) Fix translation of seed data

Overview
--------

This fixes a regression in which seed data is not translated.

Before
------

The `civicrm_data.*.mysql` files are not translated.

After
-----

The `civicrm_data.*.mysql` files are translated.

There's a unit-test to check this.

Comments
--------

This regression stems from #15411, which aimed to allow extensions to define
custom variants of `ts()`.  The crux of the issue is "What happens if you
try to translate a string before the system is bootstrapped - before the
extension is loaded?  What's your fallback behavior?"

In #15411, it used a fallback behavior of "do no translation".  In theory,
you shouldn't really get into this scenario since UIs are pretty much always
generated post-boot.

However, it turns out that there is a situation where you have an un-booted
system and need to translate strings -- i.e. when generating the localized
`civicrm_data.*.mysql` data.  Hence the bug.

This patch preserves most of the changes from #15411, but it changes the
fallback behavior from "do no translation" to "use the built-in/default
translator".
CRM/Core/I18n.php
tests/phpunit/E2E/Core/LocalizedDataTest.php [new file with mode: 0644]