This article overviews how language files are used and managed in a Umbraco CMS website.
Language files are XML files used to translate:
The Umbraco backoffice user interface so that end users can use Umbraco in their native language. This is particularly important for content editors who do not speak English.
The member identity errors in an Umbraco website enabling end users to use Umbraco in the website language.
Read Add translations for your packages to see how to include translations for your own package.
Override existing language files.
You can use localization files for Document and Media Types as well. You can find more information about this in the Document Type Localization article.
This is an example of such a language file, the most important parts are the alias
fields of the <area>
and <key>
elements. This is what you need to retrieve the values from .NET or Angular.
Current languages that are included in new Umbraco installations are:
English (UK)
English (US)
Danish
German
Spanish
French
Hebrew (Israel)
Italian
Japanese
Korean
Dutch
Norwegian
Polish
Portuguese
Russian
Swedish
Chinese
Chinese (Taiwan)
Czech
Turkish
Welsh
Ukrainian
The core Umbraco language files are found at the following location within the Umbraco source:
These language files are the ones shipped with Umbraco and should not be modified.
If you are a package developer, see here for docs on how to include translations for your own package, package language files are located in:
The App_Plugins
version of the Lang
directory is case sensitive on Linux systems, so make sure that it start with a capital L
.
If you want to override Umbraco core translations or translations shipped with packages, you can do that too, these files are located here:
The /config/lang/
folders do not exist on a clean installation of the CMS. You will need to create them at the root of your src
project.
By default, these files are empty but you can add any new keys you want or override existing ones with your own translations. The nice part about the user files is that they will not get overwritten by the installer when you upgrade your Umbraco versions.
In order for these files to deploy when you do a dotnet publish
, you need to add the following to your .csproj
file:
Using core or custom language keys from your code:
ILocalizedTextService
is used to localize strings, and is available through dependency injection. First, inject the service, and then use the Localize()
method available in the namespace Umbraco.Extensions
to localize the string with the format \[area]/\[key]
:
In the Umbraco backoffice UI, labels can be localized with the localize
directive. The syntax is slightly different when compared to the .NET variant. Here the syntax is \[area]_\[key]
:
The localize directive can also be used as an attribute like below. The value of the title attribute is then populated with the dictionary key "title_name" from the language file using "@title_name".
Or from a controller by using the LocalizationService
which returns an async translation in a promise:
As Umbraco is a continually evolving product it is inevitable that new text is added regularly to the English language version of these files. This may mean that some of the above languages are no longer up to date.
If a translation is missing, the key "alias" used will be shown within the user interface, as an example:
The language files are XML files with a straight-forward layout as seen below.
In the above example of a missing translation for "assignDomain", locate this string in the en.xml file. Then copy the whole "Key" element into the relevant language file. Then you can translate the text, as an example here is the Spanish version of the above snippet:
If you modify core language files or introduce a new language, you can assist the community by sharing your updates. This can be done by submitting a pull request so that your changes are merged into the core.