Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
[ci skip] [skip ci]
  • Loading branch information
askvortsov1 authored and StyleCIBot committed Apr 5, 2021
1 parent 45b188e commit d7db6d5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/Extend/Locales.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function (LocaleManager $locales) {

$intlIcu = false;
$locale = $file->getBasename(".$extension");

if (strpos($file->getPathname(), MessageCatalogueInterface::INTL_DOMAIN_SUFFIX) !== false) {
$intlIcu = true;
// Ignore ICU MessageFormat suffixes.
Expand Down
2 changes: 1 addition & 1 deletion src/Locale/LocaleManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function addTranslations(string $locale, $file, string $module = null, bo
$domain = null;

if ($intlIcu) {
$domain = 'messages'. MessageCatalogueInterface::INTL_DOMAIN_SUFFIX;
$domain = 'messages'.MessageCatalogueInterface::INTL_DOMAIN_SUFFIX;
}

$this->translator->addResource('prefixed_yaml', compact('file', 'prefix'), $locale, $domain);
Expand Down
15 changes: 7 additions & 8 deletions tests/integration/extenders/LocalesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function custom_translation_exists_if_added()
$this->extend(
(new Extend\Locales(dirname(__FILE__, 3).'/fixtures/locales'))
);

$this->app()->getContainer()->make('flarum.locales');
$translator = $this->app()->getContainer()->make(Translator::class);

Expand All @@ -57,7 +57,7 @@ public function custom_translation_exists_if_added()
public function custom_translation_exists_if_added_via_intl_file()
{
$this->extend(
(new Extend\Locales(dirname(__FILE__, 3) . '/fixtures/locales'))
(new Extend\Locales(dirname(__FILE__, 3).'/fixtures/locales'))
);

$this->app()->getContainer()->make('flarum.locales');
Expand All @@ -66,20 +66,19 @@ public function custom_translation_exists_if_added_via_intl_file()
$this->assertEquals('World-intl ACME', $translator->trans('test.hello-intl', ['name' => 'ACME']));
}


/**
* @test
*/
public function messageformat_doesnt_work_in_regular_file()
{
$this->extend(
(new Extend\Locales(dirname(__FILE__, 3) . '/fixtures/locales'))
(new Extend\Locales(dirname(__FILE__, 3).'/fixtures/locales'))
);

$this->app()->getContainer()->make('flarum.locales');
$translator = $this->app()->getContainer()->make(Translator::class);

$templateStringWithVars = "{female, select,
$templateStringWithVars = '{female, select,
female {{2, plural, offset:1
=0 {{ACME} does not give a party.}
=1 {{ACME} invites {ACME2} to her party.}
Expand All @@ -98,7 +97,7 @@ public function messageformat_doesnt_work_in_regular_file()
=2 {{ACME} invites {ACME2} and one other person to their party.}
other {{ACME} invites {ACME2} and # other people to their party.}
}}
}";
}';
$this->assertEquals($templateStringWithVars, $translator->trans('test.party-invitation', ['gender_of_host' => 'female', 'host' => 'ACME', 'num_guests' => 2, 'guest' => 'ACME2']));
}

Expand All @@ -108,7 +107,7 @@ public function messageformat_doesnt_work_in_regular_file()
public function messageformat_works_in_intl_icu_file()
{
$this->extend(
(new Extend\Locales(dirname(__FILE__, 3) . '/fixtures/locales'))
(new Extend\Locales(dirname(__FILE__, 3).'/fixtures/locales'))
);

$this->app()->getContainer()->make('flarum.locales');
Expand All @@ -123,7 +122,7 @@ public function messageformat_works_in_intl_icu_file()
public function laravel_interface_methods_work()
{
$this->extend(
(new Extend\Locales(dirname(__FILE__, 3) . '/fixtures/locales'))
(new Extend\Locales(dirname(__FILE__, 3).'/fixtures/locales'))
);

$this->app()->getContainer()->make('flarum.locales');
Expand Down

0 comments on commit d7db6d5

Please sign in to comment.