102086832SGreg Roach<?php 23976b470SGreg Roach 302086832SGreg Roach/** 402086832SGreg Roach * webtrees: online genealogy 5*d11be702SGreg Roach * Copyright (C) 2023 webtrees development team 602086832SGreg Roach * This program is free software: you can redistribute it and/or modify 702086832SGreg Roach * it under the terms of the GNU General Public License as published by 802086832SGreg Roach * the Free Software Foundation, either version 3 of the License, or 902086832SGreg Roach * (at your option) any later version. 1002086832SGreg Roach * This program is distributed in the hope that it will be useful, 1102086832SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 1202086832SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1302086832SGreg Roach * GNU General Public License for more details. 1402086832SGreg Roach * You should have received a copy of the GNU General Public License 1589f7189bSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>. 1602086832SGreg Roach */ 17fcfa147eSGreg Roach 1802086832SGreg Roachdeclare(strict_types=1); 1902086832SGreg Roach 2002086832SGreg Roachnamespace Fisharebest\Webtrees\Module; 2102086832SGreg Roach 2202086832SGreg Roachuse Fisharebest\Localization\Locale\LocaleInterface; 2302086832SGreg Roachuse Fisharebest\Localization\Locale\LocaleNb; 2452288ec7SGreg Roachuse Fisharebest\Webtrees\Encodings\UTF8; 2502086832SGreg Roach 264a9a6095SGreg Roachuse function mb_substr; 274a9a6095SGreg Roachuse function str_starts_with; 284a9a6095SGreg Roach 2902086832SGreg Roach/** 3002086832SGreg Roach * Class LanguageNorwegianBokmal. 3102086832SGreg Roach */ 3202086832SGreg Roachclass LanguageNorwegianBokmal extends AbstractModule implements ModuleLanguageInterface 3302086832SGreg Roach{ 3402086832SGreg Roach use ModuleLanguageTrait; 3502086832SGreg Roach 3602086832SGreg Roach /** 374a9a6095SGreg Roach * Phone-book ordering of letters. 384a9a6095SGreg Roach * 394a9a6095SGreg Roach * @return array<int,string> 404a9a6095SGreg Roach */ 414a9a6095SGreg Roach public function alphabet(): array 424a9a6095SGreg Roach { 4352288ec7SGreg Roach return [ 4452288ec7SGreg Roach 'A', 4552288ec7SGreg Roach 'B', 4652288ec7SGreg Roach 'C', 4752288ec7SGreg Roach 'D', 4852288ec7SGreg Roach 'E', 4952288ec7SGreg Roach 'F', 5052288ec7SGreg Roach 'G', 5152288ec7SGreg Roach 'H', 5252288ec7SGreg Roach 'I', 5352288ec7SGreg Roach 'J', 5452288ec7SGreg Roach 'K', 5552288ec7SGreg Roach 'L', 5652288ec7SGreg Roach 'M', 5752288ec7SGreg Roach 'N', 5852288ec7SGreg Roach 'O', 5952288ec7SGreg Roach 'P', 6052288ec7SGreg Roach 'Q', 6152288ec7SGreg Roach 'R', 6252288ec7SGreg Roach 'S', 6352288ec7SGreg Roach 'T', 6452288ec7SGreg Roach 'U', 6552288ec7SGreg Roach 'V', 6652288ec7SGreg Roach 'W', 6752288ec7SGreg Roach 'X', 6852288ec7SGreg Roach 'Y', 6952288ec7SGreg Roach 'Z', 7052288ec7SGreg Roach UTF8::LATIN_CAPITAL_LETTER_AE, 7152288ec7SGreg Roach UTF8::LATIN_CAPITAL_LETTER_O_WITH_STROKE, 7252288ec7SGreg Roach UTF8::LATIN_CAPITAL_LETTER_A_WITH_RING_ABOVE, 7352288ec7SGreg Roach ]; 744a9a6095SGreg Roach } 754a9a6095SGreg Roach 764a9a6095SGreg Roach /** 774a9a6095SGreg Roach * Some languages use digraphs and trigraphs. 784a9a6095SGreg Roach * 794a9a6095SGreg Roach * @param string $string 804a9a6095SGreg Roach * 814a9a6095SGreg Roach * @return string 824a9a6095SGreg Roach */ 834a9a6095SGreg Roach public function initialLetter(string $string): string 844a9a6095SGreg Roach { 854a9a6095SGreg Roach if (str_starts_with($string, 'AA')) { 864a9a6095SGreg Roach return 'Å'; 874a9a6095SGreg Roach } 884a9a6095SGreg Roach 894a9a6095SGreg Roach return mb_substr($string, 0, 1); 904a9a6095SGreg Roach } 914a9a6095SGreg Roach 924a9a6095SGreg Roach /** 9302086832SGreg Roach * Should this module be enabled when it is first installed? 9402086832SGreg Roach * 9502086832SGreg Roach * @return bool 9602086832SGreg Roach */ 9702086832SGreg Roach public function isEnabledByDefault(): bool 9802086832SGreg Roach { 9902086832SGreg Roach return false; 10002086832SGreg Roach } 10102086832SGreg Roach 10202086832SGreg Roach /** 10302086832SGreg Roach * @return LocaleInterface 10402086832SGreg Roach */ 10502086832SGreg Roach public function locale(): LocaleInterface 10602086832SGreg Roach { 10702086832SGreg Roach return new LocaleNb(); 10802086832SGreg Roach } 10952288ec7SGreg Roach 11052288ec7SGreg Roach /** 11152288ec7SGreg Roach * Letters with diacritics that are considered distinct letters in this language. 11252288ec7SGreg Roach * 11352288ec7SGreg Roach * @return array<string,string> 11452288ec7SGreg Roach */ 11552288ec7SGreg Roach protected function normalizeExceptions(): array 11652288ec7SGreg Roach { 11752288ec7SGreg Roach return [ 11852288ec7SGreg Roach 'O' . UTF8::COMBINING_LONG_SOLIDUS_OVERLAY => UTF8::LATIN_CAPITAL_LETTER_O_WITH_STROKE, 11952288ec7SGreg Roach 'A' . UTF8::COMBINING_RING_ABOVE => UTF8::LATIN_CAPITAL_LETTER_A_WITH_RING_ABOVE, 12052288ec7SGreg Roach 'AA' => UTF8::LATIN_CAPITAL_LETTER_A_WITH_RING_ABOVE, 12152288ec7SGreg Roach 'Aa' => UTF8::LATIN_CAPITAL_LETTER_A_WITH_RING_ABOVE, 12252288ec7SGreg Roach 'o' . UTF8::COMBINING_LONG_SOLIDUS_OVERLAY => UTF8::LATIN_SMALL_LETTER_O_WITH_STROKE, 12352288ec7SGreg Roach 'a' . UTF8::COMBINING_RING_ABOVE => UTF8::LATIN_SMALL_LETTER_A_WITH_RING_ABOVE, 12452288ec7SGreg Roach 'aa' => UTF8::LATIN_SMALL_LETTER_A_WITH_RING_ABOVE, 12552288ec7SGreg Roach 'aA' => UTF8::LATIN_SMALL_LETTER_A_WITH_RING_ABOVE, 12652288ec7SGreg Roach ]; 12752288ec7SGreg Roach } 12802086832SGreg Roach} 129