• There is a website in three languages. How to add the lang attribute to the html tag, for each language version?
    Using a plugin qTranslate

    • This topic was modified 4 years, 3 months ago by kvvv.
    • This topic was modified 4 years, 3 months ago by kvvv.
    • This topic was modified 4 years, 3 months ago by kvvv.
Viewing 8 replies - 1 through 8 (of 8 total)
  • Hi Kvvv,

    I had had the same question before.
    If I understand your question correctly, probably the answer is the following:
    <html <?php language_attributes(); ?>>
    Insert the above on your header.php
    The language is automatically switched.
    It passes the HTML5 Validation as well.

    Thread Starter kvvv

    (@kvvv)

    Hi createpop

    Tried it but didn’t work. The result on the screen https://prntscr.com/u7ay5c

    Hi,

    I guess you are missing the end tag “>” at the last.
    I hope you can fix it.

    Thread Starter kvvv

    (@kvvv)

    When editing the code, there are two closing brackets, but one is not displayed on the site
    https://prntscr.com/u7b0q7

    The code is correct. When I check my header.php I see this:

    <!DOCTYPE html>
    <html xmlns="https://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
    <head>
    <meta ...

    If I check the page source then the language is replaced by the current language set (nl-BE):

    <!DOCTYPE html>
    <html xmlns="https://www.w3.org/1999/xhtml" lang="nl-BE">
    <head>
    <meta ...

    rgds, Wilfried

    Thread Starter kvvv

    (@kvvv)

    When I check I see this:
    <html <?php language_attributes(); ?>>
    But if I check the page source I see:
    <html <?php language_attributes(); ?>

    But my tag <html> located in _layout.twig

    It looks that the function is not called. Can you try to switch debug on in wp-config.php?

    define(‘WP_DEBUG’, true);
    define(‘WP_DEBUG_DISPLAY’, false);
    define(‘WP_DEBUG_LOG’, true);

    Or mayby it does not return the correct language. Is the language you switched to correctly installed in the Language Management (qTranslate Configuration)?

    rgds, Wilfried

    Thread Starter kvvv

    (@kvvv)

    I think correctly. When switching the language, the language code is added to the url. <Linl> hreflang works correctly

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘“Lang” attribute in html tag’ is closed to new replies.