versionFrom | meta.Title | meta.Description |
---|---|---|
9.0.0 |
Language Model |
Represents a Language. Installed languages can be found in the settings section. |
Represents a Language. Installed languages can be found in the settings section.
- Namespace:
Umbraco.Cms.Core.Models
- Assembly:
Umbraco.Core.dll
All samples in this document will require references to the following dll:
- Umbraco.Core.dll
All samples in this document will require the following using statement:
using Umbraco.Cms.Core.Models;
Constructor for creating a new Language
object where the necessary parameter are the global settings as GlobalSettings
and the isoCode as a string
.
:::note To create a new Language the global setting parameter is necessary. You can find more info about how to use configuration in code in the Config article. :::
Gets the CultureInfo object for the language.
var language = new Language(globalSettings, "en-US");
CultureInfo cultureInfo = language.CultureInfo;
return cultureInfo;
Gets or sets the culture name of the language.
var language = new Language(globalSettings, "en-US");
string cultureName = language.CultureName;
return cultureName;
Gets or sets the identifier of a fallback language. The fallback language can be used in multi-lingual scenarios, to help define fallback strategies when a value does not exist for a requested language.
var language = new Language(globalSettings, "en-US");
int? fallbackLanguageId = language.FallbackLanguageId;
return fallbackLanguageId;
Gets or sets a value indicating whether the language is the default language.
var language = new Language(globalSettings, "en-US");
bool isDefault = language.IsDefault;
return isDefault;
Gets or sets a value indicating whether the language is mandatory. When a language is mandatory, a multi-lingual document cannot be published without that language being published, and unpublishing that language unpublishes the entire document.
var language = new Language(globalSettings, "en-US");
bool isMandatory = language.IsMandatory;
return isMandatory;
Gets or sets the ISO code of the language.
var language = new Language(globalSettings, "en-US");
return language.IsoCode;