Backoffice Localization
Learn how to manage and use the Backoffice UI Localization files.
Last updated
Was this helpful?
Learn how to manage and use the Backoffice UI Localization files.
Last updated
Was this helpful?
This article describes how you can translate the Umbraco Backoffice UI into different languages. You can use the existing localizations from Umbraco or register your own localizations. You can also use the localization in your custom elements and controllers.
Localizations can be registered via the Extension Registry. .
As Umbraco is an evolving product, new text is regularly added to the English version of these files. Therefore, some of the languages may no longer be up-to-date.
If a key is not found in the current language, the fallback language will be used. The fallback language is English with the culture code en.
If a translation is missing, the default value within umb-localize
will be shown in the user interface:
Instead of showing the default value we can show the key alias if we set debug="true"
:
The following example shows how you can display localized text with the umb-localize
element:
In some situations, you need the localization as a variable that can be parsed. In this case, the Localization Controller can be used in your element.ts
file. This can be setup in two ways:
The arguments will be passed to the function in the localization file if it is a function.
If you are working with an Umbraco Controller, then you need to initialize the Localization Controller on your own via the UmbLocalizationController
:
Sometimes you need to pass arguments to the localization to return different values based on the arguments. A localization value can be either a string or a function. Given a localization file like this, we can return different values based on the number of items:
Using the Localize Element
You can pass arguments to the localization by adding them as additional attributes:
The arguments will be passed to the function in the localization file if it is a function. The args
attribute must be JSON-serializable and each array value will be passed to the function as an extra argument.
Using the Localize Controller
You can pass arguments to the localization by calling the term
method with the arguments:
The arguments will be passed to the function in the localization file if it is a function. Each argument of term
will be passed to the function as an extra argument.
You can also use placeholders in the localization keys to replace parts of the string with dynamic values. Placeholders are defined by curly braces {0}
or percentage signs %0%
in the localization key. The placeholders will be replaced one-to-one with the arguments passed to the localization. It works the same as the arguments feature, except you cannot calculate the value based on the arguments.
Given a localization file like this:
You can use the same args
attribute to pass the arguments:
You can localize values in a manifest. For example, prefix the name of the dashboard tab visible in the UI with a #
.
A manifest registering a dashboard with umbraco-package.json
or JavaScript can localize the label
property in the meta
object like this.
You can add your own localization keys using the principles you have learned, and apply them in a number of ways:
You can have a look and try out the element in the .
Using
Using
When using an , the Localization Controller is already initialized on the localize
property via the UmbElementMixin
.
You can try out the arguments feature in the .
You can find a localization example in the article. This will get you started with using localization in your custom elements. You can apply the same principles to all extensions.
Property descriptions and labels can also be localized. They are formatted as Markdown and can contain localization keys using the built-in syntax.