forked from raycast/extensions
-
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.
- chore: proxy - feat: support open in web dicts - fix: from lang - feat: source language select - feat: make config types from a single source of truth (raycast#5) - refactor: extract spellcheck item logic (raycast#6) - chore: styling - docs: add license - docs: update readme - feat: better item selection - chore: refactor - feat: add a few more actions - chore: update lint rules - refactor: use native spellcheck cli (raycast#4) - chore: restructure - fix: svg foreground color - feat: render svg as data url (raycast#3) - docs: layout - chore: clean up - fix: auto clean cache on start up - chore: clean up deps - chore: add esno to the deps - feat: support spelling check - chore: lint - fix: react hooks can not in condition segment (raycast#2) - feat: hide from lang when all are the same - docs: update readme - docs: update - feat: update logo - feat: add option to disable text selection grab - feat: translate back - chore: cleanup - docs: readme - chore: trimming - feat: passive selection grab - feat: make changes - chore: deps and lint - feat: fork from https://github.com/raycast/extensions/tree/main/extensions/google-translate
- Loading branch information
Showing
26 changed files
with
7,894 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,12 @@ | ||
{ | ||
"extends": [ | ||
"plugin:react/recommended", | ||
"plugin:react/jsx-runtime", | ||
"@antfu" | ||
], | ||
"rules": { | ||
"react/jsx-indent": ["error", 2], | ||
"react/jsx-indent-props": ["error", 2], | ||
"react/jsx-max-props-per-line": ["error", { "maximum": 4 }], | ||
} | ||
} |
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,159 @@ | ||
### macOS ### | ||
# General | ||
.DS_Store | ||
.AppleDouble | ||
.LSOverride | ||
|
||
# Icon must end with two \r | ||
Icon | ||
|
||
# Thumbnails | ||
._* | ||
|
||
# Files that might appear in the root of a volume | ||
.DocumentRevisions-V100 | ||
.fseventsd | ||
.Spotlight-V100 | ||
.TemporaryItems | ||
.Trashes | ||
.VolumeIcon.icns | ||
.com.apple.timemachine.donotpresent | ||
|
||
# Directories potentially created on remote AFP share | ||
.AppleDB | ||
.AppleDesktop | ||
Network Trash Folder | ||
Temporary Items | ||
.apdisk | ||
|
||
## Build generated | ||
build/ | ||
DerivedData/ | ||
assets/spellcheck | ||
|
||
### Node ### | ||
# 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/ | ||
|
||
# Build directories | ||
dist/ | ||
|
||
# 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 | ||
.env.json | ||
|
||
# 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 | ||
|
||
# Stores VSCode versions used for testing VSCode extensions | ||
.vscode-test | ||
|
||
## JS Source Maps | ||
*.js.map | ||
|
||
## Extension archives | ||
examples/**/*.zip | ||
extensions/**/*.zip | ||
|
||
# IntelliJ / WebStorm | ||
.idea/ | ||
*.iml | ||
|
||
# Raycast | ||
raycast-env.d.ts |
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 @@ | ||
shamefully-hoist=true |
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 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Anthony Fu <https://github.com/antfu> | ||
Copyright (c) 2023 Slavik Nychkalo <https://github.com/gebeto> | ||
Copyright (c) 2021 Raycast | ||
|
||
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,74 @@ | ||
<br> | ||
<br> | ||
<p align="center"> | ||
<img src="https://github.com/antfu/raycast-multi-translate/blob/main/assets/icon.png?raw=true" width="140" height="140" align="center" /> | ||
</p> | ||
|
||
<h1 align="center">MultiTranslate</sup></h1> | ||
|
||
<p align="center"> | ||
A Raycast extension that translates text to multiple languages at once. | ||
</p> | ||
|
||
<img width="862" src="https://github.com/antfu/raycast-multi-translate/assets/11247099/593bd567-0383-47ad-9a94-b576c2724350"> | ||
|
||
## Motivation | ||
|
||
I speak Chinese, work in English, live in France, and sometimes also consume Japanese content. I do language-switching all the time. For example, I'd like to know what's the meaning of a new English word, find the English translation of a Chinese word, or verify if my French sentence is correct, etc. Most of the time I just need a quick answer, but I found I spend quite a lot of time telling the translator which language **from** and **to**, which should be detected automatically. So instead of setting the language manually every time, let's translate it to all languages we use at once. | ||
|
||
## Features | ||
|
||
|
||
## Installation | ||
|
||
Currently, you need to clone this repo and install it locally in developer mode. | ||
|
||
You will need to have [Node.js](https://nodejs.org) and [pnpm](https://pnpm.io/) installed. | ||
|
||
1. Clone this repo `git clone https://github.com/antfu/raycast-multi-translate` | ||
2. Go to the folder `cd raycast-multi-translate` | ||
3. Install dependencies `pnpm install` | ||
4. Go to Raycast, run `Import Extension` and select the folder | ||
|
||
There is **no plan** to publish to the bloated [raycast/extensions](https://github.com/raycast/extensions) until they make a decentralized publishing system. | ||
|
||
## Features | ||
|
||
### Multiple Translations Targets | ||
|
||
Support translating up to 7 languages at once. Options can be found in the extensions tab of Raycast settings. | ||
|
||
<img width="1112" src="https://github.com/antfu/raycast-multi-translate/assets/11247099/797a83ea-6013-4cef-82fe-dfc5d309aada"> | ||
|
||
### Spellcheck | ||
|
||
When you misspell some words, an additional item will be listed, with diffing support to help you find the correct spelling easier. | ||
|
||
<img width="862" src="https://github.com/antfu/raycast-multi-translate/assets/11247099/ca5ea47a-3d8f-4657-83c1-4955798564fe"> | ||
|
||
### Source Language Detection | ||
|
||
By default we send the text to Google Translate and let it detect the source language automatically. In some cases, it might not be accurate because different works in different languages can spell the same. For example, `ours` in French means `bear`, but in English, it means `belonging to us`. In this case, if you want to translate `ours` in French, you can add `>fr` to the end of the text to force the source language to be French. | ||
|
||
<img width="862" src="https://github.com/antfu/raycast-multi-translate/assets/11247099/5dc72896-f1ce-440c-8337-8fe8350cb59e"> | ||
|
||
## Credits | ||
|
||
Originally forked from https://github.com/raycast/extensions/tree/main/extensions/google-translate, thanks to [@gebeto](https://github.com/gebeto) et al. | ||
|
||
<details> | ||
<summary>Changes from the original extension</summary> | ||
|
||
- Support translating for any language to multiple languages at once | ||
- Removed the representation of flag emojis, as languages are not countries | ||
- Removed the `Translate From` command, and the language selection dropdown, as they are automatized | ||
- Show details view by default | ||
- Cache translation results | ||
- Make "Use current selection" passive and don't interfere the input field | ||
- Added spellcheck functionality | ||
|
||
</details> | ||
|
||
## License | ||
|
||
MIT License |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,28 @@ | ||
import Cocoa | ||
|
||
let spellChecker = NSSpellChecker.shared | ||
spellChecker.automaticallyIdentifiesLanguages = true | ||
|
||
// Debug: `swift ./spellcheck.swift "how are yu?"` | ||
guard CommandLine.argc == 2, let stringToCheck = CommandLine.arguments.last else { | ||
debugPrint("error: \(CommandLine.arguments)") | ||
exit(0) | ||
} | ||
|
||
print(checkSpelling(stringToCheck), terminator: "") | ||
|
||
func checkSpelling(_ text: String) -> String { | ||
var misspellings = spellChecker.check(text, range: NSRange(location: 0, length: text.utf16.count), types: NSTextCheckingResult.CheckingType.spelling.rawValue, options: nil, inSpellDocumentWithTag: 0, orthography: nil, wordCount: nil) | ||
if misspellings.isEmpty { | ||
return text | ||
} | ||
misspellings.reverse() | ||
var correctedText = NSString(string: text) | ||
for misspelling in misspellings { | ||
let guesses = spellChecker.guesses(forWordRange: misspelling.range, in: text, language: spellChecker.language(), inSpellDocumentWithTag: 0) | ||
if let suggest = guesses?.first { | ||
correctedText = NSString(string: correctedText.replacingCharacters(in: misspelling.range, with: suggest)) | ||
} | ||
} | ||
return String(correctedText) | ||
} |
Oops, something went wrong.