- This topic has 9 replies, 3 voices, and was last updated 4 years, 2 months ago by
Elvin.
-
AuthorPosts
-
January 22, 2022 at 5:52 am #2089549
A. R. Choudhury
Hello, I want to launch a website in Bengali language. The best way is to install WP on a subdirectory and change the site language. I did that. But the problem is, the HTML language after changing the site language is “<html lang=”bn-BD”>”
It looks as if it is set only for Bangladesh region.
I want to change that to “<html lang=”bn”>”
How can I do that?
The English version of HTML language is also set to <html lang=”en-US”
How can I change that too to <html lang=”en”
Because I have noticed that major websites in my niche like Healthline, WebMD also uses <html lang=”en”>
Please help.
January 22, 2022 at 10:16 am #2089920David
StaffCustomer SupportHi there,
just to be clear you want to have the site displayed in Bengali but the Language meta to be set to English?
January 22, 2022 at 7:05 pm #2090258A. R. Choudhury
No no. For example, If I view the page source of GeneratePress, I can see the language HTML <!DOCTYPE html><html lang=”en-US”>
The same happened with all my sites.
I want to change the language of HTML to be <!DOCTYPE html><html lang=”en”>
See, HTML is not “en-US”. It is only “en”.
You can see for example here: view-source:https://www.healthline.com/
How can I change HTML language from “en-US” to “en”?
January 23, 2022 at 4:34 am #2090494David
StaffCustomer SupportThen you would need a PHP Snippet as WP only adds languages and country.
Try adding this snippet:add_filter('language_attributes', function($lang){ $lang = "lang=\"en\""; return $lang; });January 23, 2022 at 4:53 am #2090509A. R. Choudhury
Thanks, David. It works.
What about this plugin? https://wordpress.org/plugins/chl-change-html-lang/
Is it function like the same? I have tried this and it also works.
But it hasn’t been tested with the latest 3 major releases of WordPress.
Can I use it safely?January 23, 2022 at 10:35 am #2090897David
StaffCustomer SupportI can’t say whether its safe for use but WP looking at the plugins code it uses the same
language_attributesfilter plus doing some stuff if WPSEO ( Yoast ) is active.January 23, 2022 at 6:55 pm #2091224A. R. Choudhury
Ok. Is there any way to just change Site HTML Language without changing the WordPress dashboard language without plugins?
January 23, 2022 at 9:20 pm #2091267Elvin
StaffCustomer SupportHi there,
Ok. Is there any way to just change Site HTML Language without changing the WordPress dashboard language without plugins?
David’s provided code from one of his previous reply does that.
https://generatepress.com/forums/topic/change-html-lang/#post-2090494More about
language_attributesfilter here
https://developer.wordpress.org/reference/hooks/language_attributes/If you wish to avoid adding even the Code Snippets plugin then you must have a child theme’s functions.php.
Here’s how to add PHP snippets – https://docs.generatepress.com/article/adding-php/
January 23, 2022 at 9:27 pm #2091272A. R. Choudhury
Ok, Elvin. Thanks.
January 23, 2022 at 9:28 pm #2091273Elvin
StaffCustomer SupportNo problem. 😀
-
AuthorPosts
- You must be logged in to reply to this topic.