created
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
vendor
|
37
composer.json
Normal file
37
composer.json
Normal 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
20
composer.lock
generated
Normal 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"
|
||||
}
|
63
mirzaev/languages/system/language.php
Normal file
63
mirzaev/languages/system/language.php
Normal 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 => '🇷🇺'
|
||||
};
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user