Skip to content

Commit 618e02c

Browse files
Translation to solovyina (#22)
* migrate to Solovyina * update: README description with new assets * update: tests for migration to Solovyina * update: minor README changes — upcase lang names * add: Learning mode video to README
1 parent 8efad1d commit 618e02c

14 files changed

+92
-114
lines changed

README.md

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
<a src="https://www.npmjs.com/package/alfred-translayta"><img src="https://img.shields.io/npm/v/alfred-translayta?color=yellow" /></a>
44

55

6-
> **Translate** with Google Translate in Alfred (*en-ru* / *ru-en*). **Save** to favorites. Finally, **learn** the words.
6+
> **Translate** with Google Translate in Alfred (*en-uk* / *uk-en*). **Save** to favorites. Finally, **learn** the words.
77
88
![](screenshots/dir.jpg)
99

10-
Alfred Translayta is an Alfred workflow, which lets you easily translate en-ru, ru-en pairs, add words to favorites and have convenient way to review and memorize them later.
10+
Alfred Translayta is an Alfred workflow, which lets you easily translate 🇬🇧 to 🇺🇦, 🇺🇦 to 🇬🇧 pairs, add words to favorites and have convenient way to review and memorize them later.
1111

1212
## Features
1313
### Translation
@@ -23,7 +23,7 @@ Alfred Translayta is an Alfred workflow, which lets you easily translate en-ru,
2323
* Auto save favorites to a file on disk
2424

2525
## Prerequisites
26-
You need [Node.js 12+](https://nodejs.org) and Alfred 3 or 4 with the paid [Powerpack](https://www.alfredapp.com/powerpack/) upgrade.
26+
You need [Node.js 14+](https://nodejs.org) and Alfred 3 or 4 with the paid [Powerpack](https://www.alfredapp.com/powerpack/) upgrade.
2727

2828
## Install
2929
```
@@ -34,7 +34,7 @@ $ npm install --global alfred-translayta
3434

3535
Open Alfred and type `t` **or** press `Cmd+Shift+K` and:
3636
* **to get translation**:
37-
- start typing words or phrases in english or russian
37+
- start typing words or phrases in English or Ukrainian
3838
* **to get previous translation from cache**:
3939
- press `spacebar`
4040
* **access the favorites**:
@@ -52,30 +52,21 @@ Open Alfred and type `t` **or** press `Cmd+Shift+K` and:
5252

5353
## Screenshots
5454

55-
![](screenshots/direction.jpg)
55+
**Auto** detection of **translation direction**
5656

57-
![](screenshots/previous-and-autocorrection.jpg)
57+
![](screenshots/direction.jpg)
5858

59-
![](screenshots/learning-mode.jpg)
59+
**Auto correction** of misspelled words
6060

61-
## How it is different
62-
There are a lot of more popular alfred workflows for translation.
63-
I really like 2 of them:
64-
* [alfred-translate](https://github.com/podgorniy/alfred-translate) — ideological inspiration (`python` + `yandex translate`). The problem for me here is all `yandex` services are restricted in Ukraine. Plus some `python` errors after a few translations while using VPN(maybe this is just a local problem).
65-
* [alfred-polyglot](https://github.com/nikersify/alfred-polyglot) — technical inspiration (`node` + `google translate`). **Alfred-polyglot** is really cool, you can translate to any language or set default translation pair, but the translations are restricted to only 1 option and really often it was not a best fit.
61+
![](screenshots/autocorrection.jpg)
6662

67-
> The best code is no code at all
63+
**Learning Mode**
6864

69-
**Why another solution?** It was an idea to mix both solutions and to get the best features of each: auto lang. detection, multiple options for translation and of course `favorites list`.
65+
https://user-images.githubusercontent.com/6503508/190931908-f900f9da-8299-43e9-bb10-633299b817ed.mov
7066

71-
Moreover, `favorites` was the main feature I needed so bad. There are plenty of difficult words for me, `which I translate over and over and still can't remember their meaning and translation`. Instead, I would really like to have a place for all these words, which I could access even when my laptop is offline. So here it is!
7267

7368
## Testimonials
7469

75-
**Tech**
76-
Inspired by [alfred-translate](https://github.com/podgorniy/alfred-translate) and [alfred-polyglot](https://github.com/nikersify/alfred-polyglot).
77-
Based on [Alfy](https://github.com/sindresorhus/alfy) and [google-translate-api](https://github.com/vitalets/google-translate-api)
78-
7970
**Visual**
8071
All icons are taken from [flaticon.com](https://www.flaticon.com/), so many kudos and thanks to [the authors](/icons/testimonials.md)
8172

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "alfred-translayta",
3-
"version": "1.1.1",
4-
"description": "Alfred workflow, which translates in ru-en/en-ru directions, save words to favorites.",
3+
"version": "2.0.0",
4+
"description": "Alfred workflow, which translates in uk-en/en-uk directions, save words to favorites.",
55
"main": "index.js",
66
"scripts": {
77
"postinstall": "alfy-init",
@@ -19,7 +19,7 @@
1919
"url": "https://twitter.com/dev99problems"
2020
},
2121
"engines": {
22-
"node": ">=12"
22+
"node": ">=14"
2323
},
2424
"keywords": [
2525
"alfred",

screenshots/autocorrection.jpg

99.5 KB
Loading

screenshots/dir.jpg

-105 KB
Loading

screenshots/direction.jpg

-54 KB
Loading

screenshots/learning-mode.jpg

-140 KB
Binary file not shown.

screenshots/learning-mode.mov

1.26 MB
Binary file not shown.
-168 KB
Binary file not shown.

src/__tests__/intl.test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ describe('intl', () => {
88
actionTip: 'to access favorites list enter "."'
99
})
1010

11-
expect(getActionTranslations('addToFavorites', 'ru')).toEqual({
12-
action: '/добавить в избранное',
13-
actionTip: 'получить доступ к списку избранного можно набрав "."'
11+
expect(getActionTranslations('addToFavorites', 'uk')).toEqual({
12+
action: '/додати в обране',
13+
actionTip: 'переглянути обране можна натиснувши "."'
1414
})
1515

1616
expect(getActionTranslations('save', 'en')).toEqual({
1717
action: '/save',
1818
actionTip: 'save updated translation'
1919
})
2020

21-
expect(getActionTranslations('save', 'ru')).toEqual({
22-
action: '/сохранить',
23-
actionTip: 'сохранит обновленный перевод'
21+
expect(getActionTranslations('save', 'uk')).toEqual({
22+
action: '/зберегти',
23+
actionTip: 'зберегти зміни'
2424
})
2525
})
2626
})

src/__tests__/output.test.js

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ describe('output', () => {
3232
describe('pronunciation', () => {
3333
test('adds "pronunciation" next to translation if there is one', () => {
3434
// originalInput = 'indeed'
35-
const translation = 'верно'
35+
const translation = 'вірно'
3636
const pronunciation = 'inˈdēd'
3737
const targetLang = 'en'
3838

@@ -43,14 +43,14 @@ describe('output', () => {
4343
)
4444

4545
expect(mainTranslation).toEqual({
46-
title: 'верно [inˈdēd]',
46+
title: 'вірно [inˈdēd]',
4747
subtitle: 'best fit translation'
4848
})
4949
})
5050

5151
test('returns only translation, if no pronunciation found', () => {
5252
// originalInput = 'indeed'
53-
const translation = 'верно'
53+
const translation = 'вірно'
5454
const pronunciation = undefined
5555
const targetLang = 'en'
5656

@@ -61,18 +61,18 @@ describe('output', () => {
6161
)
6262

6363
expect(mainTranslation).toEqual({
64-
title: 'верно',
64+
title: 'вірно',
6565
subtitle: 'best fit translation'
6666
})
6767
})
6868
})
6969

7070
describe('shows translation and tip in subtitle in "targetLang" and pronunciation in "sourceLang"', () => {
71-
test('for en-ru direction', () => {
71+
test('for en-uk direction', () => {
7272
// originalInput = 'dwell'
73-
const translation = 'жить'
73+
const translation = 'мешкати'
7474
const pronunciation = 'dwell'
75-
const targetLang = 'ru'
75+
const targetLang = 'uk'
7676

7777
const mainTranslation = formatMainTranslation(
7878
translation,
@@ -82,17 +82,17 @@ describe('output', () => {
8282
const hintLang = getStrLanguage(mainTranslation.subtitle)
8383

8484
expect(mainTranslation).toEqual({
85-
title: 'жить [dwell]',
86-
subtitle: 'найболее подходящий перевод'
85+
title: 'мешкати [dwell]',
86+
subtitle: 'накрайщий переклад'
8787
})
8888

89-
expect(hintLang).toBe('ru')
89+
expect(hintLang).toBe('uk')
9090
})
9191

92-
test('for ru-en direction', () => {
93-
// originalInput = 'обитать'
92+
test('for uk-en direction', () => {
93+
// originalInput = 'мешкати'
9494
const translation = 'dwell'
95-
const pronunciation = "obitat'"
95+
const pronunciation = 'meshkaty'
9696
const targetLang = 'en'
9797

9898
const mainTranslation = formatMainTranslation(
@@ -103,7 +103,7 @@ describe('output', () => {
103103
const hintLang = getStrLanguage(mainTranslation.subtitle)
104104

105105
expect(mainTranslation).toEqual({
106-
title: "dwell [obitat']",
106+
title: 'dwell [meshkaty]',
107107
subtitle: 'best fit translation'
108108
})
109109

@@ -116,30 +116,30 @@ describe('output', () => {
116116
test('prepares other translations to alfy-output format of {title: translation}', () => {
117117
const translations = [
118118
'замок',
119-
'дворец',
120-
'ладья',
121-
'твердыня',
122-
'рокировка',
123-
'убежище'
119+
'контейнер',
120+
'сховище',
121+
'палац',
122+
'тура',
123+
'фортеця'
124124
]
125125

126126
const formattedOtherTranslations = formatOtherTranslations(translations)
127127

128128
expect(formattedOtherTranslations).toEqual([
129129
{
130-
title: 'дворец'
130+
title: 'контейнер'
131131
},
132132
{
133-
title: 'ладья'
133+
title: 'сховище'
134134
},
135135
{
136-
title: 'твердыня'
136+
title: 'палац'
137137
},
138138
{
139-
title: 'рокировка'
139+
title: 'тура'
140140
},
141141
{
142-
title: 'убежище'
142+
title: 'фортеця'
143143
}
144144
])
145145
})
@@ -155,14 +155,14 @@ describe('output', () => {
155155
test('prepares auto corrected value to alfy-output format', () => {
156156
// originalInput = 'casle'
157157
const correctedValue = 'castle'
158-
const targetLang = 'ru'
158+
const targetLang = 'uk'
159159

160160
const autoCorrectedItem = formatAutoCorrection(correctedValue, targetLang)
161161
const hintLang = getStrLanguage(autoCorrectedItem.subtitle)
162162

163163
expect(autoCorrectedItem).toEqual({
164164
title: 'castle',
165-
subtitle: 'возможно вы имели ввиду ⤴️',
165+
subtitle: 'можливо, ви мали на увазі ⤴️',
166166
autocomplete: 'castle',
167167
icon: { path: './icons/question.png' }
168168
})
@@ -175,14 +175,14 @@ describe('output', () => {
175175
describe('formatLastSearch', () => {
176176
test('prepares last searched input to alfy-output format', () => {
177177
const lastUserInput = 'dog'
178-
const targetLang = 'ru'
178+
const targetLang = 'uk'
179179

180180
const lastSearchItem = formatLastSearch(lastUserInput, targetLang)
181181
const hintLang = getStrLanguage(lastSearchItem.subtitle)
182182

183183
expect(lastSearchItem).toEqual({
184184
title: 'dog',
185-
subtitle: 'предыдущий запрос',
185+
subtitle: 'попередній запит',
186186
icon: { path: './icons/history.png' }
187187
})
188188

@@ -197,13 +197,13 @@ describe('output', () => {
197197
const translation = 'замок'
198198
const otherTranslations = [
199199
'замок',
200-
'дворец',
201-
'ладья',
202-
'твердыня',
203-
'рокировка',
204-
'убежище'
200+
'контейнер',
201+
'сховище',
202+
'палац',
203+
'тура',
204+
'фортеця'
205205
]
206-
const targetLang = 'ru'
206+
const targetLang = 'uk'
207207

208208
const addToFavsItem = addToFavoritesAction(
209209
userInput,
@@ -219,11 +219,11 @@ describe('output', () => {
219219
console.log('otherTranslationsInArg', otherTranslationsInArg)
220220

221221
expect(addToFavsItem).toEqual({
222-
title: '/добавить в избранное',
223-
subtitle: 'получить доступ к списку избранного можно набрав "."',
222+
title: '/додати в обране',
223+
subtitle: 'переглянути обране можна натиснувши "."',
224224
icon: { path: './icons/bookmark.png' },
225225
arg:
226-
'{"alfredworkflow":{"variables":{"action":"add","word":"castle","translations":"замок, дворец, ладья, твердыня, рокировка, убежище"}}}'
226+
'{"alfredworkflow":{"variables":{"action":"add","word":"castle","translations":"замок, контейнер, сховище, палац, тура, фортеця"}}}'
227227
})
228228

229229
expect(titleLang).toBe(targetLang)

0 commit comments

Comments
 (0)