This commit is contained in:
2025-08-21 21:41:44 +07:00
parent 35f70b9826
commit c58dc95f7d
4 changed files with 121 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
vendor

37
composer.json Normal file
View File

@@ -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"
}
}
}

20
composer.lock generated Normal file
View File

@@ -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"
}

View File

@@ -0,0 +1,63 @@
<?php
declare(strict_types=1);
namespace mirzaev\languages;
/**
* Language
*
* Types of languages by ISO 639-1 standart
*
* @package mirzaev\languages
*
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
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 => '🇷🇺'
};
}
}