Skip to content

Commit

Permalink
fix locale mapping forrecaptcha and jquery
Browse files Browse the repository at this point in the history
  • Loading branch information
bozana committed Dec 5, 2024
1 parent 33c7423 commit 08749d8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions classes/template/PKPTemplateManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,11 @@ public function initialize(PKPRequest $request)
array_push($contexts, 'frontend-login-index', 'frontend-login-signIn');
}
if (count($contexts)) {
// These are the supported locales: https://developers.google.com/recaptcha/docs/language
// It seems Google has already mapping for locales missing in that list, so that we can provide locale es it is.
$this->addJavaScript(
'recaptcha',
'https://www.google.com/recaptcha/api.js?hl=' . substr(Locale::getLocale(), 0, 2),
'https://www.google.com/recaptcha/api.js?hl=' . Locale::getLocale(),
[
'contexts' => $contexts,
]
Expand Down Expand Up @@ -656,7 +658,7 @@ public function setState(array $data)
public function registerJSLibrary(): void
{
$baseUrl = $this->_request->getBaseUrl();
$localeChecks = [Locale::getLocale(), strtolower(substr(Locale::getLocale(), 0, 2))];
$localeChecks = [Locale::getLocale(), \Locale::getPrimaryLanguage(Locale::getLocale())];

// Common $args array used for all our core JS files
$args = [
Expand Down

0 comments on commit 08749d8

Please sign in to comment.