Language
How to work with multiple languages.
The Language entity makes use of the multi-language capabilities of the field framework. It is connected to the Channel entity, and indirectly to the Website entity. One website can be connected to several languages. Content in the Website entity can be shown or hidden for different channels and languages.
The Language entity can be found under Namespace: Litium.Globalization.Language. It has three properties:
- Default indicator – to know if the language is the default language or not
- Culture name
- Fallback languages
The fallback languages follow these rules:
- Current language has value – there will be no translation
- Current language has no fallback language and no value of text – the translation will be Translation missing.
- Current language has fallback language and no value for text – the translation will follow the format Translation of fallback language [the fallback culture],for example: About us [sv-SE].
- The value for multiple fallback languages will follow their respective order. For example, en-SE has two fallback languages: sv-SE and en-US, in that order – The system will check the sv-SE fallback first. In case that language has no value, the translation will be en-US. If both sv-SE and en-US return no value, the translation will be Translation missing.
The language settings can be accessed in the back-office UI under Cogwheel > Globalization > Languages.

By default, the language created first will be the default language. You can only change the default language when you edit the languages.

Language service
Language service is there to help basic CRUD actions on a language object. Here are two code samples for creating and retrieving a language object:
Create a new language:
var language = _languageService.Get("sv-se");
if (language == null)
{
language = new Language(new CultureInfo("sv-se")) {IsDefaultLanguage = true };
_languageService.Create(language);
}
return language;
We use GetEntityName() extension to get the language translation correctly:
var displayName = product.GetEntityName();
We could also get all languages in the system like this:
var languages = _languageService.GetAll().ToList();