Ctrl+K
v3.0.5

Translations (i18n)

Add multi-language support and customize all text labels in the editor.

Setting the Active Language

Imigi supports full internationalization out of the box. To change the editor's display language, set the activeLanguage option during initialization. The default language is English ('en').

JavaScript
import { Imigi } from 'imigi';

const editor = await Imigi.init({
  selector: '#editor',
  image: 'photo.jpg',
  activeLanguage: 'es',
});
Tip

When you set activeLanguage to a language code, Imigi looks for matching translation strings in the languages object. If a key is not found, it falls back to the built-in English default.

Providing Custom Translations

To supply your own translations, pass a languages object in the configuration. Each key in the object is a language code, and its value is an object mapping translation keys to translated strings.

JavaScript
const editor = await Imigi.init({
  selector: '#editor',
  activeLanguage: 'es',
  languages: {
    es: {
      // Navigation
      'nav.filter': 'Filtros',
      'nav.crop': 'Recortar',
      'nav.draw': 'Dibujar',
      'nav.text': 'Texto',
      'nav.shapes': 'Formas',
      'nav.stickers': 'Stickers',
      'nav.frame': 'Marco',
      'nav.resize': 'Redimensionar',
      'nav.finetune': 'Ajustes',
      'nav.fill': 'Relleno',
      'nav.corners': 'Esquinas',
      'nav.redact': 'Censurar',

      // Toolbar
      'toolbar.save': 'Guardar',
      'toolbar.close': 'Cerrar',
      'toolbar.undo': 'Deshacer',
      'toolbar.redo': 'Rehacer',
      'toolbar.apply': 'Aplicar',
      'toolbar.cancel': 'Cancelar',

      // Messages
      'msg.loading': 'Cargando...',
      'msg.saving': 'Guardando...',
      'msg.error': 'Ocurrió un error',
      'msg.unsavedChanges': 'Tienes cambios sin guardar',
      // ... more keys
    },
  },
});
Tip

You can define multiple languages in the languages object and switch between them at any time using setConfig(). See Dynamic Language Switching below.

Translation Keys Reference

Below is the complete table of all available translation keys organized by category. Use these keys in your languages object to translate every label, button, tooltip, and message in the editor.

These keys control the labels shown in the main tool navigation bar.

Key Default (English) Description
nav.filter Filters Filter tool nav label
nav.crop Crop Crop tool nav label
nav.draw Draw Draw tool nav label
nav.text Text Text tool nav label
nav.shapes Shapes Shapes tool nav label
nav.stickers Stickers Stickers tool nav label
nav.frame Frame Frame tool nav label
nav.resize Resize Resize tool nav label
nav.finetune Adjust Finetune tool nav label
nav.fill Fill Fill tool nav label
nav.corners Corners Corners tool nav label
nav.redact Redact Redact tool nav label

Toolbar Keys

These keys control the labels and tooltips for the main toolbar buttons.

Key Default Description
toolbar.save Save Save button label
toolbar.close Close Close button label
toolbar.undo Undo Undo button tooltip
toolbar.redo Redo Redo button tooltip
toolbar.apply Apply Apply changes button
toolbar.cancel Cancel Cancel changes button
toolbar.zoomIn Zoom In Zoom in tooltip
toolbar.zoomOut Zoom Out Zoom out tooltip
toolbar.resetZoom Reset Zoom Reset zoom tooltip

Tool-specific Keys

Each tool has its own set of translation keys for labels, options, and presets displayed within the tool panel.

Filter Keys
Key Default Description
filter.noneNoneNo filter option
filter.grayscaleGrayscaleGrayscale filter label
filter.sepiaSepiaSepia filter label
filter.invertInvertInvert filter label
filter.vintageVintageVintage filter label
filter.polaroidPolaroidPolaroid filter label
filter.blackWhiteBlack & WhiteB&W filter label
filter.sharpenSharpenSharpen filter label
filter.blurBlurBlur filter label
filter.embossEmbossEmboss filter label
Crop Keys
Key Default Description
crop.originalOriginalOriginal ratio preset
crop.freeFreeFree-form crop
crop.squareSquare1:1 aspect ratio
crop.landscapeLandscape16:9 aspect ratio
crop.portraitPortrait9:16 aspect ratio
crop.flipXFlip XHorizontal flip label
crop.flipYFlip YVertical flip label
crop.rotateRotateRotation label
Draw Keys
Key Default Description
draw.penPenPen brush type
draw.pencilPencilPencil brush type
draw.eraserEraserEraser tool
draw.sizeSizeBrush size label
draw.colorColorBrush color label
draw.opacityOpacityBrush opacity label
Text Keys
Key Default Description
text.addTextAdd TextAdd text button
text.fontFontFont selector label
text.sizeSizeFont size label
text.colorColorText color label
text.boldBoldBold toggle label
text.italicItalicItalic toggle label
text.underlineUnderlineUnderline toggle label
text.alignAlignText alignment label
text.lineHeightLine HeightLine height label
text.letterSpacingSpacingLetter spacing label
Finetune Keys
Key Default Description
finetune.brightnessBrightnessBrightness slider
finetune.contrastContrastContrast slider
finetune.saturationSaturationSaturation slider
finetune.exposureExposureExposure slider
finetune.temperatureTemperatureTemperature slider
finetune.hueHueHue slider
finetune.vibranceVibranceVibrance slider

Dialog Keys

These keys are used in dialog windows and modal prompts throughout the editor.

Key Default Description
dialog.newImage New Image New image dialog title
dialog.openImage Open Image Open image label
dialog.blankCanvas Blank Canvas Blank canvas option
dialog.width Width Width label
dialog.height Height Height label

Message Keys

These keys control status messages, loading indicators, and user-facing notifications.

Key Default Description
msg.loading Loading... Loading indicator
msg.saving Saving... Saving indicator
msg.error An error occurred Generic error message
msg.unsavedChanges You have unsaved changes Unsaved changes warning

Adding a Complete Language

For production use, it is recommended to define all translation keys for a language in a dedicated file. Below is a full example of adding Spanish translations.

Spanish (es)

translations/es.js
export const spanishTranslations = {
  // Navigation
  'nav.filter': 'Filtros',
  'nav.crop': 'Recortar',
  'nav.draw': 'Dibujar',
  'nav.text': 'Texto',
  'nav.shapes': 'Formas',
  'nav.stickers': 'Stickers',
  'nav.frame': 'Marco',
  'nav.resize': 'Redimensionar',
  'nav.finetune': 'Ajustes',
  'nav.fill': 'Relleno',
  'nav.corners': 'Esquinas',
  'nav.redact': 'Censurar',

  // Toolbar
  'toolbar.save': 'Guardar',
  'toolbar.close': 'Cerrar',
  'toolbar.undo': 'Deshacer',
  'toolbar.redo': 'Rehacer',
  'toolbar.apply': 'Aplicar',
  'toolbar.cancel': 'Cancelar',
  'toolbar.zoomIn': 'Acercar',
  'toolbar.zoomOut': 'Alejar',
  'toolbar.resetZoom': 'Restablecer zoom',

  // Dialogs
  'dialog.newImage': 'Nueva imagen',
  'dialog.openImage': 'Abrir imagen',
  'dialog.blankCanvas': 'Lienzo en blanco',
  'dialog.width': 'Ancho',
  'dialog.height': 'Alto',

  // Messages
  'msg.loading': 'Cargando...',
  'msg.saving': 'Guardando...',
  'msg.error': 'Ocurrió un error',
  'msg.unsavedChanges': 'Tienes cambios sin guardar',
};
JavaScript
import { Imigi } from 'imigi';
import { spanishTranslations } from './translations/es';

const editor = await Imigi.init({
  selector: '#editor',
  image: 'photo.jpg',
  activeLanguage: 'es',
  languages: {
    es: spanishTranslations,
  },
});

French (fr)

translations/fr.js
export const frenchTranslations = {
  // Navigation
  'nav.filter': 'Filtres',
  'nav.crop': 'Recadrer',
  'nav.draw': 'Dessiner',
  'nav.text': 'Texte',
  'nav.shapes': 'Formes',
  'nav.stickers': 'Autocollants',
  'nav.frame': 'Cadre',
  'nav.resize': 'Redimensionner',
  'nav.finetune': 'Réglages',
  'nav.fill': 'Remplissage',
  'nav.corners': 'Coins',
  'nav.redact': 'Censurer',

  // Toolbar
  'toolbar.save': 'Enregistrer',
  'toolbar.close': 'Fermer',
  'toolbar.undo': 'Annuler',
  'toolbar.redo': 'Rétablir',
  'toolbar.apply': 'Appliquer',
  'toolbar.cancel': 'Annuler',
  'toolbar.zoomIn': 'Zoom avant',
  'toolbar.zoomOut': 'Zoom arrière',
  'toolbar.resetZoom': 'Réinitialiser le zoom',

  // Messages
  'msg.loading': 'Chargement...',
  'msg.saving': 'Enregistrement...',
  'msg.error': 'Une erreur est survenue',
  'msg.unsavedChanges': 'Vous avez des modifications non enregistrées',
};

German (de)

translations/de.js
export const germanTranslations = {
  // Navigation
  'nav.filter': 'Filter',
  'nav.crop': 'Zuschneiden',
  'nav.draw': 'Zeichnen',
  'nav.text': 'Text',
  'nav.shapes': 'Formen',
  'nav.stickers': 'Aufkleber',
  'nav.frame': 'Rahmen',
  'nav.resize': 'Größe ändern',
  'nav.finetune': 'Feineinstellung',
  'nav.fill': 'Füllung',
  'nav.corners': 'Ecken',
  'nav.redact': 'Schwärzen',

  // Toolbar
  'toolbar.save': 'Speichern',
  'toolbar.close': 'Schließen',
  'toolbar.undo': 'Rückgängig',
  'toolbar.redo': 'Wiederholen',
  'toolbar.apply': 'Anwenden',
  'toolbar.cancel': 'Abbrechen',
  'toolbar.zoomIn': 'Vergrößern',
  'toolbar.zoomOut': 'Verkleinern',
  'toolbar.resetZoom': 'Zoom zurücksetzen',

  // Messages
  'msg.loading': 'Laden...',
  'msg.saving': 'Speichern...',
  'msg.error': 'Ein Fehler ist aufgetreten',
  'msg.unsavedChanges': 'Sie haben ungespeicherte Änderungen',
};
Tip

Store each language in its own file (e.g. translations/es.js, translations/fr.js) and import only the languages your application needs. This keeps your bundle size small with tree-shaking.

RTL (Right-to-Left) Support

Imigi supports right-to-left (RTL) languages such as Arabic and Hebrew. When you set the active language to an RTL locale, the editor automatically mirrors the layout, including the toolbar, navigation, and panel positions.

To enable RTL, set the dir property in your language configuration:

JavaScript
const editor = await Imigi.init({
  selector: '#editor',
  image: 'photo.jpg',
  activeLanguage: 'ar',
  languages: {
    ar: {
      dir: 'rtl',
      'nav.filter': '\u0641\u0644\u0627\u062a\u0631',
      'nav.crop': '\u0642\u0635',
      'nav.draw': '\u0631\u0633\u0645',
      'nav.text': '\u0646\u0635',
      'toolbar.save': '\u062d\u0641\u0638',
      'toolbar.close': '\u0625\u063a\u0644\u0627\u0642',
      'toolbar.undo': '\u062a\u0631\u0627\u062c\u0639',
      'toolbar.redo': '\u0625\u0639\u0627\u062f\u0629',
      // ... more Arabic translations
    },
  },
});
Warning

When using RTL languages, ensure that your page's <html dir="rtl"> attribute is also set if you want the entire page to follow RTL layout. Imigi handles its own internal RTL mirroring independently.

The following elements are automatically mirrored in RTL mode:

Dynamic Language Switching

You can change the editor's language at runtime without reinitializing the editor. Use the setConfig() method to update the activeLanguage and provide the corresponding translations.

JavaScript
import { frenchTranslations } from './translations/fr';
import { germanTranslations } from './translations/de';

// Switch to French at runtime
editor.setConfig({
  activeLanguage: 'fr',
  languages: {
    fr: frenchTranslations,
  },
});

// Switch to German at runtime
editor.setConfig({
  activeLanguage: 'de',
  languages: {
    de: germanTranslations,
  },
});

// Switch back to English (built-in)
editor.setConfig({
  activeLanguage: 'en',
});
Tip

When switching back to English, you do not need to provide a languages object since English is the built-in default. All labels automatically revert to their default values.

A common pattern is to build a language selector dropdown that triggers the switch:

JavaScript
const languageMap = {
  en: null,           // Built-in default
  es: spanishTranslations,
  fr: frenchTranslations,
  de: germanTranslations,
};

function switchLanguage(langCode) {
  const config = { activeLanguage: langCode };
  if (languageMap[langCode]) {
    config.languages = { [langCode]: languageMap[langCode] };
  }
  editor.setConfig(config);
}

// Wire up a <select> element
document.getElementById('lang-select')
  .addEventListener('change', (e) => switchLanguage(e.target.value));

Partial Translations

You do not need to translate every single key. Imigi supports partial translations -- any key that is not found in your custom language object will automatically fall back to the built-in English default.

This is useful when you want to quickly localize only the most visible parts of the editor (such as navigation and toolbar labels) while leaving less common strings in English.

JavaScript
const editor = await Imigi.init({
  selector: '#editor',
  image: 'photo.jpg',
  activeLanguage: 'pt',
  languages: {
    pt: {
      // Only translate the most visible labels
      'toolbar.save': 'Salvar',
      'toolbar.close': 'Fechar',
      'toolbar.undo': 'Desfazer',
      'toolbar.redo': 'Refazer',
      'nav.filter': 'Filtros',
      'nav.crop': 'Cortar',
      // All other keys fall back to English
    },
  },
});
Best Practice

Start with a partial translation covering navigation and toolbar keys, then gradually expand to cover tool-specific and dialog keys as your localization matures. This lets you ship localized builds faster.

Extracting Translation Keys

Imigi provides a built-in CLI command to extract all translation keys used in the editor source code. This is useful for generating a template file that translators can fill in.

Terminal
npm run extract-i18n

This command scans the Imigi source code and outputs a JSON file containing every translation key with its default English value:

i18n-keys.json (generated)
{
  "nav.filter": "Filters",
  "nav.crop": "Crop",
  "nav.draw": "Draw",
  "nav.text": "Text",
  "toolbar.save": "Save",
  "toolbar.close": "Close",
  // ... all keys
}
Tip

You can pipe the output into translation management tools like i18next, Crowdin, or Lokalise to streamline your localization workflow.

Community Translations

The Imigi community maintains translations for several popular languages. You can find community-contributed translation files in the translations directory of the GitHub repository.

Available community translations include:

Contribute

Want to add a new language or improve an existing translation? Contributions are welcome. Fork the repository, add or update a translation file, and open a pull request. See the contributing guide for details.

Warning

Community translations may not always be 100% complete or up to date with the latest version. Always verify translations against the keys listed in the Translation Keys Reference above.

On This Page
Active Language Custom Translations Keys Reference Navigation Keys Toolbar Keys Tool-specific Keys Dialog Keys Message Keys Complete Language RTL Support Dynamic Switching Partial Translations Extracting Keys Community Translations