From b4ca57f9c57b3c18eda4860ec59b3a55dba77707 Mon Sep 17 00:00:00 2001 From: Bozana Bokan Date: Tue, 16 Jul 2024 16:31:59 +0200 Subject: [PATCH] pkp/pkp-lib#9910 Use UI Language in Web Feeds --- WebFeedGatewayPlugin.php | 5 ++++- templates/rss.tpl | 2 +- templates/rss2.tpl | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/WebFeedGatewayPlugin.php b/WebFeedGatewayPlugin.php index 10f3926..89ca436 100644 --- a/WebFeedGatewayPlugin.php +++ b/WebFeedGatewayPlugin.php @@ -25,6 +25,8 @@ use Exception; use PKP\category\Category; use PKP\core\Registry; +use PKP\facades\Locale; +use PKP\i18n\LocaleConversion; use PKP\plugins\GatewayPlugin; class WebFeedGatewayPlugin extends GatewayPlugin @@ -126,7 +128,8 @@ public function fetch($args, $request): bool 'latestDate' => $latestDate, 'feedUrl' => $request->getRequestUrl(), 'userGroups' => $userGroups, - 'includeIdentifiers' => $includeIdentifiers + 'includeIdentifiers' => $includeIdentifiers, + 'language' => locale_get_region(Locale::getLocale()) ? locale_get_primary_language(Locale::getLocale()) . '-' . locale_get_region(Locale::getLocale()) : locale_get_primary_language(Locale::getLocale()), ] ) ->setHeaders(['content-type: ' . static::FEED_MIME_TYPE[$feedType] . '; charset=utf-8']) diff --git a/templates/rss.tpl b/templates/rss.tpl index 6b15c9e..faaa16a 100644 --- a/templates/rss.tpl +++ b/templates/rss.tpl @@ -37,7 +37,7 @@ {/if} {if $context->getPrimaryLocale()} - {$context->getPrimaryLocale()|replace:'_':'-'|strip|escape:"html"} + {$language|escape} {/if} {$context->getLocalizedName()|strip|escape:"html"} diff --git a/templates/rss2.tpl b/templates/rss2.tpl index e0b8565..b48cb6e 100644 --- a/templates/rss2.tpl +++ b/templates/rss2.tpl @@ -26,7 +26,7 @@ {* optional elements *} {if $context->getPrimaryLocale()} - {$context->getPrimaryLocale()|replace:'_':'-'|strip|escape:"html"} + {$language|escape} {/if} {if $context->getLocalizedData('licenseTerms')}