• Resolved esanchez3

    (@esanchez3)


    Hi,

    Is there any way to get the active language in php?

    I need to switch the wordpress language along the plugin to translate a plugin ::after attribute text.

    The get_locale() function always returns the site default language.

    Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author edo888

    (@edo888)

    Hi,

    Please check How to detect current selected language?

    You can check for googtrans cookie to detect the language, but when you switch the language it will not execute PHP, as the translations happen on the fly.

    If you are trying to achieve something, please describe it here, may be there is a better way other than changing the locale, which does not seem right to me.

    You can also check our paid version: https://gtranslate.io/#pricing which has more features.

    Thanks! 🙂

    Thread Starter esanchez3

    (@esanchez3)

    Hi,

    Thanks for your answer.

    We are using the GPDR Cookie Consent plugin, which inserts a text using a data-attribute value located in a ::after element. So we are trying to translate it by setting the active language as the user language.

    Plugin Author edo888

    (@edo888)

    Hi,

    If you are using CSS and you need to write language specific rule you can use attribute selector. We are setting lang attribute on html tag like this:

    HTML:
    <html lang="es" ..>

    CSS can be like this:
    html[lang="es"] .etc {...}

    Hope this helps.

    Thanks! 🙂

    • This reply was modified 5 years, 7 months ago by edo888.
Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘get active language’ is closed to new replies.