Skip to content

Commit

Permalink
docs: end ru translate
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenesius committed Aug 25, 2023
1 parent a64ceaa commit 3a9838f
Show file tree
Hide file tree
Showing 20 changed files with 135 additions and 127 deletions.
2 changes: 1 addition & 1 deletion docs/examples/list.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
- [Simple modal](simple-modal.md)
- [Prompt modal](prompt-modal.md)
- [Multi modal](multi-modals.md)
- [VueRouter with Modals](../ru/examples/vue-router-with-modals.md)
- [VueRouter with Modals](vue-router-with-modals.md)
- [Demo](demo.md)
- [Animation](animation.md)
2 changes: 1 addition & 1 deletion docs/examples/vue-router-with-modals.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ component. It is with the help of it that our components will be wrapped in moda
config file for vue-router:
```ts
import {createRouter, createWebHashHistory} from "vue-router"
import {useModalRouter} from "../../plugin/routerIntegration";
import {useModalRouter} from "jenesius-vue-mdoal";
import Modal from "./any-modal.vue";

const routes = [
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/details-animation.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ to override some properties and styles. Default for animating modal windows uses
**modal-list** as the animation name. To override the animation name, you need
to specify a new one in the configuration:
```ts
import {config} from "../../../../plugin";
import {config} from "jenesius-vue-modal";

config({
animation: "fade" // Any name
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/modal-object.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const modal = await openModal(Modal, {
modal.onclose = () => false

modal.instance.message; // "Welcome"
modal.closed.value; // true
modal.closed.value; // false

modal.close() // The modal will not be closed
```
Expand Down
2 changes: 1 addition & 1 deletion docs/ru/examples/animation.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup>
import App from '../../examples/simple-animation/App.vue';
import App from '../../../examples/simple-animation/App.vue';
</script>

# Кастомные анимации
Expand Down
2 changes: 1 addition & 1 deletion docs/ru/examples/demo.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup>
import App from '../../examples/pretty-modal/App.vue';
import App from '../../../examples/pretty-modal/App.vue';
</script>

# Демо
Expand Down
2 changes: 1 addition & 1 deletion docs/ru/examples/list.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
- [Простое модальное окно](simple-modal.md)
- [Возращение значение из модального окна](prompt-modal.md)
- [Множественные модальные окна](multi-modals.md)
- [vue-router с модальными окнами](../ru/examples/vue-router-with-modals.md)
- [vue-router с модальными окнами](vue-router-with-modals.md)
- [Демо](demo.md)
- [Анимации](animation.md)
4 changes: 2 additions & 2 deletions docs/ru/examples/multi-modals.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup>
import App from '../../examples/multi-modal/App.vue';
import App from '../../../examples/multi-modal/App.vue';
</script>

# Multi Modal
# Множественные модальные окна

<App/>
4 changes: 2 additions & 2 deletions docs/ru/examples/prompt-modal.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup>
import App from '../../examples/prompt-modal/App.vue';
import App from '../../../examples/prompt-modal/App.vue';
</script>

# Prompt Modal
# Возвращаемое значение

<App/>
4 changes: 2 additions & 2 deletions docs/ru/examples/simple-modal.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup>
import App from '../../examples/open-modal/App.vue';
import App from '../../../examples/open-modal/App.vue';
</script>

# Simple Modal
# Простое модальное окно

<App/>
58 changes: 30 additions & 28 deletions docs/ru/guide/guide-navigation-guards.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
# Navigation Guards
# Навигационные хуки

## Information
Sometimes it is necessary to catch the closing of a modal and manage
this state. This can be useful to prevent the user from closing the
modal until they have entered input, or to send a request to the server.
## Информация
Иногда необходимо отловить закрытие модального кона. Это может быть полезно для предотвращения закрытия пользователем
модально, пока они не введут данные или не отправят запрос на сервер.

If the handler returns **false** or **throws an error** , closing
the modal window will be interrupted.
Если обработчик возвращает **false** или **выдает ошибку**, закрытие
модальное окно будет прервано.

Jenesius Vue Modal provides three ways to catch closures:
Jenesius Vue Modal предоставляет три способа перехвата закрытия:

## Onclose
The [openModal](/guide/guide-methods#open-modal) and [pushModal](/guide/guide-methods#push-modal)
methods return Promise, which, if successful,
will return the [modalObject](/guide/modal-object) object. In order to catch the closing of
a modal window, you need to add an event **onclose** to this object:
Методы [openModal](./guide-methods#open-modal) and [pushModal](./guide-methods#push-modal)
возвращают Promise, который в случае успеха
вернет объект [modalObject](./modal-object). Чтобы поймать закрытие
модальное окно, вам нужно добавить событие **onclose** к этому объекту:
```ts
import {openModal} from "jenesius-vue-modal";
const modal = await openModal(VueComponent);
Expand All @@ -23,11 +22,14 @@ let count = 5;

modal.onclose = () => {
count--;
if (count > 0 ) return false; //The modal window will be closed after five attempts.
if (count > 0 ) return false; // Модальное окно закроется после пяти попыток.
}
```
EXAMPLE
If several modal windows are open, and one of them will have an onclose handler that returns false, you can close only those modal windows that were opened after it.
### Пример

Если открыто несколько модальных окон и у одного из них будет обработчик onclose, возвращающий false, вы сможете
закрыть только те модальные окна, которые были открыты после него.

```ts
import {pushModal, closeModal} from "jenesius-vue-modal";

Expand All @@ -37,39 +39,39 @@ const modal3 = await pushModal(VueComponent);

modal2.onclose = () => false;

closeModal(); // close only modal3
closeModal(); // закроется только modal3
```

## In-Component Guards
Finally, the navigation hook can be specified directly in the component using the following options:
## Хук внутри компоненты
Наконец, навигационный хук можно указать непосредственно в компоненте, используя следующие параметры:
- beforeModalClose
```ts
const Foo = {
template: "...",
beforeModalClose() {
// has access to the context of the component instance this.
// имеет доступ к контексту экземпляра компонента this.
}
}
```
## Composition Api
While you can still use built-in functions, Jenesius Vue Modal provides functions for the Composition API:
Хотя вы по-прежнему можете использовать встроенные функции, Jenesius Vue Modal предоставляет функции для Composition API:
```ts
import {onBeforeModalClose} from "jenesius-vue-modal"

export default {
setup() {
onBeforeModalClose(() => {
const answer = window.confirm(
"Do you really want to leave? You have unsaved changes!"
"Вы действительно хочешь уйти? У вас есть несохраненные изменения!"
)
if (!answer) return false
})
}
}
```

## Async Guards
The navigation hook can be asynchronous. The modal window will be closed only when it finishes its work:
## Асинхронный хук
Навигационный хук может быть асинхронным. Модальное окно закроется только тогда, когда завершит свою работу:
```ts
{
async beforeModalClose(){
Expand All @@ -82,17 +84,17 @@ const modal = await openModal(Modal);

modal.onclose = () => {
return new Promise(resolve => {
setTimeout(resolve, 1000); // The modal will be closed after one second.
setTimeout(resolve, 1000); // Модальное окно закроется через одну секунду.
})
}
```

## Close event
Each modal close handler get window parameter: event-close
## Событие close
Каждый обработчик модального закрытия получает параметр окна: event-close
```ts
modal.onclose = (event) => {
// ...
}
```
This *event* stores information about how the modal window is closed. Detailed information about it, about the way to prevent
Closing a modal window by background or by pressing the Esc key can be read [here](/guide/event-close).
Это *событие* хранит информацию о том, как закрывается модальное окно. Подробная информация о нем, о способах предотвращения
закрытия модального окна при нажатии на фон или по нажатию клавиши Esc можно прочитать [здесь](./event-close).
53 changes: 31 additions & 22 deletions docs/ru/guide/guide-returned-value.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
# Return value from Modal
# Возвращение значения

If we are talking about the return value of modal windows, we must first understand their essence. By default, modal windows are treated as a separate layer of logic with their own data model. This approach is convenient and makes developing a web application with modal windows safe. This library inherits this concept.
A modal window is a separate logical level that accepts input parameters and somehow interacts with them.
However, there are times when a modal window is just part of a process. I sometimes encounter such cases (although I try my best to avoid them).
I will describe the solutions that I use in my projects. Starting with the most convenient, ending with those that I would not use:
Если мы говорим о возвращаемом значении модальных окон, мы должны сначала понять их суть.
По умолчанию модальные окна рассматриваются как отдельный уровень логики со своей собственной моделью данных.
Такой подход удобен и делает разработку веб-приложения с модальными окнами безопасной. Эта библиотека наследует
эту концепцию. Модальное окно — это отдельный логический уровень, принимающий входные параметры и каким-то образом с
ними взаимодействующий. Однако бывают случаи, когда модальное окно является лишь частью процесса. Я иногда сталкиваюсь с
такими случаями (хотя стараюсь их избегать). Опишу решения, которые использую в своих проектах. Начиная с самых удобных,
заканчивая теми, которыми я бы не стал пользоваться:

## Использование PromptModal

## Using PromptModal

In vanilla JS, there is a function prompt, which, upon closing the popup, will wrap the entered value. To implement such
logic, let's write a wrapper for the modal window opening function:

File *ModalCode.vue*
В VanillaJS есть функция prompt, которая при закрытии всплывающего окна возвращает введённое значение. Для реализации
такой логики, напишем обертку для функции открытия модального окна:

Файл *ModalCode.vue*
```vue
<template>
<button @click="handleClick">Click</button>
Expand All @@ -23,16 +24,16 @@ import {Modal} from "jenesius-vue-modal";
export default {
methods: {
handleClick() {
// Current emit will close the modal and provided Meth.random()
// result to Promise returned by promptModal
// Modal.EVENT_PROMPT закроет модальное окно и предоставит Math.random()
// результат для Promise, возвращенный PromptModal
this.$emit(Modal.EVENT_PROMPT, Math.random());
}
}
}
</script>
```

How to use:
Как использовать:
```ts
import {promptModal} from "jenesius-vue-modal"
const code = await promptModal(ModalCode);
Expand All @@ -41,20 +42,28 @@ What happened in this example:

- promptModal return Promise, which will be executed when the modal window is closed. It will also be passed the value, which is inside the modal window component.
- To describe the modal window, we implemented a simple input field that was concatenated with value (which is used as return value in the first step)
This is the most elegant solution that I have found so far and often use in my projects.
This is the most elegant solution that I have found so far and often use in my projects.


Что произошло в этом примере:

## Provide Handle
We can also pass a function to be called inside a modal window (Reminds me of the React component logic):
- promptModal возвращает обещание, которое будет выполнено при закрытии модального окна. Результатом `promise` будет
переданное в событие `Modal.EVENT_PROMPT` значение.
- Чтобы описать модальное окно, мы реализовали простую передачу случайного значения по нажатию на кнопку.

Это самое элегантное решение, которое я нашел для себя и часто использую в своих проектах.

## Предоставить Handle
Мы также можем передать функцию для вызова внутри модального окна (напоминает мне логику компонента React):

```ts
const modal = await openModal(Modal, {
handleRequest: (value) => {
// do something
// Делаем что-то
}
})
```
And then in the modal:

И затем в модальном окне:
```vue
<script>
export default {
Expand All @@ -68,15 +77,15 @@ And then in the modal:
</script>
```

## Emit value and closing
## Передать значение и после этого закрыть окно

```vue
// modal.vue
<template>
<button @click = "$emit('return', false)">run</button>
</template>
```
And when we open modal:
И когда мы открываем окно:
```ts
const modal = await openModal(Modal)
modal.on('return', (value) => {
Expand Down
18 changes: 9 additions & 9 deletions docs/ru/guide/integration-installation.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# Installation
# Установка

- Don't forget to [initialize](/guide/getting-started) Jenesius Vue Modal
- When creating router add modal integration:
- Не забудьте [проинициализировать](./getting-start) Jenesius Vue Modal
- При создании роутера добавьте модальную интеграцию:
```ts
import { createWebHistory, createRouter} from "vue-router";
import {useModalRouter} from "jenesius-vue-modal";

const routes = [...];
const router = createRouter({
history: createWebHistory(), // Or any other
history: createWebHistory(),
routes,
});

useModalRouter.init(router);
useModalRouter.init(router); // !
```
Now the modal handler will react to navigation changes.
- Add new route:
Теперь модальный обработчик будет реагировать на изменения навигации.
- Добавьте новый маршрут обёрнутый в `useModalRouter`:
```ts
import Modal from "Modal.vue"

Expand All @@ -26,5 +26,5 @@ const routes = [
}
]
```
Now, when switching to **/any-route**, the window that was passed to
**useModalRouter** will be shown modally
Теперь при переключении на **/any-route** окно, переданное в
**useModalRouter** будет отображаться модальное окно.
18 changes: 7 additions & 11 deletions docs/ru/guide/integration-introduction.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
# Introduction
# Введение

Sometimes it becomes necessary to link vue-router to show a modal window. To
do this, you need to write your own handler for router and integrate it with
opening/closing a modal window. One in Jenesius Vue Modal already has it all,
you just need to connect it.
Иногда возникает необходимость связать vue-router для отображения модального окна. Чтобы сделать это, вам нужно написать
собственный обработчик для маршрутизатора и интегрировать его с открытием/закрытием модального окна. В
Jenesius Vue Modal уже есть все это, вам просто нужно подключить его.

For example, a table of users was created, on the route **/users**. A modal handler
has been added to the route **/users/:id**. Now, when switching to **/users/3**, a
modal window will open into which the input parameters from route, available
in props, will be passed.

Go to example
Например, была создана таблица пользователей по маршруту **/users**. Модальный обработчик
был добавлен в маршрут **/users/:id**. Теперь при переключении на **/users/3**
откроется модальное окно, в котором доступны входные параметры из маршрута. Они будут переданы в качестве `props`.
11 changes: 6 additions & 5 deletions docs/ru/guide/integration-practical.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Particular Qualities
You can use **props** to get input parameters.
# Особые качества
Вы можете использовать **props** для получения входных параметров.
```ts
// user/5
{
Expand All @@ -8,6 +8,7 @@ You can use **props** to get input parameters.
}
}
```
Using **beforeRouteEnter** , **beforeRouteUpdate** , **beforeRouteLeave** is not
possible at this stage. I will try to fix this problem shortly.
BeforeModalClose can be used as a temporary solution.
Использование **beforeRouteEnter** , **beforeRouteUpdate** , **beforeRouteLeave** не является
возможно на данном этапе. Я постараюсь исправить эту проблему в ближайшее время.
BeforeModalClose можно использовать как временное решение.

Loading

0 comments on commit 3a9838f

Please sign in to comment.