diff --git a/src/Content/Widget.php b/src/Content/Widget.php index 6adb8c24b7..7cc0099771 100644 --- a/src/Content/Widget.php +++ b/src/Content/Widget.php @@ -48,6 +48,12 @@ class Widget */ public static function findPeople(): string { + // Langs in friendica are all lowercase and dash separated (e.g. da-dk) - in the directory + // they're underscore separated, with the latter part being uppercase (e.g. da_DK) + $directory_user_lang_string = ""; + if (DI::userSession()->get('language')) { + $directory_user_lang_string = "&lang=" . DI::l10n()->langToLocaleCode(DI::userSession()->get('language')); + } $global_dir = Search::getGlobalDirectory(); if (DI::config()->get('system', 'invitation_only')) { @@ -70,7 +76,7 @@ class Widget $nv['random'] = DI::l10n()->t('Random Profile'); $nv['inv'] = DI::l10n()->t('Invite Friends'); $nv['directory'] = DI::l10n()->t('Global Directory'); - $nv['global_dir'] = OpenWebAuth::getZrlUrl($global_dir, true); + $nv['global_dir'] = OpenWebAuth::getZrlUrl($global_dir, true) . $directory_user_lang_string; $nv['local_directory'] = DI::l10n()->t('Local Directory'); $aside = []; @@ -611,9 +617,9 @@ class Widget $widget_timelineorder = json_decode(DI::pConfig()->get($uid, 'system', 'widget_timeline_order')); if (!empty($widget_timelineorder)) { $tmp = []; - foreach($widget_timelineorder as $order) { - foreach($channels as $channel) { - if($channel['ref'] == $order) { + foreach ($widget_timelineorder as $order) { + foreach ($channels as $channel) { + if ($channel['ref'] == $order) { $tmp[] = $channel; } } diff --git a/src/Core/L10n.php b/src/Core/L10n.php index 33fa658836..9d16415e89 100644 --- a/src/Core/L10n.php +++ b/src/Core/L10n.php @@ -469,6 +469,17 @@ class L10n return $languages; } + /** + * Converts e.g. en-gb to en_GB and da-dk to da_DK, which is the format some other systems expect + * + * @param string $lang + * @return string + * */ + public function langToLocaleCode($lang) + { + return preg_replace_callback("/([a-z]+)-([a-z]+)/", fn ($m) => $m[1] . "_" . strtoupper($m[2]), $lang); + } + /** * Convert the language code to ISO639-1 * It also converts old codes to their new counterparts.