v8.77.0

Can labels be changed to a different language?

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

When using the default factories like openDefaultEditor the english locale is automatically loaded.

Overwriting label captions

We can overwrite labels by passing locale properties like shown below.

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

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

Importing language and locale objects

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,

    // the core locale object
    locale_en_gb,

    // the crop locale object
    plugin_crop_locale_en_gb,

    // the markup editor locale object
    markup_editor_locale_en_gb,
} from './pintura.js';

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

locale.labelButtonExport = 'Save';

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

Loading different language and locale files

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';

// note that the MarkupEditor locale is exported by the core locale file
import locale_de_DE, {
    MarkupEditor as locale_markup_editor_de_DE,
} from './locale/de_DE/core/de_DE.js';

// each plugin has a separate locale file
import locale_annotate_de_DE from './locale/de_DE/annotate/de_DE.js';

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

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