# Document Type Localization

The Umbraco backoffice is localized to match the [user's configured UI Culture](https://docs.umbraco.com/umbraco-cms/tutorials/multilanguage-setup#changing-the-default-backoffice-language-of-a-user).

When defining a Document Type, you can apply localization to:

* Document Type names and descriptions.
* Property names and descriptions.
* Custom property validation messages.
* Tab and group names.

Setting up localization for Document Types is a three-step process:

* Register the Document Type localization files via [a new manifest 'umbraco-package.json' file](https://docs.umbraco.com/umbraco-cms/customizing/extending-overview/extension-types/localization#registering-localization).
* Create the localizations in [user defined Document Type localization files](https://docs.umbraco.com/umbraco-cms/customizing/extending-overview/extension-types/localization#the-localization-file).
* Apply the localizations to the Document Type.

{% hint style="info" %}
Everything in this article also applies to defining [Media Types](https://docs.umbraco.com/umbraco-cms/backoffice#media-types) and [Member Types](https://docs.umbraco.com/umbraco-cms/backoffice#member-types).
{% endhint %}

## Registering Document Type localization Files

To register Document Type localizations, you must create a new manifest using an `umbraco-package.json` file.

{% hint style="info" %}
The `umbraco-package.json` file is only registered when placed directly in the `/App_Plugins/` or `/App_Plugins/{SubFolderName}` folder. It will not be recognized in nested subfolders.
{% endhint %}

{% code title="umbraco-package.json" %}

```json
{
  "name": "Document Type Localization",
  "extensions": [
    {
      "type": "localization",
      "alias": "DocumentType.Localize.En",
      "name": "English",
      "meta": {
        "culture": "en"
      },
      "js": "/App_Plugins/DocumentTypeLocalization/doctype-en.js"
    }
  ]
}
```

{% endcode %}

## Creating localizations

Once you have registered the Document Type localization, you can add your localization texts for use in Document Types. The following localizations are used for the samples in this article:

{% code title="doctype-en.js" lineNumbers="true" %}

```js
export default {
    contentTypes: {
        article: 'Article page',
        'article-desc': 'A textual, article-like page on the site. Use this as the main type of content.',
        landing: 'Landing page',
        'landing-desc': 'An inviting, very graphical page. Use this as an entry point for a campaign, and supplement with Article pages.'
    },
    tabs: {
        content: 'Page content',
        seo: 'SEO configuration',
    },
    groups: {
        titles: 'Page titles'
    },
    properties: {
        title: 'Main title',
        'title-desc': 'This is the main title of the page.',
        'title-message': 'The main title is required for this page.',
        subTitle: 'Sub title',
        'subTitle-desc': 'This is the sub title of the page.',
    }
};
```

{% endcode %}

{% hint style="info" %}
Umbraco must be restarted to register the localization manifest. Any subsequent localization text changes will need to be reloaded within the browser.
{% endhint %}

## Applying localizations

The localizations are applied by using the syntax `#{area alias}_{key alias}`.

1. Create a **Document Type with Template** called `#contentTypes_article` with the **alias**: `articlePage`.
2. Under the newly created Document Type, follow these steps:
   * Set the **description** to `#contentTypes_article-desc`.
   * Create a new **tab** called `#tabs_content`.
   * Add a new **group** called `#groups_titles`.
   * Add a **property** called `#properties_title` with **alias** `title`.
     * Set the description to `{#properties_title-desc}`.
     * Use a `TextString` editor.
     * Set the field validation to `mandatory`.
     * Under validation add `#properties_title-message`.

{% hint style="info" %}
Property descriptions support [Umbraco Flavored Markdown](https://docs.umbraco.com/umbraco-cms/reference/umbraco-flavored-markdown), which uses a different syntax (wrapped in brackets) to avoid conflicts with Markdown headers.
{% endhint %}

![Applying localization to a property](https://2050077833-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fb0WSXUuM7Qx5BfREagAI%2Fuploads%2Fgit-blob-c14a6bb5ca35e3f03417c5bf2c37bd14378f5e13%2Flocalization-document-type-editor-validation-v15.png?alt=media)

3. Add a **property** called `#properties_subTitle` with **alias** `subTitle`.
   * Set the description to `{#properties_subTitle-desc}`.
   * Use a `TextString` editor.
4. Enable `Allow at root` in the **Structure** tab.

![Applying localization to a Document Type](https://2050077833-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fb0WSXUuM7Qx5BfREagAI%2Fuploads%2Fgit-blob-9f3533c9eab90560a568451d5cbe788d108fa117%2Flocalization-document-type-editor-v15.png?alt=media)

When creating and editing the content, you will see that the backoffice now uses the configured localizations.

![Localized document creation dialog](https://2050077833-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fb0WSXUuM7Qx5BfREagAI%2Fuploads%2Fgit-blob-58b02eb6b1c7fc91622b40689087dc92743bb36c%2Flocalization-document-editor-create.png?alt=media)

5. Create a new "Article" node:

![Localized document editing](https://2050077833-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fb0WSXUuM7Qx5BfREagAI%2Fuploads%2Fgit-blob-47ed19ed8814e61b96535bc918c525dd14df4c99%2Flocalization-document-editor-v15.png?alt=media)

6. When trying to save the node without adding the mandatory content, you will see a warning as expected:

![Localized property validation](https://2050077833-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fb0WSXUuM7Qx5BfREagAI%2Fuploads%2Fgit-blob-a81ce08060873ef2f487955a1375576e419ab570%2Flocalization-document-editor-validation.png?alt=media)
