lang attribute in html tag

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
sangnandar
User
Posts: 1031

lang attribute in html tag

Post 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">

arbei
User
Posts: 9787

Post by arbei »

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


sangnandar
User
Posts: 1031

Post 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.


Post Reply