<?php
/**
* Italian copy for the Automattic "OpenID Connect Server" plugin consent screen
* and related messages (text domain: openid-connect-server). Also a few wp-login
* strings in the default domain when the language pack is missing or incomplete.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class WP_OJS_SSO_OIDC_Server_It_Locale {
public static function init() {
if ( ! self::is_italian_site() ) {
return;
}
add_filter( 'gettext', [ __CLASS__, 'translate_gettext' ], 20, 3 );
add_filter( 'login_title', [ __CLASS__, 'italian_login_title' ], 20, 2 );
}
private static function is_italian_site() {
$locale = get_locale();
return 0 === strpos( $locale, 'it' );
}
/**
* @param string $translation Current translation.
* @param string $text Original (English) string.
* @param string $domain Text domain.
*/
public static function translate_gettext( $translation, $text, $domain ) {
if ( 'openid-connect-server' === $domain ) {
static $oidc = null;
if ( null === $oidc ) {
$oidc = [
'Hi %s!' => 'Ciao %s!',
'Do you want to log in to <em>%1$s</em> with your <em>%2$s</em> account?'
=> 'Vuoi accedere a <em>%1$s</em> usando il tuo account <em>%2$s</em>?',
'Authorize' => 'Autorizza',
'Cancel' => 'Annulla',
"You don't have permission to use OpenID Connect."
=> "Non hai l'autorizzazione per usare OpenID Connect.",
'Contact your administrator for more details.'
=> "Contatta l'amministratore del sito per maggiori informazioni.",
];
}
return $oidc[ $text ] ?? $translation;
}
if ( 'default' === $domain ) {
static $core = null;
if ( null === $core ) {
$core = [
'Registration confirmation will be emailed to you.'
=> "Riceverai un'email di conferma della registrazione.",
];
}
if ( isset( $core[ $text ] ) && ( $translation === $text || '' === $translation ) ) {
return $core[ $text ];
}
return $translation;
}
return $translation;
}
/**
* The OIDC server calls login_header( 'OIDC Connect' ) — that string is not i18n.
*
* @param string $login_title The title to show in the <title> and heading.
* @param string $title The raw first argument to login_header().
*/
public static function italian_login_title( $login_title, $title ) {
if ( 'OIDC Connect' === $title ) {
return 'Accesso con OpenID Connect';
}
return $login_title;
}
}