Localization
Add translations for the editor's functions based on existing language packages or create your own. Currently, the project supports translations in English and Russian.
js
import Texditor from 'texditor';
import { RuLocale, EnLocale } from "texditor/locales";
// Your own language package
import CustomFrLocale from '../path/to/locales/fr'
const editor = new Texditor({
// HTML element identifier
handle: 'texditor',
// Optional parameter if localization other than "en" is not used
locale: "ru",
// Connecting translations
locales: [
{ code: 'ru', data: RuLocale },
{ code: 'en', data: EnLocale },
{ code: 'fr', data: CustomFrLocale }
],
// Optional parameter that will be used if the language is not defined via the "locale" parameter
defaultLocale: 'en'
});
// Get the language code
const currentLocale = editor.i18n.getLocale();
// Get the default language code
const defaultLocale = editor.i18n.getDefaultLocale();
// Receiving a key transfer
const translation = editor.i18n.get('save', 'Save');Use the following as a basis for custom translations: