I manage a plugin. I have people often complain about translations and have found that sometimes they don't have their site set to their local language.
Is it possible in site source code to display the site language as chosen in Settings > General
?
e.g. I have a comment <!-- plugin version 123 -->
. Is it possible to display <!-- plugin version 123 (Fr) -->
if the language is French?
I manage a plugin. I have people often complain about translations and have found that sometimes they don't have their site set to their local language.
Is it possible in site source code to display the site language as chosen in Settings > General
?
e.g. I have a comment <!-- plugin version 123 -->
. Is it possible to display <!-- plugin version 123 (Fr) -->
if the language is French?
1 Answer
Reset to default 1Is it possible to display
<!-- plugin version 123 (Fr) -->
if the language is French?
Yes, it is possible and you can use get_bloginfo( 'language' )
which returns a language tag like en-US
for English (US)
.
So if you just want to retrieve the first 2-or-3 character code (e.g. en
for en-US
and en-UK
) of the language tag, you can do:
list ( $lang ) = explode( '-', get_bloginfo( 'language' ) );
echo '<!-- plugin version 123 (' . ucfirst( $lang ) . ') -->';
get_locale()
andget_bloginfo( 'language' )
, if that helps. – Sally CJ Commented Mar 23, 2020 at 6:26<html lang="">
attribute set withlanguage_attributes()
. See in_s
. So with that in place you can always have the set language in the opening<html>
tag. – Mayeenul Islam Commented Mar 23, 2020 at 6:26