ItalyCookieChoices / italy-cookie-choices

A simple way to show how your website complies with the EU Cookie Law.
53 stars 12 forks source link

Italy Cookie choices in multilingua #181

Open claudiorn opened 7 years ago

claudiorn commented 7 years ago

Salve. Ho installato Italy Cookie choices nel mio sito wordpress nel quale avevo già installato il plugin qtranslate-x per la gestione del multilingua. C'è un modo per consentire una visualizzazione adeguata del testo relativo all'informativa sui cookie che sia funzione della lingua selezionata dall'utente?

Grazie. Claudio.

overclokk commented 7 years ago

Ciao @claudiorn attualmente Italy Cookie Choices supporta wpml, polylang e Ceceppa https://github.com/ItalyCookieChoices/italy-cookie-choices/wiki/Multilanguage al momento non è previsto qtranslate-x ma lo posso tenere in considerazione per un eventuale supporto futuro.

ghost commented 7 years ago

ciao, rispetto a questo problema ho trovato una soluzione molto semplice, semplicemente nel get_string aggiungere "__()" sull'ultime else...sarebbe possibile inserirlo nella prossima release?

    function get_string( $plugin_name_human_format, $string_name, $value ) {

        $true = true;

        if ( function_exists( 'icl_t' ) ) {
            return icl_t( $plugin_name_human_format, $string_name, $value );

        } elseif ( has_filter( 'cml_my_translations' ) ) {
            return CMLTranslations::get( CMLLanguage::get_current_id(), strtolower( $string_name ), str_replace( ' ', '-', $plugin_name_human_format, $true ) );

        } elseif ( function_exists( 'pll__' ) ) {
            return pll__( $string_name );

        } else {
            return __($value);
        }

    }

può creare problemi?

overclokk commented 7 years ago

Ciao @kikko088 se la funzione __( $value ) la usi così senza il $domain come carichi la traduzione?

ghost commented 7 years ago

Ciao! non sono super esperto e non ho mai approfondito il funzionamento della traduzione su wp, quindi non so darti una spiegazione...l'unica cosa che posso dire è che provando questa soluzione con qtranslate funziona

overclokk commented 7 years ago

I tag forniti dal plugin non funzionano?

dademaru commented 7 years ago

Ciao @overclokk purtroppo i tag (Raw ML values) non funzionano.

Ideale sarebbe aggiungere degli hook in Cookie_Choices.php, così le opzioni da back end sono comunque utilizzabili, mentre chi ha necessità può sovrascriverle agganciandosi all'hook.

$text_option = $this->wp_json_encode( wp_kses_post( get_string( 'Italy Cookie Choices', 'Banner text', $this->options['text'] ) ) );
$text = apply_filters( 'icc_text_filter', $text_option );

$url = esc_url( get_string( 'Italy Cookie Choices', 'Banner url', $this->options['url'] ) );

$anchor_text_option = esc_js( get_string( 'Italy Cookie Choices', 'Banner anchor text', $this->options['anchor_text'] ) );
$anchor_text = apply_filters( 'icc_anchor_text_filter', $anchor_text_option );

$button_text_option = esc_js( get_string( 'Italy Cookie Choices', 'Banner button text', $this->options['button_text'] ) );
$button_text = apply_filters( 'icc_button_text_filter', $button_text_option );

EDIT: ho provato anche la soluzione di @kikko088 e funziona senza problemi, non necessita del parametro $domain. È più veloce rispetto all'aggiunta di hook (sebbene avere filtri a disposizione per sovrascrivere opzioni resta molto potente).

Nella documentazione qTranslate X è scritto:

How to translate multilingual fields at frontend? […] Use WordPress translation function (). A multilingual text gets translated whenever it is passed through the standard WordPress translation function ().

overclokk commented 7 years ago

Ciao @dademaru aggiungere filtri non è un problema se possono servire, lo tengo in considerazione per le prossime release.

ghost commented 6 years ago

Buongiorno, è stato poi integrato qualcosa? Ho la necessità su un sito sviluppato da terzi con qTranslate, Italy Cookie Choice è l'unico che non crea conflitti ma non riesco a tradurlo...