Removed html_colour function, moved renamed DateCheck to Tools and moved the country names function into it and use new callable syntax.

This commit is contained in:
flash 2023-08-31 14:55:39 +00:00
parent 0c9bac473b
commit 45500ce698
15 changed files with 362 additions and 383 deletions

View file

@ -40,10 +40,10 @@ final class ChangelogRoutes {
$this->authInfo = $authInfo;
$this->comments = $comments;
$router->get('/changelog', [$this, 'getIndex']);
$router->get('/changelog.rss', [$this, 'getFeedRSS']);
$router->get('/changelog.atom', [$this, 'getFeedAtom']);
$router->get('/changelog/change/:id', [$this, 'getChange']);
$router->get('/changelog', $this->getIndex(...));
$router->get('/changelog.rss', $this->getFeedRSS(...));
$router->get('/changelog.atom', $this->getFeedAtom(...));
$router->get('/changelog/change/:id', $this->getChange(...));
$router->get('/changelog.php', function($response, $request) {
$changeId = $request->getParam('c', FILTER_SANITIZE_NUMBER_INT);

View file

@ -1,27 +0,0 @@
<?php
namespace Misuzu;
final class DateCheck {
public static function isLeapYear(int $year): bool {
return (($year % 4) === 0 && ($year % 100) !== 0)
|| ($year % 400) === 0;
}
// i realise this implementation is probably horribly naive,
// but for what i need it will Do the Job
public static function isValidDate(int $year, int $month, int $day): bool {
if($month < 1 || $month > 12)
return false;
if($day < 1 || $day > 31)
return false;
if($month === 2)
$days = $year === 0 || self::isLeapYear($year) ? 29 : 28;
elseif($month === 4 || $month === 6 || $month === 9 || $month === 11)
$days = 30;
else
$days = 31;
return $day <= $days;
}
}

View file

@ -46,10 +46,10 @@ class HomeRoutes {
$this->news = $news;
$this->users = $users;
$router->get('/', [$this, 'getIndex']);
$router->get('/', $this->getIndex(...));
if(MSZ_DEBUG)
$router->get('/dev-landing', [$this, 'getLanding']);
$router->get('/dev-landing', $this->getLanding(...));
$router->get('/index.php', function($response) {
$response->redirect(url('index'), true);

View file

@ -17,9 +17,9 @@ class InfoRoutes {
];
public function __construct(IRouter $router) {
$router->get('/info', [$this, 'getIndex']);
$router->get('/info/:name', [$this, 'getDocsPage']);
$router->get('/info/:project/:name', [$this, 'getProjectPage']);
$router->get('/info', $this->getIndex(...));
$router->get('/info/:name', $this->getDocsPage(...));
$router->get('/info/:project/:name', $this->getProjectPage(...));
$router->get('/info.php', function($response) {
$response->redirect(url('info'), true);

View file

@ -43,11 +43,11 @@ class NewsRoutes {
$this->users = $users;
$this->comments = $comments;
$router->get('/news', [$this, 'getIndex']);
$router->get('/news.rss', [$this, 'getFeedRss']);
$router->get('/news.atom', [$this, 'getFeedAtom']);
$router->get('/news/:category', [$this, 'getCategory']);
$router->get('/news/post/:id', [$this, 'getPost']);
$router->get('/news', $this->getIndex(...));
$router->get('/news.rss', $this->getFeedRss(...));
$router->get('/news.atom', $this->getFeedAtom(...));
$router->get('/news/:category', $this->getCategory(...));
$router->get('/news/post/:id', $this->getPost(...));
$router->get('/news.php', function($response, $request) {
$postId = $request->getParam('n', FILTER_SANITIZE_NUMBER_INT)

View file

@ -49,10 +49,10 @@ final class SatoriRoutes {
});
});
$router->use('/_satori', [$this, 'verifyRequest']);
$router->get('/_satori/get-profile-field', [$this, 'getProfileField']);
$router->get('/_satori/get-recent-forum-posts', [$this, 'getRecentForumPosts']);
$router->get('/_satori/get-recent-registrations', [$this, 'getRecentRegistrations']);
$router->use('/_satori', $this->verifyRequest(...));
$router->get('/_satori/get-profile-field', $this->getProfileField(...));
$router->get('/_satori/get-recent-forum-posts', $this->getRecentForumPosts(...));
$router->get('/_satori/get-recent-registrations', $this->getRecentRegistrations(...));
}
public function verifyRequest($response, $request) {

View file

@ -67,18 +67,18 @@ final class SharpChatRoutes {
});
// Public endpoints
$router->get('/_sockchat/emotes', [$this, 'getEmotes']);
$router->get('/_sockchat/login', [$this, 'getLogin']);
$router->options('/_sockchat/token', [$this, 'getToken']);
$router->get('/_sockchat/token', [$this, 'getToken']);
$router->get('/_sockchat/emotes', $this->getEmotes(...));
$router->get('/_sockchat/login', $this->getLogin(...));
$router->options('/_sockchat/token', $this->getToken(...));
$router->get('/_sockchat/token', $this->getToken(...));
// Private endpoints
$router->post('/_sockchat/bump', [$this, 'postBump']);
$router->post('/_sockchat/verify', [$this, 'postVerify']);
$router->get('/_sockchat/bans/list', [$this, 'getBanList']);
$router->get('/_sockchat/bans/check', [$this, 'getBanCheck']);
$router->post('/_sockchat/bans/create', [$this, 'postBanCreate']);
$router->delete('/_sockchat/bans/revoke', [$this, 'deleteBanRevoke']);
$router->post('/_sockchat/bump', $this->postBump(...));
$router->post('/_sockchat/verify', $this->postVerify(...));
$router->get('/_sockchat/bans/list', $this->getBanList(...));
$router->get('/_sockchat/bans/check', $this->getBanCheck(...));
$router->post('/_sockchat/bans/create', $this->postBanCreate(...));
$router->delete('/_sockchat/bans/revoke', $this->deleteBanRevoke(...));
}
public function getEmotes($response, $request): array {

313
src/Tools.php Normal file
View file

@ -0,0 +1,313 @@
<?php
namespace Misuzu;
final class Tools {
public static function isLeapYear(int $year): bool {
return (($year % 4) === 0 && ($year % 100) !== 0)
|| ($year % 400) === 0;
}
// i realise this implementation is probably horribly naive,
// but for what i need it will Do the Job
public static function isValidDate(int $year, int $month, int $day): bool {
if($month < 1 || $month > 12)
return false;
if($day < 1 || $day > 31)
return false;
if($month === 2)
$days = $year === 0 || self::isLeapYear($year) ? 29 : 28;
elseif($month === 4 || $month === 6 || $month === 9 || $month === 11)
$days = 30;
else
$days = 31;
return $day <= $days;
}
// for your own sanity and the sanity of others, keep this one at the bottom
public static function countryName(string $code): string {
return match(strtoupper($code)) {
'AD' => 'Andorra',
'AE' => 'United Arab Emirates',
'AF' => 'Afghanistan',
'AG' => 'Antigua and Barbuda',
'AI' => 'Anguilla',
'AL' => 'Albania',
'AM' => 'Armenia',
'AO' => 'Angola',
'AQ' => 'Antarctica',
'AR' => 'Argentina',
'AS' => 'American Samoa',
'AT' => 'Austria',
'AU' => 'Australia',
'AW' => 'Aruba',
'AX' => 'Åland',
'AZ' => 'Azerbaijan',
'BA' => 'Bosnia and Herzegovina',
'BB' => 'Barbados',
'BD' => 'Bangladesh',
'BE' => 'Belgium',
'BF' => 'Burkina Faso',
'BG' => 'Bulgaria',
'BH' => 'Bahrain',
'BI' => 'Burundi',
'BJ' => 'Benin',
'BL' => 'Saint Barthélemy',
'BM' => 'Bermuda',
'BN' => 'Brunei',
'BO' => 'Bolivia',
'BQ' => 'Bonaire, Sint Eustatius and Saba',
'BR' => 'Brazil',
'BS' => 'Bahamas',
'BT' => 'Bhutan',
'BV' => 'Bouvet Island',
'BW' => 'Botswana',
'BY' => 'Belarus',
'BZ' => 'Belize',
'CA' => 'Canada',
'CC' => 'Cocos (Keeling) Islands',
'CD' => 'Democratic Republic of Congo',
'CF' => 'Central African Republic',
'CG' => 'Congo Republic',
'CH' => 'Switzerland',
'CI' => 'Ivory Coast',
'CK' => 'Cook Islands',
'CL' => 'Chile',
'CM' => 'Cameroon',
'CN' => 'China',
'CO' => 'Colombia',
'CR' => 'Costa Rica',
'CU' => 'Cuba',
'CV' => 'Cabo Verde',
'CW' => 'Curaçao',
'CX' => 'Christmas Island',
'CY' => 'Cyprus',
'CZ' => 'Czechia',
'DE' => 'Germany',
'DJ' => 'Djibouti',
'DK' => 'Denmark',
'DM' => 'Dominica',
'DO' => 'Dominican Republic',
'DZ' => 'Algeria',
'EC' => 'Ecuador',
'EE' => 'Estonia',
'EG' => 'Egypt',
'EH' => 'Western Sahara',
'ER' => 'Eritrea',
'ES' => 'Spain',
'ET' => 'Ethiopia',
'FI' => 'Finland',
'FJ' => 'Fiji',
'FK' => 'Falkland Islands',
'FM' => 'Micronesia',
'FO' => 'Faroe Islands',
'FR' => 'France',
'GA' => 'Gabon',
'GB' => 'United Kingdom',
'GD' => 'Grenada',
'GE' => 'Georgia',
'GF' => 'French Guiana',
'GG' => 'Guernsey',
'GH' => 'Ghana',
'GI' => 'Gibraltar',
'GL' => 'Greenland',
'GM' => 'The Gambia',
'GN' => 'Guinea',
'GP' => 'Guadeloupe',
'GQ' => 'Equatorial Guinea',
'GR' => 'Greece',
'GS' => 'South Georgia and South Sandwich Islands',
'GT' => 'Guatemala',
'GU' => 'Guam',
'GW' => 'Guinea-Bissau',
'GY' => 'Guyana',
'HK' => 'Hong Kong',
'HM' => 'Heard and McDonald Islands',
'HN' => 'Honduras',
'HR' => 'Croatia',
'HT' => 'Haiti',
'HU' => 'Hungary',
'ID' => 'Indonesia',
'IE' => 'Ireland',
'IL' => 'Israel',
'IM' => 'Isle of Man',
'IN' => 'India',
'IO' => 'British Indian Ocean Territory',
'IQ' => 'Iraq',
'IR' => 'Iran',
'IS' => 'Iceland',
'IT' => 'Italy',
'JE' => 'Jersey',
'JM' => 'Jamaica',
'JO' => 'Jordan',
'JP' => 'Japan',
'KE' => 'Kenya',
'KG' => 'Kyrgyzstan',
'KH' => 'Cambodia',
'KI' => 'Kiribati',
'KM' => 'Comoros',
'KN' => 'St Kitts and Nevis',
'KP' => 'North Korea',
'KR' => 'South Korea',
'KW' => 'Kuwait',
'KY' => 'Cayman Islands',
'KZ' => 'Kazakhstan',
'LA' => 'Laos',
'LB' => 'Lebanon',
'LC' => 'Saint Lucia',
'LI' => 'Liechtenstein',
'LK' => 'Sri Lanka',
'LR' => 'Liberia',
'LS' => 'Lesotho',
'LT' => 'Lithuania',
'LU' => 'Luxembourg',
'LV' => 'Latvia',
'LY' => 'Libya',
'MA' => 'Morocco',
'MC' => 'Monaco',
'MD' => 'Moldova',
'ME' => 'Montenegro',
'MF' => 'Saint Martin',
'MG' => 'Madagascar',
'MH' => 'Marshall Islands',
'MK' => 'North Macedonia',
'ML' => 'Mali',
'MM' => 'Myanmar',
'MN' => 'Mongolia',
'MO' => 'Macao',
'MP' => 'Northern Mariana Islands',
'MQ' => 'Martinique',
'MR' => 'Mauritania',
'MS' => 'Montserrat',
'MT' => 'Malta',
'MU' => 'Mauritius',
'MV' => 'Maldives',
'MW' => 'Malawi',
'MX' => 'Mexico',
'MY' => 'Malaysia',
'MZ' => 'Mozambique',
'NA' => 'Namibia',
'NC' => 'New Caledonia',
'NE' => 'Niger',
'NF' => 'Norfolk Island',
'NG' => 'Nigeria',
'NI' => 'Nicaragua',
'NL' => 'Netherlands',
'NO' => 'Norway',
'NP' => 'Nepal',
'NR' => 'Nauru',
'NU' => 'Niue',
'NZ' => 'New Zealand',
'OM' => 'Oman',
'PA' => 'Panama',
'PE' => 'Peru',
'PF' => 'French Polynesia',
'PG' => 'Papua New Guinea',
'PH' => 'Philippines',
'PK' => 'Pakistan',
'PL' => 'Poland',
'PM' => 'Saint Pierre and Miquelon',
'PN' => 'Pitcairn Islands',
'PR' => 'Puerto Rico',
'PS' => 'Palestine',
'PT' => 'Portugal',
'PW' => 'Palau',
'PY' => 'Paraguay',
'QA' => 'Qatar',
'RE' => 'Réunion',
'RO' => 'Romania',
'RS' => 'Serbia',
'RU' => 'Russia',
'RW' => 'Rwanda',
'SA' => 'Saudi Arabia',
'SB' => 'Solomon Islands',
'SC' => 'Seychelles',
'SD' => 'Sudan',
'SE' => 'Sweden',
'SG' => 'Singapore',
'SH' => 'Saint Helena',
'SI' => 'Slovenia',
'SJ' => 'Svalbard and Jan Mayen',
'SK' => 'Slovakia',
'SL' => 'Sierra Leone',
'SM' => 'San Marino',
'SN' => 'Senegal',
'SO' => 'Somalia',
'SR' => 'Suriname',
'SS' => 'South Sudan',
'ST' => 'São Tomé and Príncipe',
'SV' => 'El Salvador',
'SX' => 'Sint Maarten',
'SY' => 'Syria',
'SZ' => 'Eswatini',
'TC' => 'Turks and Caicos Islands',
'TD' => 'Chad',
'TF' => 'French Southern Territories',
'TG' => 'Togo',
'TH' => 'Thailand',
'TJ' => 'Tajikistan',
'TK' => 'Tokelau',
'TL' => 'Timor-Leste',
'TM' => 'Turkmenistan',
'TN' => 'Tunisia',
'TO' => 'Tonga',
'TR' => 'Turkey',
'TT' => 'Trinidad and Tobago',
'TV' => 'Tuvalu',
'TW' => 'Taiwan',
'TZ' => 'Tanzania',
'UA' => 'Ukraine',
'UG' => 'Uganda',
'UM' => 'U.S. Outlying Islands',
'US' => 'United States',
'UY' => 'Uruguay',
'UZ' => 'Uzbekistan',
'VA' => 'Vatican City',
'VC' => 'St Vincent and Grenadines',
'VE' => 'Venezuela',
'VG' => 'British Virgin Islands',
'VI' => 'U.S. Virgin Islands',
'VN' => 'Vietnam',
'VU' => 'Vanuatu',
'WF' => 'Wallis and Futuna',
'WS' => 'Samoa',
'XK' => 'Kosovo',
'XM' => 'The Moon',
'XS' => 'System',
'XX' => 'Unknown',
'YE' => 'Yemen',
'YT' => 'Mayotte',
'ZA' => 'South Africa',
'ZM' => 'Zambia',
'ZW' => 'Zimbabwe',
default => 'Unknown',
};
}
}

View file

@ -5,6 +5,7 @@ use Index\ByteFormat;
use Index\DateTime;
use Index\Environment;
use Misuzu\MisuzuContext;
use Misuzu\Tools;
use Misuzu\Parsers\Parser;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
@ -20,10 +21,9 @@ final class TwigMisuzu extends AbstractExtension {
public function getFilters() {
return [
new TwigFilter('html_colour', 'html_colour'),
new TwigFilter('country_name', 'get_country_name'),
new TwigFilter('country_name', Tools::countryName(...)),
new TwigFilter('parse_text', fn(string $text, int $parser): string => Parser::instance($parser)->parseText($text)),
new TwigFilter('time_format', [$this, 'timeFormat']),
new TwigFilter('time_format', $this->timeFormat(...)),
];
}
@ -31,14 +31,14 @@ final class TwigMisuzu extends AbstractExtension {
return [
new TwigFunction('url_construct', 'url_construct'),
new TwigFunction('url', 'url'),
new TwigFunction('csrf_token', fn() => CSRF::token()),
new TwigFunction('git_commit_hash', fn(bool $long = false) => GitInfo::hash($long)),
new TwigFunction('git_tag', fn() => GitInfo::tag()),
new TwigFunction('git_branch', fn() => GitInfo::branch()),
new TwigFunction('csrf_token', CSRF::token(...)),
new TwigFunction('git_commit_hash', GitInfo::hash(...)),
new TwigFunction('git_tag', GitInfo::tag(...)),
new TwigFunction('git_branch', GitInfo::branch(...)),
new TwigFunction('startup_time', fn(float $time = MSZ_STARTUP) => microtime(true) - $time),
new TwigFunction('sql_query_count', fn() => $this->ctx->getDbQueryCount()),
new TwigFunction('ndx_version', fn() => Environment::getIndexVersion()),
new TwigFunction('byte_symbol', fn($bytes, $decimal = ByteFormat::DECIMAL_DEFAULT) => ByteFormat::format($bytes, $decimal)),
new TwigFunction('sql_query_count', $this->ctx->getDbQueryCount(...)),
new TwigFunction('ndx_version', Environment::getIndexVersion(...)),
new TwigFunction('byte_symbol', ByteFormat::format(...)),
];
}

View file

@ -20,11 +20,11 @@ class AssetsRoutes {
$this->bans = $bans;
$this->users = $users;
$router->get('/assets/avatar', [$this, 'getAvatar']);
$router->get('/assets/avatar/:filename', [$this, 'getAvatar']);
$router->get('/assets/profile-background', [$this, 'getProfileBackground']);
$router->get('/assets/profile-background/:filename', [$this, 'getProfileBackground']);
$router->get('/user-assets.php', [$this, 'getUserAssets']);
$router->get('/assets/avatar', $this->getAvatar(...));
$router->get('/assets/avatar/:filename', $this->getAvatar(...));
$router->get('/assets/profile-background', $this->getProfileBackground(...));
$router->get('/assets/profile-background/:filename', $this->getProfileBackground(...));
$router->get('/user-assets.php', $this->getUserAssets(...));
}
private function canViewAsset($request, UserInfo $assetUser): bool {

View file

@ -10,8 +10,8 @@ use Index\Data\DbStatementCache;
use Index\Data\DbTools;
use Index\Data\IDbConnection;
use Index\Net\IPAddress;
use Misuzu\DateCheck;
use Misuzu\Pagination;
use Misuzu\Tools;
use Misuzu\Parsers\Parser;
class Users {
@ -695,7 +695,7 @@ class Users {
if($year > 0 && ($year < $currentYear - $yearRange || $year > $currentYear))
return 'year';
if(!DateCheck::isValidDate($year, $month, $day))
if(!Tools::isValidDate($year, $month, $day))
return 'date';
}

View file

@ -21,9 +21,8 @@
{% set id = id|default('') %}
{% endif %}
<div class="container forum__categories"
{% if colour is not null %}style="{{ colour|html_colour('--accent-colour') }}"{% endif %}
{% if id|length > 0 %}id="{{ id }}"{% endif %}>
<div class="container forum__categories" {% if id|length > 0 %}id="{{ id }}"{% endif %}
{% if colour is not null %}style="--accent-colour: {{ colour }}"{% endif %}>
{{ container_title('<span class="' ~ icon ~ '"></span> ' ~ title) }}
{% if forums|length > 0 %}

View file

@ -43,7 +43,7 @@
</div>
{% endif %}
<div class="container forum__post" style="{{ posting_post.colour|default(posting_user_colour)|html_colour('--accent-colour') }}">
<div class="container forum__post" style="--accent-colour: {{ posting_post.colour|default(posting_user_colour) }}">
<div class="forum__post__info">
<div class="forum__post__info__background"></div>
<div class="forum__post__info__content">

View file

@ -25,7 +25,7 @@
{% endif %}
</head>
<body class="main{% if site_background is defined %} {{ site_background.classNames('main--bg-%s')|join(' ') }}{% endif %}"
style="{% if global_accent_colour is defined %}{{ global_accent_colour|html_colour('--accent-colour') }}{% endif %}" id="container">
style="{% if global_accent_colour is defined %}--accent-colour: {{ global_accent_colour }}{% endif %}" id="container">
{% block main_header %}
{% include '_layout/header.twig' %}

View file

@ -1,6 +1,4 @@
<?php
use Index\Colour\Colour;
// render_error and render_info need to be nuked from orbit
function render_error(int $code, string $template = 'errors.%d'): string {
@ -19,307 +17,3 @@ function render_info(?string $message, int $httpCode, string $template = 'errors
return \Misuzu\Template::renderRaw(sprintf($template, $httpCode));
}
function html_colour(int|null|Colour $colour, $attribs = '--user-colour'): string {
$colour = (string)($colour instanceof Colour ? $colour : Colour::fromMisuzu($colour ?? 0x40000000));
if(is_string($attribs))
$attribs = [ $attribs => '%s' ];
if(!$attribs)
$attribs = [
'color' => '%s',
'--user-colour' => '%s',
];
$css = '';
foreach($attribs as $name => $format)
$css .= $name . ':' . sprintf($format, $colour) . ';';
return $css;
}
function get_country_name(string $code): string {
return match(strtoupper($code)) {
'AD' => 'Andorra',
'AE' => 'United Arab Emirates',
'AF' => 'Afghanistan',
'AG' => 'Antigua and Barbuda',
'AI' => 'Anguilla',
'AL' => 'Albania',
'AM' => 'Armenia',
'AO' => 'Angola',
'AQ' => 'Antarctica',
'AR' => 'Argentina',
'AS' => 'American Samoa',
'AT' => 'Austria',
'AU' => 'Australia',
'AW' => 'Aruba',
'AX' => 'Åland',
'AZ' => 'Azerbaijan',
'BA' => 'Bosnia and Herzegovina',
'BB' => 'Barbados',
'BD' => 'Bangladesh',
'BE' => 'Belgium',
'BF' => 'Burkina Faso',
'BG' => 'Bulgaria',
'BH' => 'Bahrain',
'BI' => 'Burundi',
'BJ' => 'Benin',
'BL' => 'Saint Barthélemy',
'BM' => 'Bermuda',
'BN' => 'Brunei',
'BO' => 'Bolivia',
'BQ' => 'Bonaire, Sint Eustatius and Saba',
'BR' => 'Brazil',
'BS' => 'Bahamas',
'BT' => 'Bhutan',
'BV' => 'Bouvet Island',
'BW' => 'Botswana',
'BY' => 'Belarus',
'BZ' => 'Belize',
'CA' => 'Canada',
'CC' => 'Cocos (Keeling) Islands',
'CD' => 'Democratic Republic of Congo',
'CF' => 'Central African Republic',
'CG' => 'Congo Republic',
'CH' => 'Switzerland',
'CI' => 'Ivory Coast',
'CK' => 'Cook Islands',
'CL' => 'Chile',
'CM' => 'Cameroon',
'CN' => 'China',
'CO' => 'Colombia',
'CR' => 'Costa Rica',
'CU' => 'Cuba',
'CV' => 'Cabo Verde',
'CW' => 'Curaçao',
'CX' => 'Christmas Island',
'CY' => 'Cyprus',
'CZ' => 'Czechia',
'DE' => 'Germany',
'DJ' => 'Djibouti',
'DK' => 'Denmark',
'DM' => 'Dominica',
'DO' => 'Dominican Republic',
'DZ' => 'Algeria',
'EC' => 'Ecuador',
'EE' => 'Estonia',
'EG' => 'Egypt',
'EH' => 'Western Sahara',
'ER' => 'Eritrea',
'ES' => 'Spain',
'ET' => 'Ethiopia',
'FI' => 'Finland',
'FJ' => 'Fiji',
'FK' => 'Falkland Islands',
'FM' => 'Micronesia',
'FO' => 'Faroe Islands',
'FR' => 'France',
'GA' => 'Gabon',
'GB' => 'United Kingdom',
'GD' => 'Grenada',
'GE' => 'Georgia',
'GF' => 'French Guiana',
'GG' => 'Guernsey',
'GH' => 'Ghana',
'GI' => 'Gibraltar',
'GL' => 'Greenland',
'GM' => 'The Gambia',
'GN' => 'Guinea',
'GP' => 'Guadeloupe',
'GQ' => 'Equatorial Guinea',
'GR' => 'Greece',
'GS' => 'South Georgia and South Sandwich Islands',
'GT' => 'Guatemala',
'GU' => 'Guam',
'GW' => 'Guinea-Bissau',
'GY' => 'Guyana',
'HK' => 'Hong Kong',
'HM' => 'Heard and McDonald Islands',
'HN' => 'Honduras',
'HR' => 'Croatia',
'HT' => 'Haiti',
'HU' => 'Hungary',
'ID' => 'Indonesia',
'IE' => 'Ireland',
'IL' => 'Israel',
'IM' => 'Isle of Man',
'IN' => 'India',
'IO' => 'British Indian Ocean Territory',
'IQ' => 'Iraq',
'IR' => 'Iran',
'IS' => 'Iceland',
'IT' => 'Italy',
'JE' => 'Jersey',
'JM' => 'Jamaica',
'JO' => 'Jordan',
'JP' => 'Japan',
'KE' => 'Kenya',
'KG' => 'Kyrgyzstan',
'KH' => 'Cambodia',
'KI' => 'Kiribati',
'KM' => 'Comoros',
'KN' => 'St Kitts and Nevis',
'KP' => 'North Korea',
'KR' => 'South Korea',
'KW' => 'Kuwait',
'KY' => 'Cayman Islands',
'KZ' => 'Kazakhstan',
'LA' => 'Laos',
'LB' => 'Lebanon',
'LC' => 'Saint Lucia',
'LI' => 'Liechtenstein',
'LK' => 'Sri Lanka',
'LR' => 'Liberia',
'LS' => 'Lesotho',
'LT' => 'Lithuania',
'LU' => 'Luxembourg',
'LV' => 'Latvia',
'LY' => 'Libya',
'MA' => 'Morocco',
'MC' => 'Monaco',
'MD' => 'Moldova',
'ME' => 'Montenegro',
'MF' => 'Saint Martin',
'MG' => 'Madagascar',
'MH' => 'Marshall Islands',
'MK' => 'North Macedonia',
'ML' => 'Mali',
'MM' => 'Myanmar',
'MN' => 'Mongolia',
'MO' => 'Macao',
'MP' => 'Northern Mariana Islands',
'MQ' => 'Martinique',
'MR' => 'Mauritania',
'MS' => 'Montserrat',
'MT' => 'Malta',
'MU' => 'Mauritius',
'MV' => 'Maldives',
'MW' => 'Malawi',
'MX' => 'Mexico',
'MY' => 'Malaysia',
'MZ' => 'Mozambique',
'NA' => 'Namibia',
'NC' => 'New Caledonia',
'NE' => 'Niger',
'NF' => 'Norfolk Island',
'NG' => 'Nigeria',
'NI' => 'Nicaragua',
'NL' => 'Netherlands',
'NO' => 'Norway',
'NP' => 'Nepal',
'NR' => 'Nauru',
'NU' => 'Niue',
'NZ' => 'New Zealand',
'OM' => 'Oman',
'PA' => 'Panama',
'PE' => 'Peru',
'PF' => 'French Polynesia',
'PG' => 'Papua New Guinea',
'PH' => 'Philippines',
'PK' => 'Pakistan',
'PL' => 'Poland',
'PM' => 'Saint Pierre and Miquelon',
'PN' => 'Pitcairn Islands',
'PR' => 'Puerto Rico',
'PS' => 'Palestine',
'PT' => 'Portugal',
'PW' => 'Palau',
'PY' => 'Paraguay',
'QA' => 'Qatar',
'RE' => 'Réunion',
'RO' => 'Romania',
'RS' => 'Serbia',
'RU' => 'Russia',
'RW' => 'Rwanda',
'SA' => 'Saudi Arabia',
'SB' => 'Solomon Islands',
'SC' => 'Seychelles',
'SD' => 'Sudan',
'SE' => 'Sweden',
'SG' => 'Singapore',
'SH' => 'Saint Helena',
'SI' => 'Slovenia',
'SJ' => 'Svalbard and Jan Mayen',
'SK' => 'Slovakia',
'SL' => 'Sierra Leone',
'SM' => 'San Marino',
'SN' => 'Senegal',
'SO' => 'Somalia',
'SR' => 'Suriname',
'SS' => 'South Sudan',
'ST' => 'São Tomé and Príncipe',
'SV' => 'El Salvador',
'SX' => 'Sint Maarten',
'SY' => 'Syria',
'SZ' => 'Eswatini',
'TC' => 'Turks and Caicos Islands',
'TD' => 'Chad',
'TF' => 'French Southern Territories',
'TG' => 'Togo',
'TH' => 'Thailand',
'TJ' => 'Tajikistan',
'TK' => 'Tokelau',
'TL' => 'Timor-Leste',
'TM' => 'Turkmenistan',
'TN' => 'Tunisia',
'TO' => 'Tonga',
'TR' => 'Turkey',
'TT' => 'Trinidad and Tobago',
'TV' => 'Tuvalu',
'TW' => 'Taiwan',
'TZ' => 'Tanzania',
'UA' => 'Ukraine',
'UG' => 'Uganda',
'UM' => 'U.S. Outlying Islands',
'US' => 'United States',
'UY' => 'Uruguay',
'UZ' => 'Uzbekistan',
'VA' => 'Vatican City',
'VC' => 'St Vincent and Grenadines',
'VE' => 'Venezuela',
'VG' => 'British Virgin Islands',
'VI' => 'U.S. Virgin Islands',
'VN' => 'Vietnam',
'VU' => 'Vanuatu',
'WF' => 'Wallis and Futuna',
'WS' => 'Samoa',
'XK' => 'Kosovo',
'XM' => 'The Moon',
'XS' => 'System',
'XX' => 'Unknown',
'YE' => 'Yemen',
'YT' => 'Mayotte',
'ZA' => 'South Africa',
'ZM' => 'Zambia',
'ZW' => 'Zimbabwe',
default => 'Unknown',
};
}