Skip to main content

Custom key attributes

Use key custom attributes to set format-specific options.

Written by Ilya Krukowski

Custom key attributes allow you to configure format-specific options for your translation keys. Currently, custom attributes are supported 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, open the Custom attributes tab. Here, you’ll find a code editor where you can define custom attributes for the selected key:


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"
                }
            ]
        }
    ]
}

YAML/YML integer and double values

When YAML or YML files are imported into Lokalise, keys with numeric values are automatically assigned custom attributes to preserve their original value types during export.

For example, integer values such as 1, 2, or 42 receive the following attribute:

{ "key_type": "integer" }

Decimal values such as 1.1 or 3.14 receive:

{ "key_type": "double" }

These attributes ensure that YAML exports preserve numeric formatting and export values as numbers instead of converting them into strings.

For example, count: 3 will remain count: 3 instead of becoming count: "3".

Important behavior

If translations for these keys are later re-imported as strings, or imported through a different file format such as JSON, the numeric custom attribute is removed from the key.

As a result, future YAML exports may return numeric values as strings, leading to inconsistent formatting between exports.

Best practices

To preserve integer and double formatting consistency:

  • Continue importing updates using the same YAML/YML file format.

  • Avoid re-importing these keys through formats that do not preserve numeric key types, such as JSON.

  • If numeric attributes were removed, re-import the source YAML/YML file to restore them.

Workaround

If integer or double values are already exporting as strings:

  1. Re-import the original YAML/YML source file.

  2. The Replace modified option can remain disabled.

  3. Lokalise will still restore the required custom attributes during import.


Additional reading

Did this answer your question?