Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | n/a |
0 / 0 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
|||
| 1 | <?php |
| 2 | /** |
| 3 | * ILocalizer.php |
| 4 | * |
| 5 | * This file is part of the Codex design system, the official design system |
| 6 | * for Wikimedia projects. It defines the `ILocalizer` interface, which |
| 7 | * standardizes the localization method for retrieving translated messages |
| 8 | * within the Codex design system. Implementations of this interface provide |
| 9 | * localized messages from various environments, such as MediaWiki and Intuition. |
| 10 | * |
| 11 | * By defining this interface, Codex components gain flexibility in message |
| 12 | * localization, allowing the system to select the appropriate localization |
| 13 | * service at runtime. |
| 14 | * |
| 15 | * @category Contract |
| 16 | * @package Codex\Contract |
| 17 | * @since 0.1.0 |
| 18 | * @author Doğu Abaris <abaris@null.net> |
| 19 | * @license https://www.gnu.org/copyleft/gpl.html GPL-2.0-or-later |
| 20 | * @link https://doc.wikimedia.org/codex/main/ Codex Documentation |
| 21 | */ |
| 22 | |
| 23 | namespace Wikimedia\Codex\Contract; |
| 24 | |
| 25 | /** |
| 26 | * Interface for localization services in Codex. |
| 27 | * |
| 28 | * The `ILocalizer` interface defines the method required for retrieving localized |
| 29 | * messages. Implementations of this interface enable message localization in |
| 30 | * different environments, ensuring flexibility and consistency in translations |
| 31 | * across Codex components. |
| 32 | * |
| 33 | * @category Contract |
| 34 | * @package Codex\Contract |
| 35 | * @since 0.1.0 |
| 36 | * @author Doğu Abaris <abaris@null.net> |
| 37 | * @license https://www.gnu.org/copyleft/gpl.html GPL-2.0-or-later |
| 38 | * @link https://doc.wikimedia.org/codex/main/ Codex Documentation |
| 39 | */ |
| 40 | interface ILocalizer { |
| 41 | |
| 42 | /** |
| 43 | * Retrieve a localized message. |
| 44 | * |
| 45 | * This method fetches a translated message based on a message key. |
| 46 | * Optional parameters can be included for placeholder replacements in the message. |
| 47 | * |
| 48 | * @since 0.1.0 |
| 49 | * @param string $key The message key. |
| 50 | * @param string ...$params Optional parameters for placeholders in the message. |
| 51 | * @return string The localized message. |
| 52 | */ |
| 53 | public function msg( string $key, ...$params ): string; |
| 54 | } |