Retrieving 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:
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, which 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:
Last updated