editor.js/types/configs/i18n-dictionary.d.ts
Peter Savchenko 21cac86e42
[Feature] i18n (#1106)
* i18n first steps

* i18n internal, toolbox, api for tools

* namespaced api

* tn, t

* tn in block tunes

* join toolbox and inlineTools under toolNames

* translations

* make enum toolTypes

* Update block.ts

* Update src/components/core.ts

Co-Authored-By: George Berezhnoy <gohabereg@users.noreply.github.com>

* add more types

* rm tn

* export i18n types

* upd bundle

* fix tabulation

* Add type-safe namespaces

* upd

* Improve example

* Update toolbox.ts

* improve examplle

* upd

* fix typo

* Add comments for complex types

Co-authored-by: George Berezhnoy <gohabereg@users.noreply.github.com>
Co-authored-by: Georgy Berezhnoy <gohabereg@gmail.com>
2020-04-20 21:25:33 +03:00

94 lines
2.2 KiB
TypeScript

/**
* Structure of the i18n dictionary
*/
export interface I18nDictionary {
/**
* Section for translation Tool Names: both block and inline tools
* Example:
* "toolNames": {
* "Text": "Параграф",
* "Heading": "Заголовок",
* "List": "Список",
* ...
* },
*/
toolNames?: Dictionary;
/**
* Section for passing translations to the external tools classes
* The first-level keys of this object should be equal of keys ot the 'tools' property of EditorConfig
* Includes internal tools: "paragraph", "stub"
*
* Example:
* "tools": {
* "warning": {
* "Title": "Название",
* "Message": "Сообщение",
* },
* "link": {
* "Add a link": "Вставьте ссылку"
* },
* },
*/
tools?: Dictionary;
/**
* Section allows to translate Block Tunes
* The first-level keys of this object should be equal of 'name' ot the 'tools.<toolName>.tunes' property of EditorConfig
* Including some internal block-tunes: "delete", "moveUp", "moveDown
*
* Example:
* "blockTunes": {
* "delete": {
* "Delete": "Удалить"
* },
* "moveUp": {
* "Move up": "Переместить вверх"
* },
* "moveDown": {
* "Move down": "Переместить вниз"
* }
* },
*/
blockTunes?: Dictionary;
/**
* Translation of internal UI components of the editor.js core
*/
ui?: Dictionary;
}
/**
* Represent item of the I18nDictionary config
*/
export interface Dictionary {
/**
* The keys of the object can represent two entities:
* 1. Dictionary key usually is an original string from default locale, like "Convert to"
* 2. Sub-namespace section, like "toolbar.converter.<...>"
*
* Example of 1:
* toolbox: {
* "Add": "Добавить",
* }
*
* Example of 2:
* ui: {
* toolbar: {
* toolbox: { <-- Example of 1
* "Add": "Добавить"
* }
* }
* }
*/
[key: string]: DictValue;
}
/**
* The value of the dictionary can be:
* - other dictionary
* - result translate string
*/
export type DictValue = {[key: string]: Dictionary | string} | string;