Is there a way to get the available language codes for the current node tree?
This is what i got currently but it gives me all configured languages in the backoffice
Copy code
C#
public bool DoesLanguageExist(string isoCode)
{
var languages = _localizationService.GetAllLanguages();
return languages.Any(language => language.IsoCode == isoCode);
}
}
a
Ambert
05/27/2024, 11:08 AM
I think you can check with the domainService to see what the configured domains for a node are, with ofcourse what languages are available
Ambert
05/27/2024, 11:08 AM
If you need to do it per node, for example for the rendering of a flag for each available culture its a bit more complex
Then loop through each language, and check if the current node has a variant in that language
Copy code
var url = currentPage.Url(_publishedUrlProvider, language.IsoCode);
and if they do, add them to a object that contains all flagitems
d
D_Inventor
05/27/2024, 11:15 AM
If you're going to check on domains frequently, then maybe you want to use the domain cache inside an Umbraco context. That should save you a roundtrip to the database, as opposed to localization service or domain service.
p
PascalEugster
05/28/2024, 7:01 AM
Thanks alot to you guys! Helped me alot! @D_Inventor@Ambert
p
ProBot Prime ✨
05/28/2024, 7:02 AM
@User May I suggest “all” instead of "guys"? We use gender inclusive language in this Discord. 😀