Can labels be changed to a different language?

The Pintura Image Editor module includes the en_gb locale files. Locale files for other languages are included in the product package.

When using the default factories like openDefaultEditor the english locale is automatically loaded. We can overwrite labels by passing locale properties like shown below.

import { openDefaultEditor } from './pintura.js';

// set locale to the editor
openDefaultEditor({
    src: './my-image.jpeg',
    locale: {
        labelButtonExport: 'Save',
    },
});

When using openEditor we have to supply locale property so the editor has labels. We can set our own labels by updating label properties in the locale objects or by duplicating the locale files and translating the label values there.

import {
    openEditor,
    locale_en_gb,
    plugin_crop_locale_en_gb,
} from './pintura.js';

const locale = {
    ...locale_en_gb,
    ...plugin_crop_locale_en_gb,
};

locale.labelButtonExport = 'Save';

// set locale to the editor
openDefaultEditor({
    src: './my-image.jpeg',
    locale,
});

We can use one of the other locale files by importing the needed modules. In the example below we load the German locale files for the core editor and annotation plugin.

import { openEditor } from './pintura.js';

import locale_de_DE from './locale/de_DE/core/de_DE.js';
import locale_annotate_de_DE from './locale/de_DE/annotate/de_DE.js';

const locale = {
    ...locale_de_DE,
    ...locale_annotate_de_DE,
};

openEditor({
    src: 'my-image.jpeg',
    locale,
});