Localization Service
Example on how to retrieve languages using the LocalizationService.
Learn how to use the Localization service to retrieve languages.
Getting a single language
The localization service contains a number of methods for looking up languages. If you already know the ID of a specific language (eg. the default language has ID 1
), you can use the GetLanguageById
method to get the reference to that language:
As an alternative, you can look up a language by its ISO code via the GetLanguageByIsoCode
method:
The ISO code is a combination of the two-letter ISO 639-1 language code (lowercase) and two-letter ISO-3166 country code (uppercase). Eg. en-US
for English in the United States, en-GB
for English in the United Kingdom and da-DK
for Danish in Denmark.
Both methods will return an instance of the ILanguage interface, which has traditional properties like Id
and Key
, but also properties specific to the language like CultureName
, CultureInfo
and IsoCode
. You can see the API reference for further information on the properties of the interface.
Getting all languages
If you need instead need a list of all installed languages, you can use the GetAllLanguages
method. It takes no parameters, and as such a returns a collection of all languages (with no pagination like some of the other services):
As shown in the example above, you can get the System.Globalization.CultureInfo
instance of each language. The CultureInfo determines how numbers, dates and similar should be either parsed or formatted in .NET.
Full example
Below you can see a full example of the examples shown above - including the necessary imports:
The above example is using ILocalizationService
which is currently obselete and will be removed in v15. Use ILanguageService
or IDictionaryItemService
(for dictionary item operations) instead.
Last updated