From 458ebd8c37e34d6457bd110e24838903dc14d2fc 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..720a825 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' => str_replace('_', '-', str_replace(['@cyrillic', '@latin', '_Latn', '_Cyrl'], '', 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')}