Skip to content

Commit

Permalink
Merge pull request #89 from ProfessionalWiki/capitalization
Browse files Browse the repository at this point in the history
Remove forced capitalization and match TWN changes
  • Loading branch information
JeroenDeDauw authored Jan 17, 2023
2 parents 5492604 + aa13b00 commit d435254
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 26 deletions.
10 changes: 5 additions & 5 deletions src/EdtfFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use EDTF\PackagePrivate\Humanizer\InternationalizedHumanizer;
use EDTF\PackagePrivate\Humanizer\PrivateStructuredHumanizer;
use EDTF\PackagePrivate\Humanizer\Strategy\EnglishStrategy;
use EDTF\PackagePrivate\Humanizer\Strategy\FrenchStrategy;
use EDTF\PackagePrivate\Humanizer\Strategy\DefaultStrategy;
use EDTF\PackagePrivate\Humanizer\Strategy\LanguageStrategy;
use EDTF\PackagePrivate\SaneParser;
use EDTF\PackagePrivate\Validator;
Expand Down Expand Up @@ -73,10 +73,10 @@ private static function newMessageBuilder(

private static function getLanguageStrategy( string $languageCode ): LanguageStrategy {
switch ( $languageCode ) {
case "fr":
return new FrenchStrategy();
case 'en':
return new EnglishStrategy();
default:
return new DefaultStrategy();
}

return new EnglishStrategy();
}
}
3 changes: 0 additions & 3 deletions src/PackagePrivate/Humanizer/InternationalizedHumanizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,6 @@ private function humanizeDateWithoutUncertainty( ExtDate $date ): string {

if ( $month !== null ) {
$month = $this->message( self::MONTH_MAP[$month] );
if ( $day === null ) {
$month = ucfirst( $month );
}
}

if ( $day !== null ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace EDTF\PackagePrivate\Humanizer\Strategy;

class FrenchStrategy implements LanguageStrategy {
class DefaultStrategy implements LanguageStrategy {

public function applyOrdinalEnding( int $number ): string {
return $number === 1 ? $number . 'er' : (string)$number;
return (string)$number;
}

public function monthUppercaseFirst(): bool {
Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/EdtfFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function testHumanizationEnglish(): void {

public function testHumanizationFrench(): void {
$this->assertSame(
'Printemps 2021',
'printemps 2021',
EdtfFactory::newHumanizerForLanguage( 'fr' )->humanize( new Season( 2021, 21 ) )
);
}
Expand Down
30 changes: 15 additions & 15 deletions tests/Functional/FrenchHumanizationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,31 @@
* @covers \EDTF\PackagePrivate\Parser\Parser
* @covers \EDTF\Model\Interval
* @covers \EDTF\Model\IntervalSide
* @covers \EDTF\PackagePrivate\Humanizer\Strategy\FrenchStrategy
* @covers \EDTF\PackagePrivate\Humanizer\Strategy\DefaultStrategy
*/
class FrenchHumanizationTest extends TestCase {

public function humanizationProvider(): Generator {
yield 'Interval year and month' => [ '2019-01/2021-02', 'De janvier 2019 à février 2021' ];
yield 'Interval year and month' => [ '2019-01/2021-02', 'du janvier 2019 au février 2021' ];
yield 'Full date' => [ '1975-07-10', '10 juillet 1975' ];
yield 'Full date first day' => [ '1975-07-01', '1er juillet 1975' ];
yield 'Year and month' => [ '1975-07', 'Juillet 1975' ];
yield 'Year and month' => [ '1975-07', 'juillet 1975' ];
yield 'Year only' => [ '1975', '1975' ];
yield 'Leading zeroes' => [ '0042', 'Année 42' ];
yield 'Leading zeroes' => [ '0042', 'année 42' ];

yield 'Interval with open end' => [ '2019/..', 'Depuis 2019 (fin indéterminée)' ];
yield 'Interval with open start' => [ '../2021', 'Jusqu’à 2021' ];
yield 'Interval with unknown end' => [ '2019/', 'Depuis 2019 jusqu’à une fin inconnue' ];
yield 'Interval with unknown start' => [ '/2021', 'Depuis un début inconnu jusqu’à 2021' ];
yield 'Interval with open end' => [ '2019/..', 'depuis le 2019 (fin indéterminée)' ];
yield 'Interval with open start' => [ '../2021', '2021 ou antérieur' ];
yield 'Interval with unknown end' => [ '2019/', 'depuis le 2019 jusqu’à une date inconnue' ];
yield 'Interval with unknown start' => [ '/2021', 'depuis une date inconnue jusqu’àu 2021' ];

yield 'Year approximate' => [ '2019~', 'Autour du 2019' ];
yield 'Year uncertain' => [ '2019?', '2019 (incertain)' ];
yield 'Year uncertain approximation' => [ '2019%', 'Autour du 2019 (incertain)' ];
yield 'Year approximate' => [ '2019~', 'autour du 2019 (date approximative)' ];
yield 'Year uncertain' => [ '2019?', '2019 (date incertaine)' ];
yield 'Year uncertain approximation' => [ '2019%', 'autour du 2019 (date incertaine et approximative)' ];

yield 'Month approximate' => [ '2019-04~', 'Autour du Avril 2019' ];
yield 'Month uncertain' => [ '2019-04?', 'Avril 2019 (incertain)' ];
yield 'Day approximate' => [ '2019-04-01~', 'Autour du 1er avril 2019' ];
yield 'Day uncertain' => [ '2019-04-01?', '1er avril 2019 (incertain)' ];
yield 'Month approximate' => [ '2019-04~', 'autour du avril 2019 (date approximative)' ];
yield 'Month uncertain' => [ '2019-04?', 'avril 2019 (date incertaine)' ];
yield 'Day approximate' => [ '2019-04-01~', 'autour du 1er avril 2019 (date approximative)' ];
yield 'Day uncertain' => [ '2019-04-01?', '1er avril 2019 (date incertaine)' ];

yield 'Time with UTC' => [ '1985-04-12T23:20:30Z', '23:20:30 UTC 12 avril 1985' ];
yield 'Time with local time' => [ '1985-04-12T23:20:30', '23:20:30 (heure locale) 12 avril 1985' ];
Expand Down

0 comments on commit d435254

Please sign in to comment.