https://github.com/mandrasch/strapi-v4-auto-translate
WIP, demo for question to community
https://github.com/mandrasch/strapi-v4-auto-translate
cms i18n strapi
Last synced: 19 days ago
JSON representation
WIP, demo for question to community
- Host: GitHub
- URL: https://github.com/mandrasch/strapi-v4-auto-translate
- Owner: mandrasch
- Created: 2025-08-26T09:45:24.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-08-26T15:58:58.000Z (10 months ago)
- Last Synced: 2025-08-26T21:37:43.517Z (10 months ago)
- Topics: cms, i18n, strapi
- Language: JavaScript
- Homepage:
- Size: 56.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Goal
1. Editors create/update english content
2. Auto-translate (updated!) fields to other languages via deepl automatically
Trying to use
- https://www.npmjs.com/package/strapi-plugin-translate
- https://www.npmjs.com/package/strapi-provider-translate-deepl
### Current state
Trying to use service of strapi plugin auto translate in lifecycle.
**Current problem: create works, but update does not.**
```js
for (const targetLocale of targetLocales) {
console.log(`\nš Starting translation for ${targetLocale}...`);
const batchResult = await translateService.batchTranslate({
sourceLocale: 'en',
targetLocale: targetLocale,
contentType: contentTypeUid,
entityIds: [result.id],
autoPublish: true
});
```
Primary discussion: https://github.com/Fekide/strapi-plugin-translate/discussions/528
See as well:
- https://github.com/Fekide/strapi-plugin-translate/issues/284
- https://github.com/Fekide/strapi-plugin-translate/discussions/283
## Old state - lifecycle manual try (not working)
See https://github.com/mandrasch/strapi-v4-auto-translate/tree/try-v1
## Local Setup
Local development playground for Strapi v4 with MySQL.
1. `cp .env.example .env`
2. `docker compose build`
3. `docker compose up`
4. Import db dump:
Import database dump:
```bash
docker compose exec -T strapiDB sh -c \
'mysql -u root -p"$MYSQL_ROOT_PASSWORD" strapi' < dump.sql.gz
```
5. Login to http://localhost:1337/admin/
User: `admin@example.com`, pw: `Password1!`
6. In future, not yet: Add deepl API keys to `.env`
## Usage
### Export database dump:
```bash
docker compose exec strapiDB sh -c \
'mysqldump -u root -p"$MYSQL_ROOT_PASSWORD" strapi' > dump.sql.gz
```
### Restore a database dump:
```bash
docker compose exec -T strapiDB sh -c \
'mysql -u root -p"$MYSQL_ROOT_PASSWORD" strapi' < dump.sql.gz
```
### Install plugins via:
1. Update `package.json` with new package, e.g. `npm install strapi-plugin-translate` locally
2. restart with CRTL+c / `docker compose down` and
```bash
# (runs `npm i` in Dockerfile)
docker compose up --build
# or
docker compose build
docker compose up
```
TODO: Better approach, do it with `docker compose exex strapi ...`, but mount can't be only for package.json?!
## How was this created?
See base repository template for all details.
Steps for this repo:
- `npm install strapi-plugin-translate`
- add config to `config/plugins.js`
- `npm i strapi-provider-translate-deepl`
- rebuild & restart `docker compose up --build`