From b8905575d1a0841f783ed1d874ea8c6442c92d09 Mon Sep 17 00:00:00 2001 From: ilyakabanov Date: Tue, 27 Jan 2026 22:28:54 +0300 Subject: [PATCH] Update Russian translation for databases guide --- .../po/ru/guide_databases_db-migrations.md.po | 6 +- _translations/po/ru/guide_index.md.po | 2 +- .../po/ru/guide_start_databases.md.po | 150 ++++++------ .../po/ru/guide_structure_domain.md.po | 71 +++--- .../po/ru/guide_structure_service.md.po | 2 +- src/ru/guide/index.md | 2 +- src/ru/guide/start/databases.md | 218 +++++++++--------- src/ru/guide/structure/domain.md | 2 +- src/ru/guide/structure/service.md | 2 +- 9 files changed, 233 insertions(+), 222 deletions(-) diff --git a/_translations/po/ru/guide_databases_db-migrations.md.po b/_translations/po/ru/guide_databases_db-migrations.md.po index 81290951..ecc26666 100644 --- a/_translations/po/ru/guide_databases_db-migrations.md.po +++ b/_translations/po/ru/guide_databases_db-migrations.md.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2025-12-27 10:28+0000\n" +"POT-Creation-Date: 2026-01-08 08:54+0000\n" "PO-Revision-Date: 2025-09-04 11:19+0500\n" "Last-Translator: Automatically generated\n" "Language-Team: none\n" @@ -146,9 +146,9 @@ msgstr "" #. type: Fenced code block (sh) #: ../src/guide/databases/db-migrations.md ../src/guide/start/databases.md -#, fuzzy, no-wrap +#, no-wrap msgid "make composer require yiisoft/db-migration\n" -msgstr "composer install yiisoft/security\n" +msgstr "" #. type: Plain text #: ../src/guide/databases/db-migrations.md diff --git a/_translations/po/ru/guide_index.md.po b/_translations/po/ru/guide_index.md.po index 37b6e9b6..b99583cf 100644 --- a/_translations/po/ru/guide_index.md.po +++ b/_translations/po/ru/guide_index.md.po @@ -264,7 +264,7 @@ msgstr "" #: ../src/guide/index.md ../src/guide/start/databases.md #, no-wrap msgid "Working with databases" -msgstr "" +msgstr "Работа с базами данных" #. type: Bullet: '- ' #: ../src/guide/index.md diff --git a/_translations/po/ru/guide_start_databases.md.po b/_translations/po/ru/guide_start_databases.md.po index 58367218..87506469 100644 --- a/_translations/po/ru/guide_start_databases.md.po +++ b/_translations/po/ru/guide_start_databases.md.po @@ -5,9 +5,9 @@ # msgid "" msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" +"Project-Id-Version: \n" "POT-Creation-Date: 2026-01-24 08:55+0000\n" -"PO-Revision-Date: 2025-09-04 11:19+0500\n" +"PO-Revision-Date: 2026-01-27 22:23+0300\n" "Last-Translator: Automatically generated\n" "Language-Team: none\n" "Language: ru\n" @@ -15,12 +15,13 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" +"X-Generator: Poedit 3.8\n" #. type: Fenced code block (sh) #: ../src/guide/databases/db-migrations.md ../src/guide/start/databases.md -#, fuzzy, no-wrap +#, no-wrap msgid "make composer require yiisoft/db-migration\n" -msgstr "composer install yiisoft/security\n" +msgstr "" #. type: Fenced code block (php) #: ../src/guide/databases/db-migrations.md ../src/guide/start/databases.md @@ -36,12 +37,12 @@ msgstr "" #: ../src/guide/index.md ../src/guide/start/databases.md #, no-wrap msgid "Working with databases" -msgstr "" +msgstr "Работа с базами данных" #. type: Plain text #: ../src/guide/start/databases.md msgid "Yii doesn't dictate using a particular database or storage for your application. There are many ways you can work with relational databases:" -msgstr "" +msgstr "Yii не требует использования конкретной базы данных или хранилища для вашего приложения. Существует множество способов работы с реляционными базами данных:" #. type: Bullet: '- ' #: ../src/guide/start/databases.md @@ -56,24 +57,22 @@ msgstr "" #. type: Bullet: '- ' #: ../src/guide/start/databases.md msgid "[Cycle](https://github.com/cycle) via [Yii Cycle package](https://github.com/yiisoft/yii-cycle)" -msgstr "" +msgstr "[Cycle](https://github.com/cycle) через [пакет Yii Cycle](https://github.com/yiisoft/yii-cycle)" #. type: Bullet: '- ' #: ../src/guide/start/databases.md msgid "[Doctrine](https://www.doctrine-project.org/) via [Yii Doctrine package](https://github.com/stargazer-team/yii-doctrine)" -msgstr "" +msgstr "[Doctrine](https://www.doctrine-project.org/) через [пакет Yii Doctrine](https://github.com/stargazer-team/yii-doctrine)" #. type: Bullet: '- ' #: ../src/guide/start/databases.md -#, fuzzy -#| msgid "[PHP manual: security](https://www.php.net/manual/en/security.php)" msgid "[PDO](https://www.php.net/manual/en/book.pdo.php)" -msgstr "[Руководство по PHP: безопасность](https://www.php.net/manual/en/security.php)" +msgstr "[PDO](https://www.php.net/manual/ru/book.pdo.php)" #. type: Plain text #: ../src/guide/start/databases.md msgid "For non-relational ones, there are usually official libraries available:" -msgstr "" +msgstr "Для нереляционных баз данных обычно доступны официальные библиотеки:" #. type: Bullet: '- ' #: ../src/guide/start/databases.md @@ -93,23 +92,23 @@ msgstr "" #. type: Plain text #: ../src/guide/start/databases.md msgid "In this guide, we will focus on working with relational databases using Yii DB. We'll use PostgreSQL to implement a simple CRUD (create read update delete)." -msgstr "" +msgstr "В этом руководстве мы сосредоточимся на работе с реляционными базами данных с помощью Yii DB. Мы будем использовать PostgreSQL для реализации простого CRUD (создание, чтение, обновление, удаление)." #. type: Title ## #: ../src/guide/start/databases.md #, no-wrap msgid "Installing PostgreSQL" -msgstr "" +msgstr "Установка PostgreSQL" #. type: Plain text #: ../src/guide/start/databases.md msgid "You need to install PostgreSQL. If you prefer not to use Docker, [get the installer from official website](https://www.postgresql.org/download/), install it and create a database." -msgstr "" +msgstr "Необходимо установить PostgreSQL. Если вы предпочитаете не использовать Docker, [загрузите установщик с официального сайта](https://www.postgresql.org/download/), установите его и создайте базу данных." #. type: Plain text #: ../src/guide/start/databases.md msgid "If you use Docker, it is a bit simpler. Modify `docker/dev/compose.yml`:" -msgstr "" +msgstr "При использовании Docker всё немного проще. Измените файл `docker/dev/compose.yml`:" #. type: Fenced code block (yaml) #: ../src/guide/start/databases.md @@ -160,41 +159,39 @@ msgstr "" #. type: Plain text #: ../src/guide/start/databases.md msgid "Note that we add `depends_on` so application waits for database to be up." -msgstr "" +msgstr "Обратите внимание, что мы добавляем `depends_on`, чтобы приложение ждало запуска базы данных." #. type: Plain text #: ../src/guide/start/databases.md msgid "Also, we'll need a `pdo_pgsql` extension to communicate with PostgreSQL. You can enable it locally in `php.ini`. If you use Docker, check `docker/Dockerfile` and add `pdo_pgsql` in `install-php-extensions` list. Then rebuild PHP image with `make build && make down && make up`." -msgstr "" +msgstr "Также потребуется расширение `pdo_pgsql` для взаимодействия с PostgreSQL. Его можно включить локально в файле `php.ini`. При использовании Docker проверьте файл `docker/Dockerfile` и добавьте `pdo_pgsql` в список `install-php-extensions`. Затем пересоберите образ PHP командой `make build && make down && make up`." #. type: Title ## #: ../src/guide/start/databases.md -#, fuzzy, no-wrap -#| msgid "Configuring SSL peer validation" +#, no-wrap msgid "Configuring connection" -msgstr "Настройка проверки SSL-сертификата" +msgstr "Настройка подключения" #. type: Plain text #: ../src/guide/start/databases.md msgid "Now that we have the database, it's time to define the connection." -msgstr "" +msgstr "Теперь, когда у нас есть база данных, пришло время определить подключение." #. type: Plain text #: ../src/guide/start/databases.md msgid "First we need a package to be installed:" -msgstr "" +msgstr "Сначала нам нужно установить пакет:" #. type: Fenced code block (sh) #: ../src/guide/start/databases.md -#, fuzzy, no-wrap -#| msgid "composer install yiisoft/security\n" +#, no-wrap msgid "make composer require yiisoft/db-pgsql\n" -msgstr "composer install yiisoft/security\n" +msgstr "" #. type: Plain text #: ../src/guide/start/databases.md msgid "Now create `config/common/di/db-pgsql.php`:" -msgstr "" +msgstr "Теперь создайте файл `config/common/di/db-pgsql.php`:" #. type: Fenced code block (php) #: ../src/guide/start/databases.md @@ -225,7 +222,7 @@ msgstr "" #. type: Plain text #: ../src/guide/start/databases.md msgid "And define parameters in `config/common/params.php`. For Docker that would be:" -msgstr "" +msgstr "Определите параметры в файле `config/common/params.php`. Для Docker это будет:" #. type: Fenced code block (php) #: ../src/guide/start/databases.md @@ -246,38 +243,38 @@ msgstr "" #. type: Plain text #: ../src/guide/start/databases.md msgid "`db` host is resolved automatically within the Docker network." -msgstr "" +msgstr "Хост `db` автоматически разрешается внутри сети Docker." #. type: Plain text #: ../src/guide/start/databases.md msgid "For local installation without Docker the host in Dsn would be `localhost`. You'll have to adjust the rest to match how you configured the database." -msgstr "" +msgstr "Для локальной установки без Docker хост в Dsn будет `localhost`. Остальные параметры необходимо настроить в соответствии с конфигурацией вашей базы данных." #. type: Title ## #: ../src/guide/start/databases.md #, no-wrap msgid "Creating and applying migrations" -msgstr "" +msgstr "Создание и применение миграций" #. type: Plain text #: ../src/guide/start/databases.md msgid "For the initial state of the application and for further database changes, it is a good idea to use migrations. These are files that create database changes. Applied migrations are tracked in the database, allowing us to know the current state and which migrations remain to be applied." -msgstr "" +msgstr "Для начальной настройки приложения и для дальнейших изменений базы данных рекомендуется использовать миграции. Это файлы, которые описывают изменения в структуре базы данных. Примененные миграции отслеживаются в базе данных, что позволяет отслеживать текущее состояние и определять, какие миграции еще необходимо применить." #. type: Plain text #: ../src/guide/start/databases.md msgid "To use migrations we need another package installed:" -msgstr "" +msgstr "Для использования миграций нам нужно установить еще один пакет:" #. type: Plain text #: ../src/guide/start/databases.md msgid "Create a directory to store migrations `src/Migration` right in the project root. Add the following configuration to `config/common/params.php`:" -msgstr "" +msgstr "Создайте каталог для хранения миграций `src/Migration` в корневой директории проекта. Добавьте следующую конфигурацию в файл `config/common/params.php`:" #. type: Plain text #: ../src/guide/start/databases.md msgid "Now you can use `make yii migrate:create page` to create a new migration. For our example we need a `page` table with some columns:" -msgstr "" +msgstr "Теперь можно использовать команду `make yii migrate:create page` для создания новой миграции. Для нашего примера необходима таблица `page` с несколькими столбцами:" #. type: Fenced code block (php) #: ../src/guide/start/databases.md @@ -318,40 +315,39 @@ msgstr "" #. type: Plain text #: ../src/guide/start/databases.md msgid "The `M251102141707Page` name of the migration class is generated so replace the `Page` suffix with the actual migration name. The `M251102141707` prefix is needed to find and sort migrations in the order they were added." -msgstr "" +msgstr "Имя класса миграции `M251102141707Page` генерируется автоматически, поэтому замените суффикс `Page` на фактическое имя миграции. Префикс `M251102141707` необходим для поиска и сортировки миграций в порядке их добавления." #. type: Plain text #: ../src/guide/start/databases.md msgid "Note that we use UUID as the primary key. We are going to generate these IDs ourselves instead of relying on database so we'll need an extra compose package for that." -msgstr "" +msgstr "Обратите внимание, что мы используем UUID в качестве первичного ключа. Мы собираемся генерировать эти идентификаторы самостоятельно, вместо того чтобы полагаться на базу данных, для этого нам понадобится добавить дополнительный пакет composer." #. type: Fenced code block (shell) #: ../src/guide/start/databases.md -#, fuzzy, no-wrap -#| msgid "composer install yiisoft/security\n" +#, no-wrap msgid "make composer require ramsey/uuid\n" -msgstr "composer install yiisoft/security\n" +msgstr "" #. type: Plain text #: ../src/guide/start/databases.md msgid "While the storage space is a bit bigger than using int, the workflow with such IDs is beneficial. Since you generate the ID yourself so you can define a set of related data and save it in a single transaction. The entities that define this set of data in the code are often called an \"aggregate\"." -msgstr "" +msgstr "Хотя объем хранилища немного больше, чем при использовании int, работа с такими идентификаторами имеет свои преимущества. Поскольку идентификатор генерируется самостоятельно, можно определить набор связанных данных и сохранить его в одной транзакции. Сущности, которые определяют этот набор данных в коде, часто называются \"агрегатом\"." #. type: Plain text #: ../src/guide/start/databases.md msgid "Apply the migration with `make yii migrate:up`." -msgstr "" +msgstr "Примените миграцию с помощью `make yii migrate:up`." #. type: Title ## #: ../src/guide/start/databases.md #, no-wrap msgid "An entity" -msgstr "" +msgstr "Сущность" #. type: Plain text #: ../src/guide/start/databases.md msgid "Now that you have a table it is time to define an entity in the code. Create `src/Web/Page/Page.php`:" -msgstr "" +msgstr "Теперь, когда таблица создана, необходимо определить сущность в коде. Создайте файл `src/Web/Page/Page.php`:" #. type: Fenced code block (php) #: ../src/guide/start/databases.md @@ -404,17 +400,17 @@ msgstr "" #: ../src/guide/structure/service.md #, no-wrap msgid "Repository" -msgstr "" +msgstr "Репозиторий" #. type: Plain text #: ../src/guide/start/databases.md msgid "Now that we have entity, we need a place for methods to save an entity, delete it and select either a single page or multiple pages." -msgstr "" +msgstr "Теперь, когда сущность создана, необходимо место для методов сохранения, удаления и выборки одной или нескольких страниц." #. type: Plain text #: ../src/guide/start/databases.md msgid "Create `src/Web/Page/PageRepository.php`:" -msgstr "" +msgstr "Создайте файл `src/Web/Page/PageRepository.php`:" #. type: Fenced code block (php) #: ../src/guide/start/databases.md @@ -515,65 +511,65 @@ msgstr "" #. type: Plain text #: ../src/guide/start/databases.md msgid "In this repository there are both methods to get data and `save()` to do insert or update. DB returns raw data as arrays but our repository automatically creates entities from this raw data so later we operate typed data." -msgstr "" +msgstr "В этом репозитории есть методы для получения данных и метод `save()` для вставки или обновления записей. База данных возвращает необработанные данные в виде массивов, но репозиторий автоматически создает из них сущности, что позволяет в дальнейшем работать с типизированными данными." #. type: Title ## #: ../src/guide/start/databases.md #, no-wrap msgid "Actions and routes" -msgstr "" +msgstr "Действия и маршруты" #. type: Plain text #: ../src/guide/start/databases.md msgid "We need some actions to:" -msgstr "" +msgstr "Необходимо создать действия для:" #. type: Bullet: '1. ' #: ../src/guide/start/databases.md msgid "List all pages." -msgstr "" +msgstr "Вывести список всех страниц." #. type: Bullet: '2. ' #: ../src/guide/start/databases.md msgid "View a page." -msgstr "" +msgstr "Просмотреть страницу." #. type: Bullet: '3. ' #: ../src/guide/start/databases.md msgid "Delete a page." -msgstr "" +msgstr "Удалить страницу." #. type: Bullet: '4. ' #: ../src/guide/start/databases.md msgid "Create a page." -msgstr "" +msgstr "Создать страницу." #. type: Bullet: '5. ' #: ../src/guide/start/databases.md msgid "Update a page." -msgstr "" +msgstr "Обновить страницу." #. type: Plain text #: ../src/guide/start/databases.md msgid "Then we need routing for all these." -msgstr "" +msgstr "Затем необходимо настроить маршрутизацию для всех этих действий." #. type: Plain text #: ../src/guide/start/databases.md msgid "Let's tackle these one by one." -msgstr "" +msgstr "Рассмотрим их по очереди." #. type: Title ### #: ../src/guide/start/databases.md #, fuzzy, no-wrap #| msgid "Install the package" msgid "List all pages" -msgstr "Установка пакета" +msgstr "Вывести список всех страниц" #. type: Plain text #: ../src/guide/start/databases.md msgid "Create `src/Web/Page/ListAction.php`:" -msgstr "" +msgstr "Создайте файл `src/Web/Page/ListAction.php`:" #. type: Fenced code block (php) #: ../src/guide/start/databases.md @@ -609,7 +605,7 @@ msgstr "" #. type: Plain text #: ../src/guide/start/databases.md msgid "Define list view in `src/Web/Page/list.php`:" -msgstr "" +msgstr "Создайте представление списка в файле `src/Web/Page/list.php`:" #. type: Fenced code block (php) #: ../src/guide/start/databases.md @@ -639,12 +635,12 @@ msgstr "" #: ../src/guide/start/databases.md #, no-wrap msgid "View a page" -msgstr "" +msgstr "Просмотр страницы" #. type: Plain text #: ../src/guide/start/databases.md msgid "Create `src/Web/Page/ViewAction.php`:" -msgstr "" +msgstr "Создайте файл `src/Web/Page/ViewAction.php`:" #. type: Fenced code block (php) #: ../src/guide/start/databases.md @@ -689,7 +685,7 @@ msgstr "" #. type: Plain text #: ../src/guide/start/databases.md msgid "Now, a template in `src/Web/Page/view.php`:" -msgstr "" +msgstr "Теперь создайте шаблон в файле `src/Web/Page/view.php`:" #. type: Fenced code block (php) #: ../src/guide/start/databases.md @@ -728,18 +724,18 @@ msgstr "" #. type: Plain text #: ../src/guide/start/databases.md msgid "In this view we have a form that submits a request for page deletion. Handing it with `GET` is common as well, but it is very wrong. Since deletion changes data, it needs to be handled by one of the non-idempotent HTTP methods. We use POST and a form in our example, but it could be `DELETE` and async request made with JavaScript. The button could be later styled properly to look similar to the \"Edit\"." -msgstr "" +msgstr "В этом представлении есть форма, которая отправляет запрос на удаление страницы. Обработка таких запросов через `GET` тоже встречается, но это неправильно. Поскольку удаление изменяет данные, оно должно обрабатываться одним из неидемпотентных HTTP-методов. В нашем примере используется POST и форма, но это может быть и `DELETE` с асинхронным запросом на JavaScript. Кнопку можно позже стилизовать, чтобы она выглядела похоже на \"Редактировать\"." #. type: Title ### #: ../src/guide/start/databases.md #, no-wrap msgid "Delete a page" -msgstr "" +msgstr "Удаление страницы" #. type: Plain text #: ../src/guide/start/databases.md msgid "Create `src/Web/Page/DeleteAction.php`:" -msgstr "" +msgstr "Создайте файл `src/Web/Page/DeleteAction.php`:" #. type: Fenced code block (php) #: ../src/guide/start/databases.md @@ -783,12 +779,12 @@ msgstr "" #: ../src/guide/start/databases.md #, no-wrap msgid "Create or update a page" -msgstr "" +msgstr "Создание или обновление страницы" #. type: Plain text #: ../src/guide/start/databases.md msgid "First of all, we need a form at `src/Web/Page/Form.php`:" -msgstr "" +msgstr "Прежде всего, необходимо создать форму в файле `src/Web/Page/Form.php`:" #. type: Fenced code block (php) #: ../src/guide/start/databases.md @@ -819,7 +815,7 @@ msgstr "" #. type: Plain text #: ../src/guide/start/databases.md msgid "Then an action. Create `src/Web/Page/EditAction.php`:" -msgstr "" +msgstr "Затем создайте действие в файле `src/Web/Page/EditAction.php`:" #. type: Fenced code block (php) #: ../src/guide/start/databases.md @@ -907,17 +903,17 @@ msgstr "" #: ../src/guide/start/databases.md #, no-wrap msgid "Note that `Uuid::uuid7()->toString()` won't work for MySQL and you'll need bytes instead, `Uuid::uuid7()->getBytes()`.\n" -msgstr "" +msgstr "Обратите внимание, что `Uuid::uuid7()->toString()` не будет работать для MySQL, и вам понадобятся байты вместо этого, `Uuid::uuid7()->getBytes()`.\n" #. type: Plain text #: ../src/guide/start/databases.md msgid "In the above we use a special slug in the URL for new pages so the URL looks like `http://localhost/pages/new`. If the page isn't new, we pre-fill the form with the data from the database. Similar to how we did in [Working with forms](forms.md), we handle the form submission. After successful save we redirect to the page view." -msgstr "" +msgstr "В приведенном выше коде используется специальный slug в URL для новых страниц, чтобы URL выглядел как `http://localhost/pages/new`. Если страница не новая, форма предварительно заполняется данными из базы данных. Аналогично тому, как это было сделано в разделе [Работа с формами](forms.md), обрабатывается отправка формы. После успешного сохранения происходит перенаправление на страницу просмотра." #. type: Plain text #: ../src/guide/start/databases.md msgid "Now, a template in `src/Web/Page/edit.php`:" -msgstr "" +msgstr "Теперь создайте шаблон в файле `src/Web/Page/edit.php`:" #. type: Fenced code block (php) #: ../src/guide/start/databases.md @@ -955,12 +951,12 @@ msgstr "" #: ../src/guide/start/databases.md #, no-wrap msgid "Routing" -msgstr "" +msgstr "Маршрутизация" #. type: Plain text #: ../src/guide/start/databases.md msgid "Adjust `config/common/routes.php`:" -msgstr "" +msgstr "Измените файл `config/common/routes.php`:" #. type: Fenced code block (php) #: ../src/guide/start/databases.md @@ -1006,15 +1002,15 @@ msgstr "" #. type: Plain text #: ../src/guide/start/databases.md msgid "Note that we've grouped all page-related routes with a group under `/pages` prefix. That is a convenient way to both not to repeat yourself and add some extra middleware, such as authentication, to the whole group." -msgstr "" +msgstr "Обратите внимание, что все маршруты, связанные со страницами, сгруппированы под префиксом `/pages`. Это удобный способ избежать дублирования кода и применить дополнительные обработчики запросов, такие как аутентификация, ко всем маршрутам в группе." #. type: Title ## #: ../src/guide/start/databases.md #, no-wrap msgid "Trying it out" -msgstr "" +msgstr "Проверка работы" #. type: Plain text #: ../src/guide/start/databases.md msgid "Now try it out by opening `http://localhost/pages` in your browser." -msgstr "" +msgstr "Теперь проверьте результат, открыв в браузере `http://localhost/pages`." diff --git a/_translations/po/ru/guide_structure_domain.md.po b/_translations/po/ru/guide_structure_domain.md.po index 575944f0..04dca5af 100644 --- a/_translations/po/ru/guide_structure_domain.md.po +++ b/_translations/po/ru/guide_structure_domain.md.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2025-11-02 16:25+0000\n" +"POT-Creation-Date: 2026-01-08 08:54+0000\n" "PO-Revision-Date: 2025-09-04 11:19+0500\n" "Last-Translator: Automatically generated\n" "Language-Team: none\n" @@ -17,28 +17,31 @@ msgstr "" "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" #. type: Title ## -#: ../../guide/en/concept/autoloading.md -#: ../../guide/en/security/best-practices.md ../../guide/en/structure/domain.md -#: ../../guide/en/tutorial/console-applications.md +#: ../src/cookbook/organizing-code/structuring-by-use-case-with-vertical-slices.md +#: ../src/guide/concept/autoloading.md ../src/guide/security/best-practices.md +#: ../src/guide/structure/domain.md +#: ../src/guide/tutorial/console-applications.md +#: ../src/internals/004-namespaces.md ../src/internals/007-exceptions.md +#: ../src/internals/008-interfaces.md #, no-wrap msgid "References" msgstr "Ссылки" #. type: Bullet: '- ' -#: ../../guide/en/start/databases.md ../../guide/en/structure/domain.md -#: ../../guide/en/structure/service.md +#: ../src/guide/start/databases.md ../src/guide/structure/domain.md +#: ../src/guide/structure/service.md #, no-wrap msgid "Repository" -msgstr "" +msgstr "Репозиторий" #. type: Title # -#: ../../guide/en/structure/domain.md +#: ../src/guide/structure/domain.md #, no-wrap msgid "Domain" msgstr "" #. type: Plain text -#: ../../guide/en/structure/domain.md +#: ../src/guide/structure/domain.md #, no-wrap msgid "" "The Domain or domain model is what makes the project unique. With requirements and terminology of the problem being solved\n" @@ -48,7 +51,7 @@ msgid "" msgstr "" #. type: Plain text -#: ../../guide/en/structure/domain.md +#: ../src/guide/structure/domain.md #, no-wrap msgid "" "> [!NOTE]\n" @@ -59,130 +62,130 @@ msgid "" msgstr "" #. type: Title ## -#: ../../guide/en/structure/domain.md +#: ../src/guide/structure/domain.md #, no-wrap msgid "Bounded context" msgstr "" #. type: Plain text -#: ../../guide/en/structure/domain.md +#: ../src/guide/structure/domain.md msgid "It's nearly impossible to build a model that solves multiple problems that aren't too complicated by itself. Therefore, it's a good practice to divide the domain into several use-cases and have a separate model for each use-case. Such separated models are called \"bounded contexts.\"" msgstr "" #. type: Title ## -#: ../../guide/en/structure/domain.md +#: ../src/guide/structure/domain.md #, no-wrap msgid "Building blocks" msgstr "" #. type: Plain text -#: ../../guide/en/structure/domain.md +#: ../src/guide/structure/domain.md msgid "There are various building blocks that are typically used when describing domain models. It isn't mandatory to use them all." msgstr "" #. type: Bullet: '- ' -#: ../../guide/en/structure/domain.md ../../guide/en/structure/service.md +#: ../src/guide/structure/domain.md ../src/guide/structure/service.md #, no-wrap msgid "Entity" msgstr "" #. type: Plain text -#: ../../guide/en/structure/domain.md +#: ../src/guide/structure/domain.md msgid "Entity is a uniquely identifiable object such as user, product, payment, etc. When comparing them, you're checking ID, not the attribute values. If there are two objects with different attributes but the same ID, they're considered being the same thing." msgstr "" #. type: Title ### -#: ../../guide/en/structure/domain.md +#: ../src/guide/structure/domain.md #, no-wrap msgid "Value object" msgstr "" #. type: Plain text -#: ../../guide/en/structure/domain.md +#: ../src/guide/structure/domain.md msgid "Value object describes an object by its characteristics. For example, a price that consists of value and currency. When comparing such objects, you're checking actual values. If they match, an object is considered to be the same." msgstr "" #. type: Title ### -#: ../../guide/en/structure/domain.md +#: ../src/guide/structure/domain.md #, no-wrap msgid "Aggregate" msgstr "" #. type: Plain text -#: ../../guide/en/structure/domain.md +#: ../src/guide/structure/domain.md msgid "Aggregate is a set of domain objects such as entities and value objects and additional data that could be treated as a single unit. It usually represents a compound object from a domain model such as shop order or HR person dossier." msgstr "" #. type: Plain text -#: ../../guide/en/structure/domain.md +#: ../src/guide/structure/domain.md msgid "One of the components of an aggregate is called a root. The root identifies an aggregate as a whole and should be used to access it." msgstr "" #. type: Title ### -#: ../../guide/en/structure/domain.md +#: ../src/guide/structure/domain.md #, no-wrap msgid "Domain event" msgstr "" #. type: Plain text -#: ../../guide/en/structure/domain.md +#: ../src/guide/structure/domain.md msgid "An aggregate, while processed, may raise events. For example, when order is confirmed, `OrderConfirmed` event would be risen so other parts of the system may react on these." msgstr "" #. type: Title ### -#: ../../guide/en/structure/domain.md +#: ../src/guide/structure/domain.md #, no-wrap msgid "Data transfer object" msgstr "" #. type: Plain text -#: ../../guide/en/structure/domain.md +#: ../src/guide/structure/domain.md msgid "Data transfer object or DTO is an object whose only purpose is to hold data as it is. It's commonly used to pass data between different services." msgstr "" #. type: Title ### -#: ../../guide/en/structure/domain.md +#: ../src/guide/structure/domain.md #, no-wrap msgid "Service" msgstr "" #. type: Plain text -#: ../../guide/en/structure/domain.md +#: ../src/guide/structure/domain.md msgid "Service is a class that contains a standalone operation within the context of your domain model. See \"[service components](service.md)\"." msgstr "" #. type: Plain text -#: ../../guide/en/structure/domain.md +#: ../src/guide/structure/domain.md msgid "The repository task is to abstract away how domain objects are obtained. These are usually separated into two parts: an interface that stays in the domain layer and an implementation that's situated in the infrastructure layer. In such a way, domain doesn't care how data is obtained and saved and may be focused around the complicated business logic instead." msgstr "" #. type: Plain text -#: ../../guide/en/structure/domain.md +#: ../src/guide/structure/domain.md msgid "Repository is usually implemented as a service." msgstr "" #. type: Title ### -#: ../../guide/en/structure/domain.md +#: ../src/guide/structure/domain.md #, no-wrap msgid "Instantiating building blocks" msgstr "" #. type: Plain text -#: ../../guide/en/structure/domain.md +#: ../src/guide/structure/domain.md msgid "Entity, value object, aggregate, and domain events aren't services and shouldn't be instantiated through DI container. Using `new` is the way to go with these." msgstr "" #. type: Bullet: '- ' -#: ../../guide/en/structure/domain.md +#: ../src/guide/structure/domain.md msgid "[BoundedContext by Martin Fowler](https://martinfowler.com/bliki/BoundedContext.html)" msgstr "" #. type: Bullet: '- ' -#: ../../guide/en/structure/domain.md +#: ../src/guide/structure/domain.md msgid "[ValueObject by Martin Fowler](https://martinfowler.com/bliki/ValueObject.html)" msgstr "" #. type: Bullet: '- ' -#: ../../guide/en/structure/domain.md +#: ../src/guide/structure/domain.md msgid "[Aggregate by Marting Fowler](https://martinfowler.com/bliki/DDD_Aggregate.html)" msgstr "" diff --git a/_translations/po/ru/guide_structure_service.md.po b/_translations/po/ru/guide_structure_service.md.po index 303c03ff..a4a6a857 100644 --- a/_translations/po/ru/guide_structure_service.md.po +++ b/_translations/po/ru/guide_structure_service.md.po @@ -21,7 +21,7 @@ msgstr "" #: ../../guide/en/structure/service.md #, no-wrap msgid "Repository" -msgstr "" +msgstr "Репозиторий" #. type: Bullet: '- ' #: ../../guide/en/structure/domain.md ../../guide/en/structure/service.md diff --git a/src/ru/guide/index.md b/src/ru/guide/index.md index 434dd8cb..470ced5f 100644 --- a/src/ru/guide/index.md +++ b/src/ru/guide/index.md @@ -58,7 +58,7 @@ Documentation](https://www.yiiframework.com/license#docs). - [Assets](views/asset.md) TODO: verify! - [Widgets](views/widget.md) TODO: verify! -## Working with databases +## Работа с базами данных - [Yii DB](https://github.com/yiisoft/db/blob/master/docs/guide/en/README.md) diff --git a/src/ru/guide/start/databases.md b/src/ru/guide/start/databases.md index 2e4e8731..c8078dad 100644 --- a/src/ru/guide/start/databases.md +++ b/src/ru/guide/start/databases.md @@ -1,33 +1,36 @@ -# Working with databases +# Работа с базами данных -Yii doesn't dictate using a particular database or storage for your -application. There are many ways you can work with relational databases: +Yii не требует использования конкретной базы данных или хранилища для вашего +приложения. Существует множество способов работы с реляционными базами +данных: - [Yii DB](https://github.com/yiisoft/db) - [Yii Active Record](https://github.com/yiisoft/active-record) -- [Cycle](https://github.com/cycle) via [Yii Cycle - package](https://github.com/yiisoft/yii-cycle) -- [Doctrine](https://www.doctrine-project.org/) via [Yii Doctrine - package](https://github.com/stargazer-team/yii-doctrine) -- [PDO](https://www.php.net/manual/en/book.pdo.php) +- [Cycle](https://github.com/cycle) через [пакет Yii + Cycle](https://github.com/yiisoft/yii-cycle) +- [Doctrine](https://www.doctrine-project.org/) через [пакет Yii + Doctrine](https://github.com/stargazer-team/yii-doctrine) +- [PDO](https://www.php.net/manual/ru/book.pdo.php) -For non-relational ones, there are usually official libraries available: +Для нереляционных баз данных обычно доступны официальные библиотеки: - [ElasticSearch](https://github.com/elastic/elasticsearch-php) - [Redis](https://redis.io/docs/latest/develop/clients/php/) - ... -In this guide, we will focus on working with relational databases using Yii -DB. We'll use PostgreSQL to implement a simple CRUD (create read update -delete). +В этом руководстве мы сосредоточимся на работе с реляционными базами данных +с помощью Yii DB. Мы будем использовать PostgreSQL для реализации простого +CRUD (создание, чтение, обновление, удаление). -## Installing PostgreSQL +## Установка PostgreSQL -You need to install PostgreSQL. If you prefer not to use Docker, [get the -installer from official website](https://www.postgresql.org/download/), -install it and create a database. +Необходимо установить PostgreSQL. Если вы предпочитаете не использовать +Docker, [загрузите установщик с официального +сайта](https://www.postgresql.org/download/), установите его и создайте базу +данных. -If you use Docker, it is a bit simpler. Modify `docker/dev/compose.yml`: +При использовании Docker всё немного проще. Измените файл +`docker/dev/compose.yml`: ```yaml services: @@ -72,24 +75,26 @@ services: retries: 5 ``` -Note that we add `depends_on` so application waits for database to be up. +Обратите внимание, что мы добавляем `depends_on`, чтобы приложение ждало +запуска базы данных. -Also, we'll need a `pdo_pgsql` extension to communicate with PostgreSQL. You -can enable it locally in `php.ini`. If you use Docker, check -`docker/Dockerfile` and add `pdo_pgsql` in `install-php-extensions` -list. Then rebuild PHP image with `make build && make down && make up`. +Также потребуется расширение `pdo_pgsql` для взаимодействия с +PostgreSQL. Его можно включить локально в файле `php.ini`. При использовании +Docker проверьте файл `docker/Dockerfile` и добавьте `pdo_pgsql` в список +`install-php-extensions`. Затем пересоберите образ PHP командой `make build +&& make down && make up`. -## Configuring connection +## Настройка подключения -Now that we have the database, it's time to define the connection. +Теперь, когда у нас есть база данных, пришло время определить подключение. -First we need a package to be installed: +Сначала нам нужно установить пакет: ```sh make composer require yiisoft/db-pgsql ``` -Now create `config/common/di/db-pgsql.php`: +Теперь создайте файл `config/common/di/db-pgsql.php`: ```php [ @@ -159,8 +165,9 @@ root. Add the following configuration to `config/common/params.php`: ], ``` -Now you can use `make yii migrate:create page` to create a new -migration. For our example we need a `page` table with some columns: +Теперь можно использовать команду `make yii migrate:create page` для +создания новой миграции. Для нашего примера необходима таблица `page` с +несколькими столбцами: ```php generate('page/edit', ['slug' => 'new'])) ?> ``` -### View a page +### Просмотр страницы -Create `src/Web/Page/ViewAction.php`: +Создайте файл `src/Web/Page/ViewAction.php`: ```php close() ?> ``` -In this view we have a form that submits a request for page -deletion. Handing it with `GET` is common as well, but it is very -wrong. Since deletion changes data, it needs to be handled by one of the -non-idempotent HTTP methods. We use POST and a form in our example, but it -could be `DELETE` and async request made with JavaScript. The button could -be later styled properly to look similar to the "Edit". +В этом представлении есть форма, которая отправляет запрос на удаление +страницы. Обработка таких запросов через `GET` тоже встречается, но это +неправильно. Поскольку удаление изменяет данные, оно должно обрабатываться +одним из неидемпотентных HTTP-методов. В нашем примере используется POST и +форма, но это может быть и `DELETE` с асинхронным запросом на +JavaScript. Кнопку можно позже стилизовать, чтобы она выглядела похоже на +"Редактировать". -### Delete a page +### Удаление страницы -Create `src/Web/Page/DeleteAction.php`: +Создайте файл `src/Web/Page/DeleteAction.php`: ```php toString()` won't work for MySQL and you'll need bytes instead, `Uuid::uuid7()->getBytes()`. +Обратите внимание, что `Uuid::uuid7()->toString()` не будет работать для MySQL, и вам понадобятся байты вместо этого, `Uuid::uuid7()->getBytes()`. -In the above we use a special slug in the URL for new pages so the URL looks -like `http://localhost/pages/new`. If the page isn't new, we pre-fill the -form with the data from the database. Similar to how we did in [Working with -forms](forms.md), we handle the form submission. After successful save we -redirect to the page view. +В приведенном выше коде используется специальный slug в URL для новых +страниц, чтобы URL выглядел как `http://localhost/pages/new`. Если страница +не новая, форма предварительно заполняется данными из базы +данных. Аналогично тому, как это было сделано в разделе [Работа с +формами](forms.md), обрабатывается отправка формы. После успешного +сохранения происходит перенаправление на страницу просмотра. -Now, a template in `src/Web/Page/edit.php`: +Теперь создайте шаблон в файле `src/Web/Page/edit.php`: ```php close() ?> ``` -### Routing +### Маршрутизация -Adjust `config/common/routes.php`: +Измените файл `config/common/routes.php`: ```php