-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2740 from briannesbitt/fix/sr-pluralization
Fix Serbian pluralization
- Loading branch information
Showing
23 changed files
with
290 additions
and
111 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
lazy/Carbon/MessageFormatter/MessageFormatterMapperStrongType.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Carbon package. | ||
* | ||
* (c) Brian Nesbitt <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Carbon\MessageFormatter; | ||
|
||
use Symfony\Component\Translation\Formatter\MessageFormatterInterface; | ||
|
||
if (!class_exists(LazyMessageFormatter::class, false)) { | ||
abstract class LazyMessageFormatter implements MessageFormatterInterface | ||
{ | ||
public function format(string $message, string $locale, array $parameters = []): string | ||
{ | ||
return $this->formatter->format( | ||
$message, | ||
$this->transformLocale($locale), | ||
$parameters | ||
); | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
lazy/Carbon/MessageFormatter/MessageFormatterMapperWeakType.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Carbon package. | ||
* | ||
* (c) Brian Nesbitt <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Carbon\MessageFormatter; | ||
|
||
use Symfony\Component\Translation\Formatter\ChoiceMessageFormatterInterface; | ||
use Symfony\Component\Translation\Formatter\MessageFormatterInterface; | ||
|
||
if (!class_exists(LazyMessageFormatter::class, false)) { | ||
abstract class LazyMessageFormatter implements MessageFormatterInterface, ChoiceMessageFormatterInterface | ||
{ | ||
abstract protected function transformLocale(?string $locale): ?string; | ||
|
||
public function format($message, $locale, array $parameters = []) | ||
{ | ||
return $this->formatter->format( | ||
$message, | ||
$this->transformLocale($locale), | ||
$parameters | ||
); | ||
} | ||
|
||
public function choiceFormat($message, $number, $locale, array $parameters = []) | ||
{ | ||
return $this->formatter->choiceFormat($message, $number, $locale, $parameters); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Carbon package. | ||
* | ||
* (c) Brian Nesbitt <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Carbon\MessageFormatter; | ||
|
||
use ReflectionMethod; | ||
use Symfony\Component\Translation\Formatter\MessageFormatter; | ||
use Symfony\Component\Translation\Formatter\MessageFormatterInterface; | ||
|
||
$transMethod = new ReflectionMethod(MessageFormatterInterface::class, 'format'); | ||
|
||
require $transMethod->getParameters()[0]->hasType() | ||
? __DIR__.'/../../../lazy/Carbon/MessageFormatter/MessageFormatterMapperStrongType.php' | ||
: __DIR__.'/../../../lazy/Carbon/MessageFormatter/MessageFormatterMapperWeakType.php'; | ||
|
||
final class MessageFormatterMapper extends LazyMessageFormatter | ||
{ | ||
/** | ||
* Wrapped formatter. | ||
* | ||
* @var MessageFormatterInterface | ||
*/ | ||
protected $formatter; | ||
|
||
public function __construct(?MessageFormatterInterface $formatter = null) | ||
{ | ||
$this->formatter = $formatter ?? new MessageFormatter(); | ||
} | ||
|
||
protected function transformLocale(?string $locale): ?string | ||
{ | ||
return $locale ? preg_replace('/[_@][A-Za-z][a-z]{2,}/', '', $locale) : $locale; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.