Custom attributes

Updated a month ago ​by Artis Melko

Use key's custom attributes for setting the format-specific options. As an example, Android Resources (XML) files can have attribute "translatable" set to "false".  Click key name in the editor to bring up the key editor. Navigate to Custom attributes tab.

Currently we support custom attributes for:

  • XLIFF
  • Android Resources
  • Java Properties

XLIFF

Each key can have datatype, notes and context-groups. See example for usage.

  • datatype has a string value.
  • notes is an array of objects, each of those is a note. For each note the only mandatory field is value.
  • context-groups is an array of objects, where each object is context-group containing array that holds all contexts. We support an extra purpose field 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 

For this format you can use two attributes – translatable and force-cdata.

  • translatable is an XML attribute for export, the value is either "true" or "false" (make sure to specify it as string, enclosing in quotes, e.g. "false").
  • force-cdata is the parameter to enable when you are confident enough to override Lokalise's default CDATA wrapper alogithm  (which renders proper XML in most cases) for the particular key.  Set the without quotes, as it's boolean, e.g. true.
{
    "translatable": "false",
    "force-cdata": true
}


Java Properties

You can set custom key-value separator for this file format. This is a legacy attribute, as currently you can set the separator at Downloads page. The value must be either = or :

{
    "separator": ":"
}


Combine them all

{
    "separator": ":",
    "translatable": "false",
    "force-cdata": true,
    "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"
                }
            ]
        }
    ]
}

How did we do