qtranslate-xt icon indicating copy to clipboard operation
qtranslate-xt copied to clipboard

Wrong HTML lang

Open andreysneg opened this issue 3 years ago • 5 comments

I setup lang code ru-EE pic: https://bit.ly/3fhvTSM

But the site frontend is nowhere - ru-EE Backend is ok . All language translation files is work fine with ru_EE.

But frontend Lang code show: ru-RU pic: https://bit.ly/3uidqcX

Only with ru-RU problem.

For example if i setup en-EE when all is ok. Frontend en-EE too .

andreysneg avatar May 24 '21 15:05 andreysneg

It looks like an unfinished concept to me!

if your theme uses the function "language_attributes()" you could use the corresponding filter.

add_filter('language_attributes', function ($output, $doctype) {
    if (function_exists('qtranxf_getLanguage')) {
        global $q_config;
        $locale = $q_config[ 'locale_html' ][ qtranxf_getLanguage() ] ?? '';
        if (! empty($locale)) {
            $output = 'lang="'. $locale .'"';    
        }
    }
    return $output;
}, 10, 2);

MK-RD avatar May 24 '21 17:05 MK-RD

It works ! Thank you.

But why qtranslate dont have this most important funciton inside ? Please add this. or optionaly.

Interesting fact

  1. At localhost HTML lang="ru-RU" work without this function

  2. At server HTML lang="ru-RU" dont work without this function.

andreysneg avatar May 27 '21 08:05 andreysneg

A similar question was asked in the past.

Normally, the locale (front-end) for the HTML lang attribute should be used with priority, if this was defined via the administration (locale at front-end) - but this is currently not the case!

The reason why the locale for Russian (Estonia) is still not used can be found in the source code ... as I'm not a fan of Trial & Error, I don't want to go into this any further.

MK-RD avatar May 27 '21 11:05 MK-RD

Right, but you already raised that issue some time ago, see #974. I keep this one as there's more information.

I'm aware there is something wrong with the locales, that was one of the reasons not finishing #668. I've been busy on other things but we will come back to this.

herrvigg avatar May 29 '21 10:05 herrvigg

At least he now has the opportunity to help himself with a possibly urgent project in the short term.

MK-RD avatar May 29 '21 12:05 MK-RD