Skip to content

Commit

Permalink
Merge pull request #157 from Fekide/109-update-translations
Browse files Browse the repository at this point in the history
feat(admin): add batch updating
  • Loading branch information
sargreal authored Jun 6, 2023
2 parents d5039e8 + 31c5ebc commit d5755b2
Show file tree
Hide file tree
Showing 69 changed files with 2,487 additions and 887 deletions.
44 changes: 7 additions & 37 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 +5,18 @@ on:
- main
- next
jobs:
eslint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install modules
run: yarn
- name: Run ESLint
run: yarn lint

commitlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: wagoid/commitlint-github-action@v5

lint:
uses: ./.github/workflows/lint.yml
unittest:
strategy:
matrix:
version: [14, 16, 18]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.version }}
cache: 'yarn'
- run: yarn
- run: yarn test
- uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./plugin/coverage/clover.xml,./providers/deepl/coverage/clover.xml
flags: unittests
name: codecov-umbrella
uses: ./.github/workflows/unittest.yml
e2e:
uses: ./.github/workflows/e2e.yml

release:
needs:
- eslint
- commitlint
- lint
- unittest
- e2e
name: Release
runs-on: ubuntu-latest
steps:
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/diff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
on:
workflow_call:
jobs:
diff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run diff script
run: sh ./scripts/diff.sh
26 changes: 26 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
on:
workflow_call:
jobs:
e2e:
strategy:
matrix:
node: [14, 16, 18]
strapi: [4.6, 4.7, 4.8, 4.9]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
cache: 'yarn'
- run: VERSION=${{ matrix.strapi }} envsubst < playground/templates/template.package.json > playground/package.json
- run: yarn
- run: yarn workspace playground build
- run: yarn workspace playground e2e
- uses: actions/upload-artifact@v3
if: always()
with:
name: cypress results (node=${{ matrix.node }},strapi=${{ matrix.strapi }})
path: |
playground/cypress/videos/*
playground/cypress/screenshots/*
19 changes: 19 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
on:
workflow_call:
jobs:
eslint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install modules
run: yarn
- name: Run ESLint
run: yarn lint

commitlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: wagoid/commitlint-github-action@v5
42 changes: 7 additions & 35 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,11 @@
name: Pull Request
on: pull_request
jobs:
eslint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install modules
run: yarn
- name: Run ESLint
run: yarn lint

commitlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: wagoid/commitlint-github-action@v5

lint:
uses: ./.github/workflows/lint.yml
diff:
uses: ./.github/workflows/diff.yml
unittest:
strategy:
matrix:
version: [14, 16, 18]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.version }}
cache: 'yarn'
- run: yarn
- run: yarn test
- uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./plugin/coverage/clover.xml,./providers/deepl/coverage/clover.xml
flags: unittests
name: codecov-umbrella
uses: ./.github/workflows/unittest.yml
e2e:
uses: ./.github/workflows/e2e.yml
22 changes: 22 additions & 0 deletions .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
on:
workflow_call:
jobs:
unittest:
strategy:
matrix:
version: [14, 16, 18]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.version }}
cache: 'yarn'
- run: yarn
- run: yarn test
- uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./plugin/coverage/clover.xml,./providers/deepl/coverage/clover.xml,./providers/libretranslate/coverage/clover.xml
flags: unittests
name: codecov-umbrella
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,7 @@ dist
.vscode

build/


**/cypress/videos
**/cypress/screenshots
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
This plugin requires the following, in order to work correctly:

- Strapi v4 (this plugin is not compatible with v3)
- Plugin tested for `v4.6` to `v4.9`
- The plugin **i18n** installed and enabled (`@strapi/plugin-i18n` [[npm](https://www.npmjs.com/package/@strapi/plugin-i18n)])
- The content type to have internationalization enabled (advanced settings in the content type builder)
- In the internationalization settings at least **two** locales
Expand Down Expand Up @@ -92,6 +93,7 @@ module.exports = {
#### Available providers

- [strapi-provider-translate-deepl](https://www.npmjs.com/package/strapi-provider-translate-deepl)
- [strapi-provider-translate-libretranslate](https://www.npmjs.com/package/strapi-provider-translate-libretranslate)

### Configure translation of individual fields/attributes

Expand Down Expand Up @@ -189,6 +191,12 @@ _The related objects are not translated directly, only the relation itself is tr
- the relation goes both ways and would be removed from another object or localization if it was used (the case with oneToOne or oneToMany) -> it is removed
- otherwise the relation is kept

## 🔐 Permissions

Since RBAC was moved to the community edition in Strapi v4.8.0, permissions for endpoints of direct translation, batch translation and api usage can now be granted to other roles than super admins:

![Permissions for Translate plugin](https://github.com/Fekide/strapi-plugin-deepl/blob/main/assets/permissions.png)

## 🧑‍💻 Creating your own translation provider

A translation provider should have the following:
Expand Down Expand Up @@ -270,5 +278,4 @@ return providerClient.translateTexts(texts)
## ⚠ Limitations:

- The translation of Markdown and HTML may vary between different providers
- **Only super admins can translate**. This is currently the case, since permissions were added to the `translate` endpoint. Probably you can change the permissions with an enterprise subscription but I am not sure. If you know how to do that also in the community edition please tell me or open a merge request!
- Relations that do not have a translation of the desired locale will not be translated. To keep the relation you will need to translate both in succession (Behaviour for multi-relations has not yet been analyzed)
Binary file added assets/permissions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion commitlint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ module.exports = {
ignores: [
(message) =>
/^Bumps \[.+]\(.+\) from .+ to .+\.$/m.test(message) ||
/^chore(release)/.test(message),
/^chore\(release\)/.test(message),
],
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"husky": "^8.0.1",
"jest": "^29.4.1",
"lint-staged": "^13.2.0",
"multi-semantic-release": "^3.0.1",
"multi-semantic-release": "^3.0.2",
"semantic-release": "^19.0.5"
},
"config": {
Expand Down
6 changes: 6 additions & 0 deletions playground/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,10 @@ API_TOKEN_SALT=tobemodified
ADMIN_JWT_SECRET=tobemodified
JWT_SECRET=tobemodified
DEEPL_API_KEY=tobemodified
INIT_ADMIN=true
INIT_ADMIN_USERNAME=admin
INIT_ADMIN_PASSWORD=admin
INIT_ADMIN_FIRSTNAME=Admin
INIT_ADMIN_LASTNAME=Admin
INIT_ADMIN_EMAIL=[email protected]
#DEEPL_API_URL=optional
14 changes: 14 additions & 0 deletions playground/.env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
HOST=0.0.0.0
PORT=1337
APP_KEYS="toBeModified1,toBeModified2"
API_TOKEN_SALT=tobemodified
ADMIN_JWT_SECRET=tobemodified
JWT_SECRET=tobemodified
TRANSLATE_PROVIDER=dummy
INIT_ADMIN=true
INIT_ADMIN_USERNAME=admin
INIT_ADMIN_PASSWORD=admin
INIT_ADMIN_FIRSTNAME=Admin
INIT_ADMIN_LASTNAME=Admin
INIT_ADMIN_EMAIL=[email protected]
#DEEPL_API_URL=optional
4 changes: 4 additions & 0 deletions playground/config/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ module.exports = ({ env }) => ({
apiToken: {
salt: env('API_TOKEN_SALT'),
},
rateLimit: {
enabled: false,
},
watchIgnoreFiles: ['./cypress/**/*'],
})
5 changes: 3 additions & 2 deletions playground/config/plugins.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
module.exports = ({ env }) => ({
// ...
translate: {
resolve: "../plugin",
resolve: '../plugin',
enabled: true,
config: {
provider: 'deepl',
provider: env('TRANSLATE_PROVIDER', 'deepl'),
providerOptions: {},
regenerateUids: true,
},
},
// ...
Expand Down
18 changes: 18 additions & 0 deletions playground/cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const { defineConfig } = require('cypress')

const dotenv = require('dotenv')

dotenv.config({ path: process.env.ENV_PATH })

module.exports = defineConfig({
e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here
},
baseUrl: `http://${process.env.HOST}:${process.env.PORT}`,
},
env: {
ADMIN_MAIL: process.env.INIT_ADMIN_EMAIL,
ADMIN_PASSWORD: process.env.INIT_ADMIN_PASSWORD,
},
})
Loading

0 comments on commit d5755b2

Please sign in to comment.