From c58dc95f7de517b35e478edd8bcc7cd318d38838 Mon Sep 17 00:00:00 2001 From: mirzaev Date: Thu, 21 Aug 2025 21:41:44 +0700 Subject: [PATCH] created --- .gitignore | 1 + composer.json | 37 ++++++++++++++++ composer.lock | 20 +++++++++ mirzaev/languages/system/language.php | 63 +++++++++++++++++++++++++++ 4 files changed, 121 insertions(+) create mode 100644 .gitignore create mode 100644 composer.json create mode 100644 composer.lock create mode 100644 mirzaev/languages/system/language.php diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..22d0d82 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +vendor diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..bcfb69c --- /dev/null +++ b/composer.json @@ -0,0 +1,37 @@ +{ + "name": "mirzaev/languages", + "description": "Languages support", + "homepage": "https://git.svoboda.works/mirzaev/languages", + "type": "library", + "keywords": [ + "enumeration", + "languages" + ], + "readme": "README.md", + "license": "WTFPL", + "authors": [ + { + "name": "Arsen Mirzaev Tatyano-Muradovich", + "email": "arsen@mirzaev.sexy", + "homepage": "https://mirzaev.sexy", + "role": "Creator" + } + ], + "support": { + "wiki": "https://git.svoboda.works/mirzaev/languages/wiki", + "issues": "https://git.svoboda.works/mirzaev/languages/issues" + }, + "require": { + "php": "^8.4" + }, + "autoload": { + "psr-4": { + "mirzaev\\languages\\": "mirzaev/languages/system" + } + }, + "autoload-dev": { + "psr-4": { + "mirzaev\\languages\\tests\\": "mirzaev/languages/tests" + } + } +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..43c151a --- /dev/null +++ b/composer.lock @@ -0,0 +1,20 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "6c93952baea5752a7ec5189c3065066e", + "packages": [], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": {}, + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": "^8.4" + }, + "platform-dev": {}, + "plugin-api-version": "2.6.0" +} diff --git a/mirzaev/languages/system/language.php b/mirzaev/languages/system/language.php new file mode 100644 index 0000000..047f964 --- /dev/null +++ b/mirzaev/languages/system/language.php @@ -0,0 +1,63 @@ + + */ +enum language +{ + case en; + case ru; + + /** + * Label + * + * Initialize label of the language + * + * @param language|null language Language into which to translate + * + * @return string Translated label of the language + */ + public function label(?language $language = language::en): string + { + // Exit (success) + return match ($this) { + language::en => match ($language) { + language::en => 'English', + language::ru => 'Английский' + }, + language::ru => match ($language) { + language::en => 'Russian', + language::ru => 'Русский' + } + }; + } + + /** + * Flag + * + * Initialize the flag emoji of the language + * + * @return string The flag emoji of the language + * + * @deprecated Not supported by modern browsers + */ + public function flag(): string + { + // Exit (success) + return match ($this) { + language::en => '🇺🇸', + language::ru => '🇷🇺' + }; + } +}