tli 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/assets/strings/google_info.txt +71 -0
- data/assets/strings/help.txt +43 -0
- data/bin/tli +5 -0
- data/db/migrate/01_create_translation.rb +15 -0
- data/lib/application.rb +4 -0
- data/lib/config.rb +8 -4
- data/lib/tli.rb +8 -1
- data/lib/translation.rb +2 -2
- data/lib/translators/google_translator.rb +1 -3
- metadata +4 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4ba58153af09978a74910a37485285145b92cff1
|
|
4
|
+
data.tar.gz: 9c68ca7f07906ce941e2e2950d39b55b216c7a95
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 052172db82136f3d835bda0443385d0b4897f1b9808077a7bce679a9f156e8af674e29ec81198248c231e42eab165705cb07c4dfc57b255c391eb728d0d90a46
|
|
7
|
+
data.tar.gz: 6c736ecc65a848d774c229f72b439c006968aad093aeb95c2213f379ecb2962d80836bbea5505ca63a985a402bb62fe818ba233421d17f03cad3db87d8e2e9cc
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
Google Translate
|
|
2
|
+
|
|
3
|
+
Google Translate is a multilingual service provided by Google Inc. to
|
|
4
|
+
translate written text from one language into another. It over 60
|
|
5
|
+
languages. Google Translate also provides Text To Speech for your
|
|
6
|
+
translations.
|
|
7
|
+
|
|
8
|
+
Supported languages:
|
|
9
|
+
====================
|
|
10
|
+
|
|
11
|
+
Code Language
|
|
12
|
+
---- ------
|
|
13
|
+
af Afrikaans
|
|
14
|
+
sq Albanian
|
|
15
|
+
ar Arabic
|
|
16
|
+
hy Armenian
|
|
17
|
+
az Azerbaijani
|
|
18
|
+
eu Basque
|
|
19
|
+
be Belarusian
|
|
20
|
+
bg Bulgarian
|
|
21
|
+
ca Catalan
|
|
22
|
+
zh-CN Chinese, (Simplified)
|
|
23
|
+
zh-TW Chinese, (Traditional)
|
|
24
|
+
hr Croatian
|
|
25
|
+
cs Czech
|
|
26
|
+
da Danish
|
|
27
|
+
nl Dutch
|
|
28
|
+
en English
|
|
29
|
+
et Estonian
|
|
30
|
+
tl Filipino
|
|
31
|
+
fi Finnish
|
|
32
|
+
fr French
|
|
33
|
+
gl Galician
|
|
34
|
+
ka Georgian
|
|
35
|
+
de German
|
|
36
|
+
el Greek
|
|
37
|
+
ht Haitian, Creole
|
|
38
|
+
iw Hebrew
|
|
39
|
+
hi Hindi
|
|
40
|
+
hu Hungarian
|
|
41
|
+
is Icelandic
|
|
42
|
+
id Indonesian
|
|
43
|
+
ga Irish
|
|
44
|
+
it Italian
|
|
45
|
+
ja Japanese
|
|
46
|
+
ko Korean
|
|
47
|
+
la Latin
|
|
48
|
+
lv Latvian
|
|
49
|
+
lt Lithuanian
|
|
50
|
+
mk Macedonian
|
|
51
|
+
ms Malay
|
|
52
|
+
mt Maltese
|
|
53
|
+
no Norwegian
|
|
54
|
+
fa Persian
|
|
55
|
+
pl Polish
|
|
56
|
+
pt Portuguese
|
|
57
|
+
ro Romanian
|
|
58
|
+
ru Russian
|
|
59
|
+
sr Serbian
|
|
60
|
+
sk Slovak
|
|
61
|
+
sl Slovenian
|
|
62
|
+
es Spanish
|
|
63
|
+
sw Swahili
|
|
64
|
+
sv Swedish
|
|
65
|
+
th Thai
|
|
66
|
+
tr Turkish
|
|
67
|
+
uk Ukrainian
|
|
68
|
+
ur Urdu
|
|
69
|
+
vi Vietnamese
|
|
70
|
+
cy Welsh
|
|
71
|
+
yi Yiddish
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
Usage: tli [options] [text]
|
|
2
|
+
|
|
3
|
+
--version Displays information about the current version.
|
|
4
|
+
|
|
5
|
+
--source Specify the language code of the text to translate, e.g. en, es,
|
|
6
|
+
fr, ja, etc.
|
|
7
|
+
|
|
8
|
+
--target Specify the we want to translate to, e.g. en, es, fr, ja, etc.
|
|
9
|
+
|
|
10
|
+
--service Specify the ID of the service we want to use as a translation
|
|
11
|
+
service, e.g. google, cambridge, etc.
|
|
12
|
+
|
|
13
|
+
--info Get information of a particular translation service, e.g.,
|
|
14
|
+
"--info google"
|
|
15
|
+
|
|
16
|
+
--cache_results Enable caching of translation and pronunciations locally.
|
|
17
|
+
|
|
18
|
+
--play Plays the pronunciation of a text in the target language
|
|
19
|
+
(if the translation service provide pronunciations).
|
|
20
|
+
|
|
21
|
+
--player Specify the program that will be used to play the translation,
|
|
22
|
+
by default `mplayer` is used.
|
|
23
|
+
|
|
24
|
+
--lts List translation services.
|
|
25
|
+
|
|
26
|
+
--help Displays information about the usage of tli (this text).
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
Examples:
|
|
30
|
+
|
|
31
|
+
Translate "song" from English to French
|
|
32
|
+
|
|
33
|
+
$ tli --source en --target fr song
|
|
34
|
+
|
|
35
|
+
Translate and play the pronunciation of "Good bye" from English to Spanish:
|
|
36
|
+
|
|
37
|
+
$ tli --source en --target es --play Good bye
|
|
38
|
+
|
|
39
|
+
Start the interactive version if you want to translate multiple words:
|
|
40
|
+
|
|
41
|
+
$ tli --source en --target es
|
|
42
|
+
>
|
|
43
|
+
|
data/bin/tli
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
+
require 'fileutils'
|
|
3
|
+
require 'active_record'
|
|
4
|
+
require_relative '../lib/application'
|
|
5
|
+
FileUtils.mkdir_p(Application.app_dir + '/db')
|
|
6
|
+
FileUtils.mkdir_p(Application.app_dir + '/pronunciations')
|
|
2
7
|
require_relative '../lib/tli'
|
|
3
8
|
begin
|
|
4
9
|
Tli.new.invoke(ARGV)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
class CreateTranslation < ActiveRecord::Migration
|
|
2
|
+
def change
|
|
3
|
+
create_table :translations do |t|
|
|
4
|
+
t.string :text
|
|
5
|
+
t.string :source
|
|
6
|
+
t.string :target
|
|
7
|
+
t.string :service
|
|
8
|
+
t.string :response
|
|
9
|
+
|
|
10
|
+
t.timestamps null: true
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
add_index :translations, [:text, :source, :target, :service], unique: true
|
|
14
|
+
end
|
|
15
|
+
end
|
data/lib/application.rb
CHANGED
data/lib/config.rb
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
|
+
app_dir = '/tmp/.tli'
|
|
1
2
|
working_directory = File.expand_path(File.dirname(__FILE__))
|
|
2
3
|
CONFIG = {
|
|
3
4
|
env: :production,
|
|
4
5
|
development: {
|
|
5
|
-
app_dir:
|
|
6
|
+
app_dir: app_dir,
|
|
6
7
|
strings_dir: working_directory + '/../assets/strings',
|
|
7
|
-
db_file:
|
|
8
|
+
db_file: app_dir + '/db/translations.db',
|
|
9
|
+
migrate_dir: working_directory + '/../db/migrate',
|
|
8
10
|
cache_results: false,
|
|
9
11
|
player: 'touch'
|
|
10
12
|
},
|
|
11
13
|
test: {
|
|
12
|
-
app_dir:
|
|
14
|
+
app_dir: app_dir,
|
|
13
15
|
strings_dir: working_directory + '/../assets/strings',
|
|
14
|
-
db_file:
|
|
16
|
+
db_file: app_dir + '/db/translations.db',
|
|
17
|
+
migrate_dir: working_directory + '/../db/migrate',
|
|
15
18
|
cache_results: false,
|
|
16
19
|
player: 'touch'
|
|
17
20
|
},
|
|
@@ -19,6 +22,7 @@ CONFIG = {
|
|
|
19
22
|
app_dir: Dir.home + '/.tli',
|
|
20
23
|
strings_dir: working_directory + '/../assets/strings',
|
|
21
24
|
db_file: Dir.home + '/.tli/db/translations.db',
|
|
25
|
+
migrate_dir: working_directory + '/../db/migrate',
|
|
22
26
|
cache_results: true,
|
|
23
27
|
player: 'mplayer'
|
|
24
28
|
}
|
data/lib/tli.rb
CHANGED
|
@@ -24,7 +24,8 @@ class Tli
|
|
|
24
24
|
cache_results: :flag,
|
|
25
25
|
play: :flag,
|
|
26
26
|
help: :flag,
|
|
27
|
-
lts: :flag
|
|
27
|
+
lts: :flag,
|
|
28
|
+
version: :flag
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
SERVICES = {
|
|
@@ -55,6 +56,7 @@ class Tli
|
|
|
55
56
|
|
|
56
57
|
return stdout.puts help if params[:help] == true
|
|
57
58
|
return stdout.puts list_services if params[:lts] == true
|
|
59
|
+
return stdout.puts version if params[:version] == true
|
|
58
60
|
return stdout.puts info(params[:info]) unless params[:info].empty?
|
|
59
61
|
|
|
60
62
|
params[:source] = DEFAULTS[:source] if params[:source].empty?
|
|
@@ -151,6 +153,7 @@ class Tli
|
|
|
151
153
|
end
|
|
152
154
|
|
|
153
155
|
def info(service)
|
|
156
|
+
fail 'Unknown service' unless SERVICES.include?(service)
|
|
154
157
|
SERVICES[service].info
|
|
155
158
|
end
|
|
156
159
|
|
|
@@ -163,4 +166,8 @@ class Tli
|
|
|
163
166
|
end
|
|
164
167
|
list
|
|
165
168
|
end
|
|
169
|
+
|
|
170
|
+
def version
|
|
171
|
+
'tli version 0.0.4'
|
|
172
|
+
end
|
|
166
173
|
end
|
data/lib/translation.rb
CHANGED
|
@@ -2,7 +2,7 @@ require 'active_record'
|
|
|
2
2
|
require_relative 'application'
|
|
3
3
|
ActiveRecord::Base .establish_connection(adapter: 'sqlite3',
|
|
4
4
|
database: Application.db_file)
|
|
5
|
-
|
|
6
|
-
ActiveRecord::Migrator.migrate(
|
|
5
|
+
ActiveRecord::Migration.verbose = false
|
|
6
|
+
ActiveRecord::Migrator.migrate(Application.migrate_dir)
|
|
7
7
|
class Translation < ActiveRecord::Base
|
|
8
8
|
end
|
|
@@ -45,9 +45,7 @@ class GoogleTranslator < Translator
|
|
|
45
45
|
|
|
46
46
|
if options[:tts]
|
|
47
47
|
audio_file = StringUtil.tts_file_name(text, source, 'google')
|
|
48
|
-
unless File.exist?(audio_file)
|
|
49
|
-
get_pronunciation(text, source, audio_file)
|
|
50
|
-
end
|
|
48
|
+
get_pronunciation(text, source, audio_file) unless File.exist?(audio_file)
|
|
51
49
|
end
|
|
52
50
|
json = JSON.parse(get_data(text, source, target, options))
|
|
53
51
|
extract_translation(json)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: tli
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Rafael Rendón Pablo
|
|
@@ -20,7 +20,10 @@ executables:
|
|
|
20
20
|
extensions: []
|
|
21
21
|
extra_rdoc_files: []
|
|
22
22
|
files:
|
|
23
|
+
- assets/strings/google_info.txt
|
|
24
|
+
- assets/strings/help.txt
|
|
23
25
|
- bin/tli
|
|
26
|
+
- db/migrate/01_create_translation.rb
|
|
24
27
|
- lib/application.rb
|
|
25
28
|
- lib/config.rb
|
|
26
29
|
- lib/dictionaries/dictionary.rb
|