1<?php 2 3/** 4 * webtrees: online genealogy 5 * Copyright (C) 2022 webtrees development team 6 * This program is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * You should have received a copy of the GNU General Public License 15 * along with this program. If not, see <https://www.gnu.org/licenses/>. 16 */ 17 18declare(strict_types=1); 19 20namespace Fisharebest\Webtrees\Module; 21 22use Fisharebest\Localization\Locale\LocaleHu; 23use Fisharebest\Localization\Locale\LocaleInterface; 24use Fisharebest\Webtrees\Encodings\UTF8; 25use Illuminate\Database\Query\Builder; 26 27use function mb_substr; 28use function str_starts_with; 29 30/** 31 * Class LanguageHungarian. 32 */ 33class LanguageHungarian extends AbstractModule implements ModuleLanguageInterface 34{ 35 use ModuleLanguageTrait; 36 37 /** 38 * Phone-book ordering of letters. 39 * 40 * @return array<int,string> 41 */ 42 public function alphabet(): array 43 { 44 return [ 45 'A', 46 UTF8::LATIN_CAPITAL_LETTER_A_WITH_ACUTE, 47 'B', 48 'C', 49 'CS', 50 'D', 51 'DZ', 52 'DZS', 53 'E', 54 UTF8::LATIN_CAPITAL_LETTER_E_WITH_ACUTE, 55 'F', 56 'G', 57 'GY', 58 'H', 59 'I', 60 UTF8::LATIN_CAPITAL_LETTER_I_WITH_ACUTE, 61 'J', 62 'K', 63 'L', 64 'LY', 65 'M', 66 'N', 67 'NY', 68 'O', 69 UTF8::LATIN_CAPITAL_LETTER_O_WITH_ACUTE, 70 UTF8::LATIN_CAPITAL_LETTER_O_WITH_DIAERESIS, 71 UTF8::LATIN_CAPITAL_LETTER_O_WITH_DOUBLE_ACUTE, 72 'P', 73 'Q', 74 'R', 75 'S', 76 'SZ', 77 'T', 78 'TY', 79 'U', 80 UTF8::LATIN_CAPITAL_LETTER_U_WITH_ACUTE, 81 UTF8::LATIN_CAPITAL_LETTER_U_WITH_DIAERESIS, 82 UTF8::LATIN_CAPITAL_LETTER_U_WITH_DOUBLE_ACUTE, 83 'V', 84 'W', 85 'X', 86 'Y', 87 'Z', 88 'ZS', 89 ]; 90 } 91 92 /** 93 * One of: 'DMY', 'MDY', 'YMD'. 94 * 95 * @return string 96 */ 97 public function dateOrder(): string 98 { 99 return 'YMD'; 100 } 101 102 /** 103 * Some languages use digraphs and trigraphs. 104 * 105 * @param string $string 106 * 107 * @return string 108 */ 109 public function initialLetter(string $string): string 110 { 111 foreach (['DZS', 'DZ', 'GY', 'LY', 'NY', 'SZ', 'TY', 'ZS'] as $digraph) { 112 if (str_starts_with($string, $digraph)) { 113 return $digraph; 114 } 115 } 116 117 return mb_substr($string, 0, 1); 118 } 119 120 /** 121 * @return LocaleInterface 122 */ 123 public function locale(): LocaleInterface 124 { 125 return new LocaleHu(); 126 } 127 128 129 /** 130 * Letters with diacritics that are considered distinct letters in this language. 131 * 132 * @return array<string,string> 133 */ 134 protected function normalizeExceptions(): array 135 { 136 return [ 137 'A' . UTF8::COMBINING_ACUTE_ACCENT => UTF8::LATIN_CAPITAL_LETTER_A_WITH_ACUTE, 138 'E' . UTF8::COMBINING_ACUTE_ACCENT => UTF8::LATIN_CAPITAL_LETTER_E_WITH_ACUTE, 139 'I' . UTF8::COMBINING_ACUTE_ACCENT => UTF8::LATIN_CAPITAL_LETTER_I_WITH_ACUTE, 140 'O' . UTF8::COMBINING_ACUTE_ACCENT => UTF8::LATIN_CAPITAL_LETTER_O_WITH_ACUTE, 141 'O' . UTF8::COMBINING_DIAERESIS => UTF8::LATIN_CAPITAL_LETTER_O_WITH_DIAERESIS, 142 'O' . UTF8::COMBINING_DOUBLE_ACUTE_ACCENT => UTF8::LATIN_CAPITAL_LETTER_O_WITH_DOUBLE_ACUTE, 143 'U' . UTF8::COMBINING_ACUTE_ACCENT => UTF8::LATIN_CAPITAL_LETTER_U_WITH_ACUTE, 144 'U' . UTF8::COMBINING_DIAERESIS => UTF8::LATIN_CAPITAL_LETTER_U_WITH_DIAERESIS, 145 'U' . UTF8::COMBINING_DOUBLE_ACUTE_ACCENT => UTF8::LATIN_CAPITAL_LETTER_U_WITH_DOUBLE_ACUTE, 146 'a' . UTF8::COMBINING_ACUTE_ACCENT => UTF8::LATIN_SMALL_LETTER_A_WITH_ACUTE, 147 'e' . UTF8::COMBINING_ACUTE_ACCENT => UTF8::LATIN_SMALL_LETTER_E_WITH_ACUTE, 148 'i' . UTF8::COMBINING_ACUTE_ACCENT => UTF8::LATIN_SMALL_LETTER_I_WITH_ACUTE, 149 'o' . UTF8::COMBINING_ACUTE_ACCENT => UTF8::LATIN_SMALL_LETTER_O_WITH_ACUTE, 150 'o' . UTF8::COMBINING_DIAERESIS => UTF8::LATIN_SMALL_LETTER_O_WITH_DIAERESIS, 151 'o' . UTF8::COMBINING_DOUBLE_ACUTE_ACCENT => UTF8::LATIN_SMALL_LETTER_O_WITH_DOUBLE_ACUTE, 152 'u' . UTF8::COMBINING_ACUTE_ACCENT => UTF8::LATIN_SMALL_LETTER_U_WITH_ACUTE, 153 'u' . UTF8::COMBINING_DIAERESIS => UTF8::LATIN_SMALL_LETTER_U_WITH_DIAERESIS, 154 'u' . UTF8::COMBINING_DOUBLE_ACUTE_ACCENT => UTF8::LATIN_SMALL_LETTER_U_WITH_DOUBLE_ACUTE, 155 ]; 156 } 157} 158