It might sound simple question as I am new into Sitecore. I need to add two characters of language code
into html tag
for site web accessibility.
Working with Sitecore 9.3
Thanks in advance.
You need to add it to the layout file like.
<html lang="@Sitecore.Context.Language.CultureInfo.TwoLetterISOLanguageName">
You can use the Sitecore context for this. The context is an object that contains information about the user, culture, language settings, and database settings.
So here is the different kind of language name that you can use like this. For example, if the language is da-DK
then you get the following using these properties.
Sitecore.Context.Language.CultureInfo.Name => 'da-DK'
Sitecore.Context.Language.CultureInfo.TwoLetterISOLanguageName => 'da'
Sitecore.Context.Language.CultureInfo.ThreeLetterISOLanguageName => 'dan'
So in your case, you can use Sitecore.Context.Language.CultureInfo.TwoLetterISOLanguageName
Hope this help.