diff options
author | Stefan Giehl <stefan@matomo.org> | 2021-09-01 11:00:26 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-01 11:00:26 +0300 |
commit | ba1facfd1ecb4e618f3162aedbdb3170e9461e50 (patch) | |
tree | e9a1b4561753c0b46608fb9280addd9623f03d5f /plugins/Intl | |
parent | fb9a8736b0d4fcd6cedcd7df9a3a6eae6c3d3f5f (diff) |
Prepares Weblate migration (#17927)
* Add translation stats to readme
* improve generate-intl command
* update readme
* remove translation workflow
* allow empty translation files
* Adds internal parameter to ignore config in LanguageManager API
* ignore missing translators
* extend commands to ignore language info
* Update lang/README.md
Co-authored-by: Lukas Winkler <git@lw1.at>
* Update commands to use Weblate instead of Transifex API
* Replace remaining Transifex occurences
* submodule updates
* fix/update tests
Co-authored-by: Lukas Winkler <git@lw1.at>
Diffstat (limited to 'plugins/Intl')
-rw-r--r-- | plugins/Intl/Commands/GenerateIntl.php | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/plugins/Intl/Commands/GenerateIntl.php b/plugins/Intl/Commands/GenerateIntl.php index 207029f9ca..af7ad7903d 100644 --- a/plugins/Intl/Commands/GenerateIntl.php +++ b/plugins/Intl/Commands/GenerateIntl.php @@ -314,6 +314,10 @@ class GenerateIntl extends ConsoleCommand $territoryData = json_decode($territoryData, true); $territoryData = $territoryData['main'][$requestLangCode]['localeDisplayNames']['territories']; + if (empty($territoryData)) { + throw new \Exception(); + } + foreach ($countryCodes AS $code) { if (!empty($territoryData[$code]) && $territoryData[$code] != $code) { $translations['Intl']['Country_' . $code] = $this->transform($territoryData[$code]); @@ -341,6 +345,10 @@ class GenerateIntl extends ConsoleCommand $calendarData = json_decode($calendarData, true); $calendarData = $calendarData['main'][$requestLangCode]['dates']['calendars']['gregorian']; + if (empty($calendarData)) { + throw new \Exception(); + } + for ($i = 1; $i <= 12; $i++) { $translations['Intl']['Month_Short_' . $i] = $calendarData['months']['format']['abbreviated'][$i]; $translations['Intl']['Month_Long_' . $i] = $calendarData['months']['format']['wide'][$i]; @@ -413,6 +421,10 @@ class GenerateIntl extends ConsoleCommand $dateFieldData = json_decode($dateFieldData, true); $dateFieldData = $dateFieldData['main'][$requestLangCode]['dates']['fields']; + if (empty($dateFieldData)) { + throw new \Exception(); + } + $translations['Intl']['PeriodWeek'] = $dateFieldData['week']['displayName']; $translations['Intl']['PeriodYear'] = $dateFieldData['year']['displayName']; $translations['Intl']['PeriodDay'] = $dateFieldData['day']['displayName']; @@ -436,6 +448,10 @@ class GenerateIntl extends ConsoleCommand $timeZoneData = json_decode($timeZoneData, true); $timeZoneData = $timeZoneData['main'][$requestLangCode]['dates']['timeZoneNames']; + if (empty($timeZoneData)) { + throw new \Exception(); + } + $cities = array(); foreach ($timeZoneData['zone'] as $key1 => $level1) { foreach ($level1 as $key2 => $level2) { @@ -495,6 +511,10 @@ class GenerateIntl extends ConsoleCommand $unitsData = json_decode($unitsData, true); $unitsData = $unitsData['main'][$requestLangCode]['numbers']; + if (empty($unitsData)) { + throw new \Exception(); + } + $numberingSystem = $unitsData['defaultNumberingSystem']; $translations['Intl']['NumberSymbolDecimal'] = $unitsData['symbols-numberSystem-' . $numberingSystem]['decimal']; @@ -521,6 +541,10 @@ class GenerateIntl extends ConsoleCommand $unitsData = json_decode($unitsData, true); $unitsData = $unitsData['main'][$requestLangCode]['units']; + if (empty($unitsData)) { + throw new \Exception(); + } + $translations['Intl']['NSeconds'] = $this->replacePlaceHolder($unitsData['long']['duration-second']['unitPattern-count-other']); $translations['Intl']['NSecondsShort'] = $this->replacePlaceHolder($unitsData['narrow']['duration-second']['unitPattern-count-other']); $translations['Intl']['Seconds'] = $unitsData['long']['duration-second']['displayName']; @@ -575,6 +599,10 @@ class GenerateIntl extends ConsoleCommand $currencyData = json_decode($currencyData, true); $currencyData = $currencyData['main'][$requestLangCode]['numbers']['currencies']; + if (empty($currencyData)) { + throw new \Exception(); + } + $dataProvider = StaticContainer::get('Piwik\Intl\Data\Provider\CurrencyDataProvider'); foreach ($dataProvider->getCurrencyList() as $code => $currency) { if (isset($currencyData[$code]['displayName'])) { |