150 lines
4.4 KiB
PHP
150 lines
4.4 KiB
PHP
<?php
|
|
|
|
namespace App\User\Database;
|
|
|
|
class CountryLanguages
|
|
{
|
|
public static $languages = [
|
|
'English (US)',
|
|
'English',
|
|
'French',
|
|
'German',
|
|
'Italian',
|
|
'Spanish',
|
|
'Portuguese',
|
|
'Mandarin',
|
|
'Japanese',
|
|
'Korean',
|
|
'Russian',
|
|
'Hindi',
|
|
'Arabic',
|
|
'Dutch',
|
|
'Swedish',
|
|
'Norwegian',
|
|
'Danish',
|
|
'Finnish',
|
|
'Polish',
|
|
'Turkish',
|
|
'Persian',
|
|
'Thai',
|
|
'Vietnamese',
|
|
'Indonesian',
|
|
'Urdu',
|
|
'Bengali',
|
|
'Ukrainian',
|
|
'Greek',
|
|
'Hebrew',
|
|
'Malay',
|
|
'Filipino'
|
|
];
|
|
|
|
public static function fromCountryCode(string $countryCode): ?string
|
|
{
|
|
$countryLanguages = [
|
|
'US' => 'English (US)',
|
|
'GB' => 'English',
|
|
'CA' => 'English', // Note: French is also official in parts of Canada
|
|
'FR' => 'French',
|
|
'DE' => 'German',
|
|
'IT' => 'Italian',
|
|
'ES' => 'Spanish',
|
|
'MX' => 'Spanish',
|
|
'BR' => 'Portuguese',
|
|
'PT' => 'Portuguese',
|
|
'CN' => 'Mandarin',
|
|
'JP' => 'Japanese',
|
|
'KR' => 'Korean',
|
|
'RU' => 'Russian',
|
|
'IN' => 'Hindi', // Note: India has multiple official languages
|
|
'SA' => 'Arabic',
|
|
'EG' => 'Arabic',
|
|
'ZA' => 'English', // South Africa has 11 official languages
|
|
'NG' => 'English',
|
|
'AU' => 'English',
|
|
'AR' => 'Spanish',
|
|
'CH' => 'German', // Also French, Italian, Romansh
|
|
'BE' => 'Dutch', // Also French and German
|
|
'NL' => 'Dutch',
|
|
'SE' => 'Swedish',
|
|
'NO' => 'Norwegian',
|
|
'DK' => 'Danish',
|
|
'FI' => 'Finnish',
|
|
'PL' => 'Polish',
|
|
'TR' => 'Turkish',
|
|
'IR' => 'Persian',
|
|
'TH' => 'Thai',
|
|
'VN' => 'Vietnamese',
|
|
'ID' => 'Indonesian',
|
|
'PK' => 'Urdu',
|
|
'BD' => 'Bengali',
|
|
'UA' => 'Ukrainian',
|
|
'GR' => 'Greek',
|
|
'IL' => 'Hebrew',
|
|
'MY' => 'Malay',
|
|
'PH' => 'Filipino',
|
|
'KE' => 'English', // Also Swahili
|
|
];
|
|
|
|
return $countryLanguages[$countryCode] ?? null;
|
|
}
|
|
|
|
public static function fromCountryName(string $countryName): ?string
|
|
{
|
|
$countryLanguages = [
|
|
'United States' => 'English (US)',
|
|
'United Kingdom' => 'English',
|
|
'Canada' => 'English', // French is also official
|
|
'France' => 'French',
|
|
'Germany' => 'German',
|
|
'Italy' => 'Italian',
|
|
'Spain' => 'Spanish',
|
|
'Mexico' => 'Spanish',
|
|
'Brazil' => 'Portuguese',
|
|
'Portugal' => 'Portuguese',
|
|
'China' => 'Mandarin',
|
|
'Japan' => 'Japanese',
|
|
'South Korea' => 'Korean',
|
|
'Russia' => 'Russian',
|
|
'India' => 'Hindi', // Also English and many regional languages
|
|
'Saudi Arabia' => 'Arabic',
|
|
'Egypt' => 'Arabic',
|
|
'South Africa' => 'English', // One of 11 official languages
|
|
'Nigeria' => 'English',
|
|
'Australia' => 'English',
|
|
'Argentina' => 'Spanish',
|
|
'Switzerland' => 'German', // Also French, Italian, Romansh
|
|
'Belgium' => 'Dutch', // Also French and German
|
|
'Netherlands' => 'Dutch',
|
|
'Sweden' => 'Swedish',
|
|
'Norway' => 'Norwegian',
|
|
'Denmark' => 'Danish',
|
|
'Finland' => 'Finnish',
|
|
'Poland' => 'Polish',
|
|
'Turkey' => 'Turkish',
|
|
'Iran' => 'Persian',
|
|
'Thailand' => 'Thai',
|
|
'Vietnam' => 'Vietnamese',
|
|
'Indonesia' => 'Indonesian',
|
|
'Pakistan' => 'Urdu',
|
|
'Bangladesh' => 'Bengali',
|
|
'Ukraine' => 'Ukrainian',
|
|
'Greece' => 'Greek',
|
|
'Israel' => 'Hebrew',
|
|
'Malaysia' => 'Malay',
|
|
'Philippines' => 'Filipino',
|
|
'Kenya' => 'English', // Also Swahili
|
|
];
|
|
|
|
return $countryLanguages[$countryName] ?? null;
|
|
}
|
|
|
|
public static function asSelectOptions(): array
|
|
{
|
|
$result = [];
|
|
foreach (static::$languages as $language) {
|
|
$result[$language] = $language;
|
|
}
|
|
return $result;
|
|
}
|
|
}
|