|
| 1 | +--- |
| 2 | +description: Here you will learn how to apply localization for Document Types in Umbraco. |
| 3 | +--- |
| 4 | + |
| 5 | +# Document Type Localization |
| 6 | + |
| 7 | +The Umbraco backoffice is fully localized to match the user's [configured language](../users.md). When defining Document Types, you can apply localization to: |
| 8 | + |
| 9 | +* Document Type names and descriptions. |
| 10 | +* Property names and descriptions. |
| 11 | +* Custom property validation messages. |
| 12 | +* Tab and group names. |
| 13 | + |
| 14 | +Setting up localization for Document Types is a two-step process: |
| 15 | + |
| 16 | +* Create the localizations in [user defined language files](../../../extending/language-files.md). |
| 17 | +* Apply the localizations to the Document Types. |
| 18 | + |
| 19 | +{% hint style="info" %} |
| 20 | +Everything in this article also applies to defining [Media Types](../creating-media/). |
| 21 | +{% endhint %} |
| 22 | + |
| 23 | +## Creating localizations |
| 24 | + |
| 25 | +User defined language files are created in `/config/lang` and must be named `{language}.user.xml`. For example: `en-us.user.xml`. |
| 26 | + |
| 27 | +There are no specific requirements as to how localizations should be structured for use in Document Types. The following localizations have been used for the samples in this article: |
| 28 | + |
| 29 | +{% code title="en-us.user.xml" lineNumbers="true" %} |
| 30 | +```xml |
| 31 | +<?xml version="1.0" encoding="utf-8" standalone="yes"?> |
| 32 | +<language> |
| 33 | + <area alias="contentTypes"> |
| 34 | + <key alias="article">Article page</key> |
| 35 | + <key alias="article-desc">A textual, article-like page on the site. Use this as the main type of content.</key> |
| 36 | + <key alias="landing">Landing page</key> |
| 37 | + <key alias="landing-desc">An inviting, very graphical page. Use this as an entry point for a campaign, and supplement with Articles.</key> |
| 38 | + </area> |
| 39 | + <area alias="tabs"> |
| 40 | + <key alias="content">Page content</key> |
| 41 | + <key alias="seo">SEO configuration</key> |
| 42 | + </area> |
| 43 | + <area alias="groups"> |
| 44 | + <key alias="titles">Page titles</key> |
| 45 | + </area> |
| 46 | + <area alias="properties"> |
| 47 | + <key alias="title">Main title</key> |
| 48 | + <key alias="title-desc">This is the main title of the page.</key> |
| 49 | + <key alias="title-message">The main title is required for this page.</key> |
| 50 | + <key alias="subTitle">Sub title</key> |
| 51 | + <key alias="subTitle-desc">This is the sub title of the page.</key> |
| 52 | + </area> |
| 53 | +</language> |
| 54 | +``` |
| 55 | +{% endcode %} |
| 56 | + |
| 57 | +{% hint style="info" %} |
| 58 | +Umbraco must be restarted to pick up on changes to language files. |
| 59 | +{% endhint %} |
| 60 | + |
| 61 | +## Applying localizations |
| 62 | + |
| 63 | +The localizations are applied by using the syntax `#{area alias}_{key alias}`. |
| 64 | + |
| 65 | +1. Create a **Document Type with template** called `#contentTypes_article` with **alias**: `articlePage`. |
| 66 | +2. Under the newly created document type follow these steps: |
| 67 | + |
| 68 | +* Name the **description** to `#contentTypes_article-desc`. |
| 69 | +* Create a new **tab** called `#tabs_content`. |
| 70 | +* Add a new **group** called `#groups_titles`. |
| 71 | +* Add a **property** called `#properties_title` with **alias** `title`. |
| 72 | + * Set description to `#properties_title-desc`. |
| 73 | + * Use a `TextString` editor. |
| 74 | + * Enable to `Set this field as mandatory`. |
| 75 | + * Under validation add `#properties_title-message`. |
| 76 | + |
| 77 | + |
| 78 | + |
| 79 | +* Add a **property** called `#properties_subTitle` with **alias** `subTitle`. |
| 80 | + * Set description to `#properties_subTitle-desc`. |
| 81 | + * Use a `TextString` editor. |
| 82 | +* Enable to `Allow as root` in the **Permissions** tab. |
| 83 | + |
| 84 | + |
| 85 | + |
| 86 | +3. When creating and editing the content, you will see that the backoffice now uses the configured localizations.  |
| 87 | + |
| 88 | + |
| 89 | + |
| 90 | +4. Create a new "Article" content: |
| 91 | + |
| 92 | + |
| 93 | + |
| 94 | +4. When trying to save the content without adding the mandatory content, you will see a warning as expected: |
| 95 | + |
| 96 | + |
0 commit comments