Skip to content

Commit

Permalink
Preserve case for CLDR month/day names (matomo-org#14015)
Browse files Browse the repository at this point in the history
Do ucfirst() on formatted date instead.
  • Loading branch information
c960657 authored and sgiehl committed Mar 2, 2019
1 parent 0e3c30b commit 17f95c2
Show file tree
Hide file tree
Showing 41 changed files with 2,933 additions and 2,927 deletions.
8 changes: 7 additions & 1 deletion core/Date.php
Expand Up @@ -10,6 +10,7 @@
namespace Piwik;

use Exception;
use Piwik\Common;
use Piwik\Container\StaticContainer;
use Piwik\Intl\Data\Provider\DateTimeFormatProvider;

Expand Down Expand Up @@ -708,9 +709,10 @@ public function subYear($n)
* The template should contain tags that will be replaced with localized date strings.
*
* @param string $template eg. `"MMM y"`
* @param bool $ucfirst whether the first letter should be upper-cased
* @return string eg. `"Aug 2009"`
*/
public function getLocalized($template)
public function getLocalized($template, $ucfirst = true)
{
$dateTimeFormatProvider = StaticContainer::get('Piwik\Intl\Data\Provider\DateTimeFormatProvider');

Expand All @@ -729,6 +731,10 @@ public function getLocalized($template)
}
}

if ($ucfirst) {
$out = Common::mb_strtoupper(mb_substr($out, 0, 1)) . mb_substr($out, 1);
}

return $out;
}

Expand Down
2 changes: 1 addition & 1 deletion core/Period.php
Expand Up @@ -366,7 +366,7 @@ protected function getTranslatedRange($format)
list($formatStart, $formatEnd) = $this->explodeFormat($format);

$string = $dateStart->getLocalized($formatStart);
$string .= $dateEnd->getLocalized($formatEnd);
$string .= $dateEnd->getLocalized($formatEnd, false);

return $string;
}
Expand Down
20 changes: 10 additions & 10 deletions plugins/Intl/Commands/GenerateIntl.php
Expand Up @@ -333,10 +333,10 @@ protected function fetchCalendarData(OutputInterface $output, $langCode, $reques
$calendarData = $calendarData['main'][$requestLangCode]['dates']['calendars']['gregorian'];

for ($i = 1; $i <= 12; $i++) {
$translations['Intl']['Month_Short_' . $i] = $this->transform($calendarData['months']['format']['abbreviated'][$i]);
$translations['Intl']['Month_Long_' . $i] = $this->transform($calendarData['months']['format']['wide'][$i]);
$translations['Intl']['Month_Short_StandAlone_' . $i] = $this->transform($calendarData['months']['stand-alone']['abbreviated'][$i]);
$translations['Intl']['Month_Long_StandAlone_' . $i] = $this->transform($calendarData['months']['stand-alone']['wide'][$i]);
$translations['Intl']['Month_Short_' . $i] = $calendarData['months']['format']['abbreviated'][$i];
$translations['Intl']['Month_Long_' . $i] = $calendarData['months']['format']['wide'][$i];
$translations['Intl']['Month_Short_StandAlone_' . $i] = $calendarData['months']['stand-alone']['abbreviated'][$i];
$translations['Intl']['Month_Long_StandAlone_' . $i] = $calendarData['months']['stand-alone']['wide'][$i];
}

$days = array(
Expand All @@ -350,12 +350,12 @@ protected function fetchCalendarData(OutputInterface $output, $langCode, $reques
);

foreach ($days AS $nr => $day) {
$translations['Intl']['Day_Min_' . $nr] = $this->transform($calendarData['days']['format']['short'][$day]);
$translations['Intl']['Day_Short_' . $nr] = $this->transform($calendarData['days']['format']['abbreviated'][$day]);
$translations['Intl']['Day_Long_' . $nr] = $this->transform($calendarData['days']['format']['wide'][$day]);
$translations['Intl']['Day_Min_StandAlone_' . $nr] = $this->transform($calendarData['days']['stand-alone']['short'][$day]);
$translations['Intl']['Day_Short_StandAlone_' . $nr] = $this->transform($calendarData['days']['stand-alone']['abbreviated'][$day]);
$translations['Intl']['Day_Long_StandAlone_' . $nr] = $this->transform($calendarData['days']['stand-alone']['wide'][$day]);
$translations['Intl']['Day_Min_' . $nr] = $calendarData['days']['format']['short'][$day];
$translations['Intl']['Day_Short_' . $nr] = $calendarData['days']['format']['abbreviated'][$day];
$translations['Intl']['Day_Long_' . $nr] = $calendarData['days']['format']['wide'][$day];
$translations['Intl']['Day_Min_StandAlone_' . $nr] = $calendarData['days']['stand-alone']['short'][$day];
$translations['Intl']['Day_Short_StandAlone_' . $nr] = $calendarData['days']['stand-alone']['abbreviated'][$day];
$translations['Intl']['Day_Long_StandAlone_' . $nr] = $calendarData['days']['stand-alone']['wide'][$day];
}

$translations['Intl']['Time_AM'] = $calendarData['dayPeriods']['format']['wide']['am'];
Expand Down
180 changes: 90 additions & 90 deletions plugins/Intl/lang/be.json
Expand Up @@ -569,48 +569,48 @@
"Currency_YER": "Еменскі рыал",
"Currency_ZAR": "Паўднёваафрыканскі ранд",
"Currency_ZMW": "Замбійская квача",
"Day_Long_1": "Панядзелак",
"Day_Long_2": "Аўторак",
"Day_Long_3": "Серада",
"Day_Long_4": "Чацвер",
"Day_Long_5": "Пятніца",
"Day_Long_6": "Субота",
"Day_Long_7": "Нядзеля",
"Day_Long_StandAlone_1": "Панядзелак",
"Day_Long_StandAlone_2": "Аўторак",
"Day_Long_StandAlone_3": "Серада",
"Day_Long_StandAlone_4": "Чацвер",
"Day_Long_StandAlone_5": "Пятніца",
"Day_Long_StandAlone_6": "Субота",
"Day_Long_StandAlone_7": "Нядзеля",
"Day_Min_1": "Пн",
"Day_Min_2": "Аў",
"Day_Min_3": "Ср",
"Day_Min_4": "Чц",
"Day_Min_5": "Пт",
"Day_Min_6": "Сб",
"Day_Min_7": "Нд",
"Day_Min_StandAlone_1": "Пн",
"Day_Min_StandAlone_2": "Аў",
"Day_Min_StandAlone_3": "Ср",
"Day_Min_StandAlone_4": "Чц",
"Day_Min_StandAlone_5": "Пт",
"Day_Min_StandAlone_6": "Сб",
"Day_Min_StandAlone_7": "Нд",
"Day_Short_1": "Пн",
"Day_Short_2": "Аў",
"Day_Short_3": "Ср",
"Day_Short_4": "Чц",
"Day_Short_5": "Пт",
"Day_Short_6": "Сб",
"Day_Short_7": "Нд",
"Day_Short_StandAlone_1": "Пн",
"Day_Short_StandAlone_2": "Аў",
"Day_Short_StandAlone_3": "Ср",
"Day_Short_StandAlone_4": "Чц",
"Day_Short_StandAlone_5": "Пт",
"Day_Short_StandAlone_6": "Сб",
"Day_Short_StandAlone_7": "Нд",
"Day_Long_1": "панядзелак",
"Day_Long_2": "аўторак",
"Day_Long_3": "серада",
"Day_Long_4": "чацвер",
"Day_Long_5": "пятніца",
"Day_Long_6": "субота",
"Day_Long_7": "нядзеля",
"Day_Long_StandAlone_1": "панядзелак",
"Day_Long_StandAlone_2": "аўторак",
"Day_Long_StandAlone_3": "серада",
"Day_Long_StandAlone_4": "чацвер",
"Day_Long_StandAlone_5": "пятніца",
"Day_Long_StandAlone_6": "субота",
"Day_Long_StandAlone_7": "нядзеля",
"Day_Min_1": "пн",
"Day_Min_2": "аў",
"Day_Min_3": "ср",
"Day_Min_4": "чц",
"Day_Min_5": "пт",
"Day_Min_6": "сб",
"Day_Min_7": "нд",
"Day_Min_StandAlone_1": "пн",
"Day_Min_StandAlone_2": "аў",
"Day_Min_StandAlone_3": "ср",
"Day_Min_StandAlone_4": "чц",
"Day_Min_StandAlone_5": "пт",
"Day_Min_StandAlone_6": "сб",
"Day_Min_StandAlone_7": "нд",
"Day_Short_1": "пн",
"Day_Short_2": "аў",
"Day_Short_3": "ср",
"Day_Short_4": "чц",
"Day_Short_5": "пт",
"Day_Short_6": "сб",
"Day_Short_7": "нд",
"Day_Short_StandAlone_1": "пн",
"Day_Short_StandAlone_2": "аў",
"Day_Short_StandAlone_3": "ср",
"Day_Short_StandAlone_4": "чц",
"Day_Short_StandAlone_5": "пт",
"Day_Short_StandAlone_6": "сб",
"Day_Short_StandAlone_7": "нд",
"EnglishLanguageName": "Belarusian",
"Format_DateTime_Long": "EEEE, d MMMM y 'г'. {time}",
"Format_DateTime_Short": "d.MM.y {time}",
Expand Down Expand Up @@ -808,54 +808,54 @@
"Language_zu": "Зулу",
"LayoutDirection": "ltr",
"Minutes": "хвіліны",
"Month_Long_1": "Студзеня",
"Month_Long_10": "Кастрычніка",
"Month_Long_11": "Лістапада",
"Month_Long_12": "Снежня",
"Month_Long_2": "Лютага",
"Month_Long_3": "Сакавіка",
"Month_Long_4": "Красавіка",
"Month_Long_5": "Мая",
"Month_Long_6": "Чэрвеня",
"Month_Long_7": "Ліпеня",
"Month_Long_8": "Жніўня",
"Month_Long_9": "Верасня",
"Month_Long_StandAlone_1": "Студзень",
"Month_Long_StandAlone_10": "Кастрычнік",
"Month_Long_StandAlone_11": "Лістапад",
"Month_Long_StandAlone_12": "Снежань",
"Month_Long_StandAlone_2": "Люты",
"Month_Long_StandAlone_3": "Сакавік",
"Month_Long_StandAlone_4": "Красавік",
"Month_Long_StandAlone_5": "Май",
"Month_Long_StandAlone_6": "Чэрвень",
"Month_Long_StandAlone_7": "Ліпень",
"Month_Long_StandAlone_8": "Жнівень",
"Month_Long_StandAlone_9": "Верасень",
"Month_Short_1": "Сту",
"Month_Short_10": "Кас",
"Month_Short_11": "Ліс",
"Month_Short_12": "Сне",
"Month_Short_2": "Лют",
"Month_Short_3": "Сак",
"Month_Short_4": "Кра",
"Month_Short_5": "Мая",
"Month_Short_6": "Чэр",
"Month_Short_7": "Ліп",
"Month_Short_8": "Жні",
"Month_Short_9": "Вер",
"Month_Short_StandAlone_1": "Сту",
"Month_Short_StandAlone_10": "Кас",
"Month_Short_StandAlone_11": "Ліс",
"Month_Short_StandAlone_12": "Сне",
"Month_Short_StandAlone_2": "Лют",
"Month_Short_StandAlone_3": "Сак",
"Month_Short_StandAlone_4": "Кра",
"Month_Short_StandAlone_5": "Май",
"Month_Short_StandAlone_6": "Чэр",
"Month_Short_StandAlone_7": "Ліп",
"Month_Short_StandAlone_8": "Жні",
"Month_Short_StandAlone_9": "Вер",
"Month_Long_1": "студзеня",
"Month_Long_10": "кастрычніка",
"Month_Long_11": "лістапада",
"Month_Long_12": "снежня",
"Month_Long_2": "лютага",
"Month_Long_3": "сакавіка",
"Month_Long_4": "красавіка",
"Month_Long_5": "мая",
"Month_Long_6": "чэрвеня",
"Month_Long_7": "ліпеня",
"Month_Long_8": "жніўня",
"Month_Long_9": "верасня",
"Month_Long_StandAlone_1": "студзень",
"Month_Long_StandAlone_10": "кастрычнік",
"Month_Long_StandAlone_11": "лістапад",
"Month_Long_StandAlone_12": "снежань",
"Month_Long_StandAlone_2": "люты",
"Month_Long_StandAlone_3": "сакавік",
"Month_Long_StandAlone_4": "красавік",
"Month_Long_StandAlone_5": "май",
"Month_Long_StandAlone_6": "чэрвень",
"Month_Long_StandAlone_7": "ліпень",
"Month_Long_StandAlone_8": "жнівень",
"Month_Long_StandAlone_9": "верасень",
"Month_Short_1": "сту",
"Month_Short_10": "кас",
"Month_Short_11": "ліс",
"Month_Short_12": "сне",
"Month_Short_2": "лют",
"Month_Short_3": "сак",
"Month_Short_4": "кра",
"Month_Short_5": "мая",
"Month_Short_6": "чэр",
"Month_Short_7": "ліп",
"Month_Short_8": "жні",
"Month_Short_9": "вер",
"Month_Short_StandAlone_1": "сту",
"Month_Short_StandAlone_10": "кас",
"Month_Short_StandAlone_11": "ліс",
"Month_Short_StandAlone_12": "сне",
"Month_Short_StandAlone_2": "лют",
"Month_Short_StandAlone_3": "сак",
"Month_Short_StandAlone_4": "кра",
"Month_Short_StandAlone_5": "май",
"Month_Short_StandAlone_6": "чэр",
"Month_Short_StandAlone_7": "ліп",
"Month_Short_StandAlone_8": "жні",
"Month_Short_StandAlone_9": "вер",
"NDays": "%s сутак",
"NHoursShort": "%s гадз",
"NMinutes": "%s хвіліны",
Expand Down

0 comments on commit 17f95c2

Please sign in to comment.