-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d98f215
Showing
23 changed files
with
3,932 additions
and
0 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,13 @@ | ||
# Editor configuration, see http://editorconfig.org | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
indent_style = space | ||
indent_size = 2 | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
max_line_length = off | ||
trim_trailing_whitespace = false |
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,39 @@ | ||
**/*.log | ||
**/.DS_Store | ||
*. | ||
.vscode/settings.json | ||
.history | ||
.yarn | ||
bazel-* | ||
bazel-bin | ||
bazel-out | ||
bazel-qwik | ||
bazel-testlogs | ||
dist | ||
dist-dev | ||
lib | ||
lib-types | ||
etc | ||
external | ||
node_modules | ||
temp | ||
tsc-out | ||
tsdoc-metadata.json | ||
target | ||
output | ||
rollup.config.js | ||
build | ||
.cache | ||
.vscode | ||
.rollup.cache | ||
tsconfig.tsbuildinfo | ||
vite.config.ts | ||
*.spec.tsx | ||
*.spec.ts | ||
.netlify | ||
pnpm-lock.yaml | ||
package-lock.json | ||
yarn.lock | ||
server | ||
src/library/saleor/gql | ||
src/types/sanity |
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,29 @@ | ||
module.exports = { | ||
root: true, | ||
env: { | ||
es2021: true, | ||
node: true, | ||
}, | ||
overrides: [ | ||
{ | ||
files: ['*.{ts,js,mjs,cjs}'], | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:@typescript-eslint/recommended', | ||
'plugin:prettier/recommended', | ||
], | ||
parser: '@typescript-eslint/parser', | ||
parserOptions: { | ||
tsconfigRootDir: __dirname, | ||
project: ['./tsconfig.json'], | ||
}, | ||
plugins: ['@typescript-eslint'], | ||
rules: { | ||
'no-console': 'off', | ||
'@typescript-eslint/no-unused-vars': ['error'], | ||
'@typescript-eslint/consistent-type-imports': 'warn', | ||
'@typescript-eslint/no-explicit-any': 'warn', | ||
}, | ||
}, | ||
], | ||
}; |
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,26 @@ | ||
name: Publish to NPM | ||
on: | ||
release: | ||
types: [created] | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: corepack enable | ||
- name: Setup Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20.x' | ||
registry-url: 'https://registry.npmjs.org' | ||
cache: 'yarn' | ||
- name: Versions | ||
run: yarn -v && node -v && npm -v | ||
- name: Install | ||
run: yarn install | ||
- name: Build | ||
run: yarn build | ||
- name: Publish package to NPM 🚀 | ||
run: npm publish --access public | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
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,23 @@ | ||
name: Commit to main | ||
on: | ||
push: # Trigger the workflow on push events but only for the main branch | ||
branches: | ||
- main | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: corepack enable | ||
- name: Setup Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20.x' | ||
registry-url: 'https://registry.npmjs.org' | ||
cache: 'yarn' | ||
- name: Versions | ||
run: yarn -v && node -v && npm -v | ||
- name: Install | ||
run: yarn install | ||
- name: Build | ||
run: yarn build |
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,26 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? | ||
|
||
.yarn |
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 @@ | ||
nodeLinker: node-modules |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Tegonal | ||
|
||
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,45 @@ | ||
# A translator for qwik-speak language files using the DeepL API (free/pro) | ||
|
||
## Features | ||
|
||
- Translate qwik-speak extracted JSON files using the DeepL API | ||
- Detects source and target languages automatically based on qwikSpeakInline() vite plugin configuration | ||
- Matches the source/target language to the DeepL API language codes as best as possible and tells you if there is no match available | ||
- Preserves dynamic placeholders like `{{name}}` and `{{count}}` withour relying on `preserverFormatting` | ||
- Caches each translated string in a local file to avoid unnecessary API calls | ||
- Backups previous translations before writing the new string set | ||
- Shows differences between the previous and the new string set | ||
- Supports DeepL context by using the content of a text file and all aggregated source language strings | ||
|
||
## Installation | ||
|
||
```bash | ||
npm add -D @tegonal/qwik-speak-deepl | ||
yaml add -D @tegonal/qwik-speak-deepl | ||
``` | ||
|
||
## Usage | ||
|
||
Run the translator with the following command from the root of your qwik project: | ||
|
||
```bash | ||
npx qwik-speak-deepl -a <deeplApiKey> | ||
``` | ||
|
||
## Options | ||
|
||
```bash | ||
Usage: qwik-speak-deepl <command> [options] | ||
|
||
Options: | ||
-a, --apiKey <key> DeepL API key | ||
-c, --contextFile <path> A text file with context for better quality translations (default: | ||
"qwik-speak-deepl.context.txt") | ||
-nc, --noCache Don't use the existing cache (default: false) | ||
-f --formality <level> Formality level to use. Available options are 'less' or 'more' (default: | ||
"less") | ||
-h, --help display help for command | ||
Example call: | ||
$ qwik-speak-deepl --help | ||
``` |
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,62 @@ | ||
{ | ||
"name": "qwik-speak-deepl", | ||
"description": "Qwik Speak Deepl Translator", | ||
"author": "Oliver Studer <[email protected]>", | ||
"license": "MIT", | ||
"version": "0.0.1", | ||
"type": "module", | ||
"main": "./dist/index.js", | ||
"bin": "./dist/bin/qwik-speak-deepl.js", | ||
"engines": { | ||
"node": ">=20.0.0" | ||
}, | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "rollup -c", | ||
"watch": "rollup -c -w", | ||
"up": "yarn upgrade-interactive", | ||
"self-update": "yarn set version latest && yarn", | ||
"lint": "eslint --ext .ts src", | ||
"lint:fix": "eslint --fix --ext .ts src", | ||
"prettier": "prettier --write \"src/**/*.{ts}\"", | ||
"prettier:check": "prettier --check \"src/**/*.{ts}\"", | ||
"cleaner": "git add . && git clean -xdf && yarn" | ||
}, | ||
"keywords": [ | ||
"qwik", | ||
"qwik-speak", | ||
"qwik-speak-deepl", | ||
"deepl", | ||
"translator" | ||
], | ||
"devDependencies": { | ||
"@rollup/plugin-json": "^6.1.0", | ||
"@types/lodash-es": "^4.17.12", | ||
"@types/node": "^20.11.7", | ||
"@types/yargs": "^17.0.32", | ||
"@typescript-eslint/eslint-plugin": "6.19.1", | ||
"@typescript-eslint/parser": "6.19.1", | ||
"commander": "^11.1.0", | ||
"deepl-node": "^1.11.1", | ||
"eslint": "^8.56.0", | ||
"eslint-config-prettier": "^9.1.0", | ||
"eslint-plugin-prettier": "^5.1.3", | ||
"locale-matcher": "^2.0.0", | ||
"lodash-es": "^4.17.21", | ||
"prettier": "^3.2.4", | ||
"rollup": "^4.9.6", | ||
"rollup-plugin-commonjs": "^10.1.0", | ||
"rollup-plugin-node-resolve": "^5.2.0", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"rollup-plugin-typescript2": "^0.36.0", | ||
"ts-command-line-args": "^2.5.1", | ||
"typescript": "^5.3.3" | ||
}, | ||
"prettier": { | ||
"printWidth": 100, | ||
"singleQuote": true, | ||
"bracketSpacing": true, | ||
"jsxBracketSameLine": true | ||
}, | ||
"packageManager": "[email protected]" | ||
} |
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 @@ | ||
import commonjs from 'rollup-plugin-commonjs'; | ||
import resolve from 'rollup-plugin-node-resolve'; | ||
import { terser } from 'rollup-plugin-terser'; | ||
import typescript from 'rollup-plugin-typescript2'; | ||
import json from "@rollup/plugin-json"; | ||
|
||
export default { | ||
input: ['src/bin/qwik-speak-deepl.ts', 'src/index.ts'], | ||
output: { | ||
dir: 'dist', | ||
format: 'es', | ||
}, | ||
plugins: [ | ||
json(), | ||
typescript(), | ||
resolve({preferBuiltins: true}), | ||
commonjs(), | ||
terser(), | ||
], | ||
}; |
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,31 @@ | ||
#!/usr/bin/env node | ||
import { qwikSpeakDeepL } from '../qwik-speak-deepl'; | ||
import { program } from 'commander'; | ||
|
||
program | ||
.requiredOption('-a, --apiKey <key>', 'DeepL API key') | ||
.option( | ||
'-c, --contextFile <path>', | ||
'A text file with context for better quality translations', | ||
'qwik-speak-deepl.context.txt', | ||
) | ||
.option('-nc, --noCache', "Don't use the existing cache", false) | ||
.option( | ||
'-f --formality <level>', | ||
"Formality level to use. Available options are 'less' or 'more'", | ||
'less', | ||
) | ||
.description('An application for translating text using DeepL') | ||
.usage('<command> [options]') | ||
.on('--help', () => { | ||
console.log(''); | ||
console.log('Example call:'); | ||
console.log(' $ qwik-speak-deepl --help'); | ||
}); | ||
|
||
program.parse(process.argv); | ||
|
||
const options = program.opts(); | ||
|
||
export type QwikSpeakDeeplArgs = typeof options; | ||
await qwikSpeakDeepL(options); |
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,2 @@ | ||
export * from './qwik-speak-deepl'; | ||
export { translateJsonRecursively } from './utils/translate-json-recursively'; |
Oops, something went wrong.