| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
class ShiConverter extends LanguageConverterSpecific { |
| 36 |
|
| 37 |
|
| 38 |
é" |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
private const TO_LATIN = [ |
| 43 |
'ⴰ' => 'a', |
| 44 |
'ⴱ' => 'b', |
| 45 |
'ⴳ' => 'g', |
| 46 |
'ⴷ' => 'd', |
| 47 |
'ⴹ' => 'ḍ', |
| 48 |
'ⴻ' => 'e', |
| 49 |
'ⴼ' => 'f', |
| 50 |
'ⴽ' => 'k', |
| 51 |
'ⵀ' => 'h', |
| 52 |
'ⵃ' => 'ḥ', |
| 53 |
'ⵄ' => 'ɛ', |
| 54 |
'ⵅ' => 'x', |
| 55 |
'ⵇ' => 'q', |
| 56 |
'ⵉ' => 'i', |
| 57 |
'ⵊ' => 'j', |
| 58 |
'ⵍ' => 'l', |
| 59 |
'ⵎ' => 'm', |
| 60 |
'ⵏ' => 'n', |
| 61 |
'ⵓ' => 'u', |
| 62 |
'ⵔ' => 'r', |
| 63 |
'ⵕ' => 'ṛ', |
| 64 |
'ⵖ' => 'ɣ', |
| 65 |
'ⵙ' => 's', |
| 66 |
'ⵚ' => 'ṣ', |
| 67 |
'ⵛ' => 'c', |
| 68 |
'ⵜ' => 't', |
| 69 |
'ⵟ' => 'ṭ', |
| 70 |
'ⵡ' => 'w', |
| 71 |
'ⵢ' => 'y', |
| 72 |
'ⵣ' => 'z', |
| 73 |
'ⵥ' => 'ẓ', |
| 74 |
'ⵯ' => 'ʷ', |
| 75 |
]; |
| 76 |
|
| 77 |
|
| 78 |
private const UPPER_TO_LOWER_CASE_LATIN = [ |
| 79 |
'A' => 'a', |
| 80 |
'B' => 'b', |
| 81 |
'G' => 'g', |
| 82 |
'D' => 'd', |
| 83 |
'Ḍ' => 'ḍ', |
| 84 |
'E' => 'e', |
| 85 |
'F' => 'f', |
| 86 |
'K' => 'k', |
| 87 |
'H' => 'h', |
| 88 |
'Ḥ' => 'ḥ', |
| 89 |
'Ɛ' => 'ɛ', |
| 90 |
'X' => 'x', |
| 91 |
'Q' => 'q', |
| 92 |
'I' => 'i', |
| 93 |
'J' => 'j', |
| 94 |
'L' => 'l', |
| 95 |
'M' => 'm', |
| 96 |
'N' => 'n', |
| 97 |
'U' => 'u', |
| 98 |
'R' => 'r', |
| 99 |
'Ṛ' => 'ṛ', |
| 100 |
'Ɣ' => 'ɣ', |
| 101 |
'S' => 's', |
| 102 |
'Ṣ' => 'ṣ', |
| 103 |
'C' => 'c', |
| 104 |
'T' => 't', |
| 105 |
'Ṭ' => 'ṭ', |
| 106 |
'W' => 'w', |
| 107 |
'Y' => 'y', |
| 108 |
'Z' => 'z', |
| 109 |
'Ẓ' => 'ẓ', |
| 110 |
'O' => 'o', |
| 111 |
'P' => 'p', |
| 112 |
'V' => 'v', |
| 113 |
]; |
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
private const TO_TIFINAGH = [ |
| 120 |
'a' => 'ⴰ', |
| 121 |
'b' => 'ⴱ', |
| 122 |
'g' => 'ⴳ', |
| 123 |
'd' => 'ⴷ', |
| 124 |
'ḍ' => 'ⴹ', |
| 125 |
'e' => 'ⴻ', |
| 126 |
'f' => 'ⴼ', |
| 127 |
'k' => 'ⴽ', |
| 128 |
'h' => 'ⵀ', |
| 129 |
'ḥ' => 'ⵃ', |
| 130 |
'ɛ' => 'ⵄ', |
| 131 |
'x' => 'ⵅ', |
| 132 |
'q' => 'ⵇ', |
| 133 |
'i' => 'ⵉ', |
| 134 |
'j' => 'ⵊ', |
| 135 |
'l' => 'ⵍ', |
| 136 |
'm' => 'ⵎ', |
| 137 |
'n' => 'ⵏ', |
| 138 |
'u' => 'ⵓ', |
| 139 |
'r' => 'ⵔ', |
| 140 |
'ṛ' => 'ⵕ', |
| 141 |
'ɣ' => 'ⵖ', |
| 142 |
's' => 'ⵙ', |
| 143 |
'ṣ' => 'ⵚ', |
| 144 |
'c' => 'ⵛ', |
| 145 |
't' => 'ⵜ', |
| 146 |
'ṭ' => 'ⵟ', |
| 147 |
'w' => 'ⵡ', |
| 148 |
'y' => 'ⵢ', |
| 149 |
'z' => 'ⵣ', |
| 150 |
'ẓ' => 'ⵥ', |
| 151 |
'ʷ' => 'ⵯ', |
| 152 |
'o' => 'ⵓ', |
| 153 |
'p' => 'ⴱ', |
| 154 |
'v' => 'ⴼ', |
| 155 |
]; |
| 156 |
|
| 157 |
public function getMainCode(): string { |
| 158 |
return 'shi'; |
| 159 |
} |
| 160 |
|
| 161 |
public function getLanguageVariants(): array { |
| 162 |
return [ 'shi', 'shi-tfng', 'shi-latn' ]; |
| 163 |
} |
| 164 |
|
| 165 |
public function getVariantsFallbacks(): array { |
| 166 |
return [ |
| 167 |
'shi' => [ 'shi-latn', 'shi-tfng' ], |
| 168 |
'shi-tfng' => 'shi', |
| 169 |
'shi-latn' => 'shi', |
| 170 |
]; |
| 171 |
} |
| 172 |
|
| 173 |
protected function loadDefaultTables(): array { |
| 174 |
return [ |
| 175 |
'lowercase' => new ReplacementArray( self::UPPER_TO_LOWER_CASE_LATIN ), |
| 176 |
'shi-tfng' => new ReplacementArray( self::TO_TIFINAGH ), |
| 177 |
'shi-latn' => new ReplacementArray( self::TO_LATIN ), |
| 178 |
'shi' => new ReplacementArray() |
| 179 |
]; |
| 180 |
} |
| 181 |
|
| 182 |
public function translate( $text, $toVariant ) { |
| 183 |
|
| 184 |
|
| 185 |
if ( trim( $text ) ) { |
| 186 |
$this->loadTables(); |
| 187 |
|
| 188 |
if ( $toVariant == 'shi-tfng' ) { |
| 189 |
$text = $this->mTables['lowercase']->replace( $text ); |
| 190 |
} |
| 191 |
$text = $this->mTables[$toVariant]->replace( $text ); |
| 192 |
} |
| 193 |
return $text; |
| 194 |
} |
| 195 |
} |