Skip to content

Commit

Permalink
New extension: Easydict (raycast#1872)
Browse files Browse the repository at this point in the history
* Squashed 'extensions/easydict/' content from commit a71d29c0

git-subtree-dir: extensions/easydict
git-subtree-split: a71d29c0803bf76cbf4d6adcbe17af6f5360ff02

* Squashed 'extensions/easydict/' changes from a71d29c0..b867d448

b867d448 chore: run npm, run prettier

git-subtree-dir: extensions/easydict
git-subtree-split: b867d4481f71efc88cc75c1a7a4b8dd04916671d

* Squashed 'extensions/easydict/' changes from b867d448..02e8fc31

02e8fc31 chore: run prettier
34572d3d chore: remove react-devtools
8ce4b4ab Merge pull request #3 from tisfeng/dependabot/npm_and_yarn/follow-redirects-1.15.1
938c424a chore(deps): bump follow-redirects from 1.14.7 to 1.15.1
90a410fa Create codeql-analysis.yml
4740e05e Merge pull request #1 from tisfeng/dependabot/npm_and_yarn/minimist-1.2.6
fe292c97 Merge pull request #2 from tisfeng/dependabot/npm_and_yarn/ansi-regex-3.0.1
acd5d0f5 chore(deps): bump ansi-regex from 3.0.0 to 3.0.1
4a052e63 chore(deps): bump minimist from 1.2.5 to 1.2.6
46a5b594 doc: update README

git-subtree-dir: extensions/easydict
git-subtree-split: 02e8fc31b7401f40f50ef92642e4a58b3887fa2c

* Squashed 'extensions/easydict/' changes from 02e8fc31..e85b1f1d

e85b1f1d doc: update README
c800d072 doc: update README

git-subtree-dir: extensions/easydict
git-subtree-split: e85b1f1d34a1e583723d17fed088eb81b56fdef8

* Squashed 'extensions/easydict/' changes from e85b1f1d..b3579838

b3579838 feat: according to the translation language, generate web translate link
7401f698 feat: set maxInputTextLength=2000
94c06d50 fix: incorrect way to save and query clipboard records

git-subtree-dir: extensions/easydict
git-subtree-split: b3579838cc6da59acef85d38c8de40058583e9bd

* style: change Copy action title to Copy Text

* fix: update Youdao and Baidu AppId, App Secret

* style: change copy action title to "Copy Text"

* Update components.tsx

* Updated metadata

* Added missing configurations files

* Renamed files and added more metadata images

* Added missing dep

* fix: resolve eslint errors

* Update CHANGELOG.md

Co-authored-by: Per Nielsen Tikær <per@raycast.com>
  • Loading branch information
tisfeng and pernielsentikaer authored Jun 16, 2022
1 parent 9b1a659 commit ceedc78
Show file tree
Hide file tree
Showing 22 changed files with 5,453 additions and 0 deletions.
15 changes: 15 additions & 0 deletions extensions/easydict/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"root": true,
"env": {
"es2020": true,
"node": true
},
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"extends": [
"eslint:recommended",
"plugin:react-hooks/recommended",
"plugin:@typescript-eslint/recommended",
"prettier"
]
}
71 changes: 71 additions & 0 deletions extensions/easydict/.github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [main]
pull_request:
# The branches below must be a subset of the branches above
branches: [main]
schedule:
- cron: "32 3 * * 0"

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: ["javascript"]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
104 changes: 104 additions & 0 deletions extensions/easydict/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port
4 changes: 4 additions & 0 deletions extensions/easydict/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"printWidth": 120,
"singleQuote": false
}
3 changes: 3 additions & 0 deletions extensions/easydict/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Easydict Changelog

## [Initial Version] - 2022-06-16
21 changes: 21 additions & 0 deletions extensions/easydict/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Tisfeng

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.
99 changes: 99 additions & 0 deletions extensions/easydict/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
## What is Easydict? [【中文简介】](https://github.com/tisfeng/Raycast-Easydict/wiki/Easydict-%E4%B8%AD%E6%96%87%E7%AE%80%E4%BB%8B)

`Easydict` is an easy dictionary, for looking up words or translate text in an easy way. Use it out of the box, automatically recognize the input text language, support 23 translation languages with the help of Youdao, Baidu and Caiyun translation API.

![log](https://cdn.jsdelivr.net/gh/tisfeng/ImageBed@main/uPic/log.png)

## Features

- [x] Out of the box, easy to look up words or translate text.
- [x] Beautiful and practical UI, friendly UI interaction and prompts.
- [x] Automatically recognize the language type of your input text and translate it into the preferred language.
- [x] Provide word rich query information, including basic translation, pronunciation, multiple parts of speech and explanations, forms and tenses, web translations and web phrases.
- [x] Show the types of exams that include the word, such as CET-4 and CET-6, TOEFL, IELTS, etc.
- [x] Support automatic query clipboard text, enabled by default.
- [x] Support to open the [Eudic Application](https://www.eudic.net/v4/en/app/eudic) and quickly look up words, if installed on your Mac.
- [x] Quick search query text online, supports Eudic, Youdao dictionary and Google translation.
- [x] Support Text to Speech(aka TTS).
- [x] Support shortcut `Cmd`+`S` to quickly play the pronunciation of query words.
- [x] Support for displaying multiple translation results, currently supports Youdao, Baidu and Caiyun translation API.
- [x] Support 23 languages.

Next:

- [ ] Support more dictionary API, such as homonyms, synonyms, antonyms, 金山词霸, etc.
- [ ] Support more translation API, such as Apple system translate, Google translate, etc.
- [ ] Optimize the implementation of text to speech, current is simple call say shell command.
- [ ] More features are on the way...

![log-exam-action](https://cdn.jsdelivr.net/gh/tisfeng/ImageBed@main/uPic/log-exam-action.png)

![With](https://cdn.jsdelivr.net/gh/tisfeng/ImageBed@main/uPic/With.png)

![增强](https://cdn.jsdelivr.net/gh/tisfeng/ImageBed@main/uPic/%E5%A2%9E%E5%BC%BA.png)

![你是非常可爱](https://github.com/tisfeng/ImageBed/blob/main/uPic/你是非常可爱.png?raw=true)

## Advanced

Actually, it works well without you having to do any extra work. The next are advanced documents for those who want to use `Easydic` better or understand how the extension works.

![](https://github.com/tisfeng/ImageBed/blob/main/uPic/iShot_2022-06-01_10.57.00.png?raw=true)

### Preferred Languages

The default preferred languages are simplified Chinese and English. You can change them according to your preferences.

Preference language has two main functions:

<details>
<summary> First, it improves the accuracy of automatic recognition of input text language. </summary>
Preference language will be given priority in order during automatic recognition. This is because some words may represent multiple languages at the same time, and the automatic recognition program cannot work as expected. In most cases, the automatic recognition of input text is very useful, except for very few special cases. For example, the English word `heel` will be automatically recognized into Dutch by Youdao translation, and then the translation results are not what we expect. At this time, if your `Easydict` preferred language contains English, it will be recognized into English first and translated correctly.
</details>

<details>
<summary> Second, it is used to confirm your target translation language. </summary>
For example, if you input a sentence arbitrarily, it will be translated into the first preferred language. If the automatically recognized language is the same as your first preferred language, it will be automatically translated into the second preferred language.
</details>

[Youdao translation](https://fanyi.youdao.com/?keyfrom=dict2.top)

![image-20220531223631425](https://cdn.jsdelivr.net/gh/tisfeng/ImageBed@main/uPic/image-20220531223631425.png)

![image-20220531223609010](https://cdn.jsdelivr.net/gh/tisfeng/ImageBed@main/uPic/image-20220531223609010.png)

### Automatic Query Clipboard

<details>
<summary> Automatic query clipboard text, This option is turned on by default. </summary>
In order to better match the automatic clipboard query feature, it is a good idea to set a hotkey for `Easydic`, such as `Shift` + `Cmd ` + `E`, so that after copying the text, you can directly query words through the hotkey, which is very smooth and elegant.
In addition, to avoid frequently querying the same clipboard words, we set a `10 minute` limit, that is, if the latest word on the clipboard is automatically queried only once within 10 minutes, of course, you can manually paste and query at any time.
</details>
### Select Target Translation Language

<details>
<summary> Specify the target translation language. This option is turned off by default. </summary>
By default, the extension will automatically select the preferred languages as the target translation language, but sometimes if you want to manually specify a supported language as the target language, you can turn on the option `Select Target Translation Language` on the preference page, and then you can temporarily select another target language in the action panel.
</details>

### Translation Services

For easy to use, we provide some built-in translation APIs appid and appkey, but these Services have request frequency limits. If many people use them at the same time, it is likely to slow down or even stop. Therefore, for a better use experience, you'd better apply for a dedicated appid and appkey, and then replace the built-in services on the Preferences page.

Don't worry, these translation services have free quotas. Generally speaking, personal use is enough.

Apply Translation Services link:

- [有道翻译](https://ai.youdao.com/price-center.s#servicename=fanyi-text)

- [百度翻译](https://fanyi-api.baidu.com/)

- [彩云小译](https://dashboard.caiyunapp.com/user/sign_in/)

## Thanks

This project is inspired by [raycast-Parrot](https://github.com/Haojen/raycast-Parrot) and based on it. `Easydic` has improved many UI displays, added more practical features, deleted some complex or inappropriate operations, and made a lot of optimization && improvements on the original project.

Finally, all those interested in this project are welcome to contribute to the project, issues and PRs are fine. The project is still in the rapid development stage, any practical suggestions or interesting ideas are OK. There is no guarantee that they will be accepted, but they will be definitely considered.

In addition, if submitting a PR, it is recommended to open a issue to briefly describe the content of the PR, or in [discussions](https://github.com/tisfeng/Raycast-Easydict/discussions) Let's have a brief discussion to avoid conflicts between PR and the features I am currently developing. Thank you.
Binary file added extensions/easydict/assets/eudic-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/easydict/assets/speak.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/easydict/metadata/easydict-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/easydict/metadata/easydict-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/easydict/metadata/easydict.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit ceedc78

Please sign in to comment.