-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into next
- Loading branch information
Showing
24 changed files
with
2,298 additions
and
1,644 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
--- | ||
name: Bug report | ||
about: Create a report to help us improve | ||
title: "[BUG]: " | ||
labels: investigate | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Describe the bug** | ||
A clear and concise description of what the bug is. | ||
|
||
**To Reproduce** | ||
Steps to reproduce the behavior: | ||
1. Go to '...' | ||
2. Click on '....' | ||
3. Scroll down to '....' | ||
4. See error | ||
|
||
**Expected behavior** | ||
A clear and concise description of what you expected to happen. | ||
|
||
**Screenshots** | ||
If applicable, add screenshots to help explain your problem. | ||
|
||
**System (please complete the following information):** | ||
- OS: [e.g. Linux] | ||
- Browser [e.g. firefox, safari, chrome] | ||
- Versions: | ||
- strapi: [e.g. 4.6.0] | ||
- strapi-plugin-translate: [e.g. 1.1.0] | ||
- provider: [e.g. [email protected]] | ||
- Other Strapi plugins: | ||
- [e.g. [email protected]] | ||
|
||
**Plugin config** | ||
Please add your plugin config here, e.g. | ||
```js | ||
module.exports = { | ||
translate: { | ||
enabled: true, | ||
config: { | ||
provider: '[e.g. deepl]', | ||
providerOptions: { }, | ||
translateRelations: true, | ||
}, | ||
}, | ||
} | ||
``` | ||
|
||
**Additional context** | ||
Add any other context about the problem here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
name: Feature request | ||
about: Suggest an idea for this project | ||
title: "[FEATURE]: " | ||
labels: enhancement | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Is your feature request related to a problem? Please describe.** | ||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] | ||
|
||
**Describe the solution you'd like** | ||
A clear and concise description of what you want to happen. | ||
|
||
**Describe alternatives you've considered** | ||
A clear and concise description of any alternative solutions or features you've considered. | ||
|
||
**Additional context** | ||
Add any other context or screenshots about the feature request here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 Feki.de e.V. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# LibreTranslate provider for Strapi Translate Plugin | ||
|
||
Configure the provider through the providerOptions: | ||
|
||
```js | ||
module.exports = { | ||
// ... | ||
translate: { | ||
enabled: true, | ||
config: { | ||
// Choose one of the available providers | ||
provider: 'libretranslate', | ||
// Pass credentials and other options to the provider | ||
providerOptions: { | ||
// your API key - required and wil cause errors if not provided | ||
apiKey: 'key', | ||
// api url - required | ||
apiUrl: 'https://your.libretranslate.instance', | ||
// maximum number of requests per minute - optional, default is `undefined` => no limit | ||
apiMaxRPM: 60, | ||
// maximum number of chars per request - optional, default is `undefined` => no limit | ||
apiMaxChars: 1234, | ||
// maximum number of texts per request | ||
apiMaxTexts: 55, | ||
// manually overwrite the Strapi Locale to LibreTranslate Locale mapping. | ||
// default is the string before the `-` character for every locale | ||
localeMap:{ | ||
'en-US' : 'de', | ||
} | ||
}, | ||
// other options ... | ||
}, | ||
}, | ||
// ... | ||
} | ||
``` | ||
|
||
or use the default environment variables: | ||
|
||
- `LT_API_KEY` - default `undefined` | ||
- `LT_API_URL` - default `undefined` | ||
- `LT_API_MAX_RPM` - default `undefined` | ||
- `LT_API_MAX_CHARS` - default `undefined` | ||
- `LT_API_MAX_TEXTS` - default `undefined` | ||
|
||
Note that environment variables take precedence over values `providerOptions`. To force no limit on requests per second or maximum characters, set them to -1 | ||
|
||
## Limitations: | ||
|
||
- Only the [languages supported by argos](https://github.com/argosopentech/argos-translate#supported-languages), the actual translation library behind LibreTranslate, can be translated. | ||
- LibreTranslate servers can impose additional restrictions, such as limits to request frequency or size. You can configure those via the pluginOptions, by default there are no limitations, because [LibreTranslate has no limitations by default](https://github.com/LibreTranslate/LibreTranslate#arguments) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
'use strict' | ||
|
||
module.exports = ({ plugins = {} }) => { | ||
let mock = { | ||
plugin(name) { | ||
return this.plugins[name] | ||
}, | ||
getRef() { | ||
return this | ||
}, | ||
plugins: { | ||
...plugins, | ||
translate: { | ||
service(name) { | ||
return this.services[name]({ strapi: mock.getRef() }) | ||
}, | ||
controller(name) { | ||
return this.controllers[name]({ strapi: mock.getRef() }) | ||
}, | ||
services: { | ||
chunks: require('strapi-plugin-translate/server/services/chunks'), | ||
format: require('strapi-plugin-translate/server/services/format'), | ||
}, | ||
}, | ||
'content-type-builder': { | ||
service(name) { | ||
return this.services[name] | ||
}, | ||
services: { | ||
components: { | ||
// To make it easier here, the componentInfo is actually already in the correct format | ||
formatComponent(componentInfo) { | ||
return componentInfo | ||
}, | ||
}, | ||
'content-types': { | ||
formatContentType(contentTypeInfo) { | ||
return contentTypeInfo | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
service(uid) { | ||
const [handler, collection] = uid.split('::') | ||
if (handler === 'plugin') { | ||
const [plugin, service] = collection.split('.') | ||
return this.plugins[plugin].services[service]({ strapi: mock.getRef() }) | ||
} | ||
return { | ||
findOne: (id, params) => this.entityService.findOne(uid, id, params), | ||
find: (params) => this.entityService.findMany(uid, params), | ||
create: (params) => this.entityService.create(uid, params), | ||
update: (id, params) => this.entityService.update(uid, id, params), | ||
delete: (id, params) => this.entityService.delete(uid, id, params), | ||
} | ||
}, | ||
log: { | ||
debug: jest.fn(), | ||
info: jest.fn(), | ||
warn: jest.fn(), | ||
error: jest.fn(), | ||
}, | ||
} | ||
|
||
return mock | ||
} |
Oops, something went wrong.