Skip to main content
Custom key attributes

Use key custom attributes to set format-specific options.

Ilya Krukowski avatar
Written by Ilya Krukowski
Updated over a week ago

Key custom attributes allow you to set format-specific options for your translation keys. Currently, we support custom attributes for the following file formats:

Getting started

To begin, open your project editor and locate the translation key you want to customize with attributes. Click on the key name to open the key editor:

Next, go to the Custom attributes tab. Here, you’ll find a code editor where you can enter your custom attributes:


Custom attributes specifics

XLIFF

For XLIFF files, each key can have the following custom attributes: datatype, notes, and context-groups.

  • datatypesupports string values.

  • notes — an array of objects, where each object represents a note. The only mandatory field for each note is value.

  • context-groups — an array of objects, where each object is a context-group containing an array that holds all contexts. An extra purpose field is supported as well.

Example:

{
"notes": [
{
"from": "description",
"value": "Welcomes the user to the page",
"priority": "1"
},
{
"from": "meaning",
"value": "heading",
"priority": "1"
}
],
"datatype": "html",
"context-groups": [
{
"purpose": "location",
"contexts": [
{
"value": "app/app.component.ts",
"context-type": "sourcefile"
},
{
"value": "1",
"context-type": "linenumber"
}
]
}
]
}

Android Resources 

This format supports the following attributes:

  • translatable — an XML attribute for export, with a value of either "true" or "false". Make sure to specify it as a string by enclosing it in quotation marks.

  • force-cdata — use this parameter to override Lokalise's default CDATA wrapper algorithm for a specific key. This is a boolean attribute, so it should be set without quotation marks, e.g., true.

  • android-tools — can contain any attributes described in Android's Tools Attributes Reference. The attribute's name should be specified without a prefix, e.g., "ignore". The prefix and namespace attribute will be automatically added during export if any tools attribute is found.

Example:

{
"translatable": "false",
"force-cdata": true,
"android-tools": {
"ignore": "missingTranslation"
}
}

Java Properties

For Java Properties files, you can set a custom key-value separator. This is a legacy attribute, as you can now set the separator on the Downloads page. The value must be either = or :.

Example:

{
    "separator": ":"
}

Combine them all

{
    "separator": ":",
    "translatable": "false",
    "force-cdata": true,
    "android-tools": {
        "ignore": "missingTranslation"
    },
    "notes": [
        {
            "from": "description",
            "value": "Welcomes the user to the page",
            "priority": "1"
        },
        {
            "from": "meaning",
            "value": "heading",
            "priority": "1"
        }
    ],
    "datatype": "html",
    "context-groups": [
        {
            "purpose": "location",
            "contexts": [
                {
                    "value": "app/app.component.ts",
                    "context-type": "sourcefile"
                },
                {
                    "value": "1",
                    "context-type": "linenumber"
                }
            ]
        }
    ]
}

Additional reading

Did this answer your question?