Page 1 of 1

lang attribute in html tag

Posted: Wed Sep 11, 2024 3:32 am
by sangnandar

I think the layout.php template is wrong. It echoed lang attribute only if the language is rtl.

// node_modules\@phpmaker\php2024\layout.php
<html<?= IsRTL() ? ' lang="' . CurrentLanguageID() . '" dir="rtl"' : '' ?> data-bs-theme="light">

Re: lang attribute in html tag

Posted: Wed Sep 11, 2024 9:23 am
by arbei

The lang attribute is not used, I believe it only wants to check what language ID makes the dir attribute "rtl".


Re: lang attribute in html tag

Posted: Wed Sep 11, 2024 3:29 pm
by sangnandar

I think Chrome, in the absence of lang attribute, consider the page is in en and offering to translate the page to browser's language. I've seen my users clicked on that offering and make some phrases looks funny.
My app is in id language. In id language field caption "No" is short for "Nomor".
My users usually, being Indonesian, usually set their browser's language to Bahasa. When they clicked the offering to translate the page field caption "No" is translated to "Tidak".
So I think it's better to set lang attribute to avoid that offering by browser.
With the advancement of AI, I believe translation offering will soon become the norm, if not yet already, for all browsers.
Hence the need to literally define lang attribute in html tag.