konjac 0.2.8.1 → 0.2.9
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +65 -92
- data/lib/applescripts/konjac_excel_export +120 -0
- data/lib/applescripts/konjac_excel_import +112 -0
- data/lib/konjac/dictionary.rb +8 -1
- data/lib/konjac/installer.rb +11 -5
- data/lib/konjac/office.rb +12 -0
- data/lib/konjac/os.rb +51 -0
- data/lib/konjac/version.rb +1 -1
- data/lib/konjac.rb +1 -0
- data/lib/locales/en.yml +3 -2
- data/lib/locales/ja.yml +3 -2
- metadata +31 -30
- data/lib/bash/install_vim +0 -5
- data/lib/bash/update_vim +0 -3
data/README.rdoc
CHANGED
@@ -7,6 +7,21 @@ Author:: Bryan McKelvey
|
|
7
7
|
Copyright:: (c) 2012 Bryan McKelvey
|
8
8
|
License:: MIT
|
9
9
|
|
10
|
+
== Features
|
11
|
+
|
12
|
+
* <b>Fuzzy matching</b> - Konjac can make suggestions for similar words based on
|
13
|
+
their similarity.
|
14
|
+
* <b>Whitespace handling</b> - It's still pretty lazy but at least functional
|
15
|
+
* <b>One-way translation</b> - For example, you would always convert full-width
|
16
|
+
letters and numbers in Japanese to their half-width counterparts in English.
|
17
|
+
The converse is not necessarily true.
|
18
|
+
* <b>Regular expressions</b> - Stuff like
|
19
|
+
<tt>/(\d+)年(\d+)月(\d+)日/\2\/\3\/\1/</tt> (i.e. <tt>1984年11月23日 # =>
|
20
|
+
11/23/1984</tt>)
|
21
|
+
* <b>Importing/exporting text from/to Office documents</b> - Currently only
|
22
|
+
working on Mac (support for Word planned, but for *nix it's probably too
|
23
|
+
difficult).
|
24
|
+
|
10
25
|
== Installation
|
11
26
|
|
12
27
|
=== Stable
|
@@ -14,7 +29,7 @@ License:: MIT
|
|
14
29
|
With {Ruby}[http://www.ruby-lang.org/en/downloads/] installed, run the
|
15
30
|
following in your terminal:
|
16
31
|
|
17
|
-
|
32
|
+
gem install konjac
|
18
33
|
|
19
34
|
=== Development
|
20
35
|
|
@@ -22,55 +37,65 @@ With Ruby, {Git}[http://help.github.com/set-up-git-redirect] and
|
|
22
37
|
{Bundler}[http://gembundler.com/] installed, navigate in your command line to a
|
23
38
|
directory of your choice, then run:
|
24
39
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
40
|
+
git clone git://github.com/brymck/konjac.git
|
41
|
+
cd konjac
|
42
|
+
bundle update
|
43
|
+
rake install
|
29
44
|
|
30
45
|
== Usage
|
31
46
|
|
32
47
|
Translate all text files in the current directory from Japanese into English:
|
33
48
|
|
34
|
-
|
35
|
-
|
49
|
+
konjac translate *.txt --from japanese --to english
|
50
|
+
konjac translate *.txt -f ja -t en
|
36
51
|
|
37
52
|
Use multiple dictionaries:
|
38
53
|
|
39
|
-
|
40
|
-
|
54
|
+
konjac translate financial_report_en.txt --to japanese --using {finance,fluffery}
|
55
|
+
konjac translate financial_report_en.txt -t ja -u {finance,fluffery}
|
41
56
|
|
42
57
|
Extract text from a .docx? document (creates a plain-text <tt>test.konjac</tt>
|
43
58
|
file from <tt>test.docx</tt>):
|
44
59
|
|
45
|
-
|
46
|
-
|
60
|
+
konjac export test.doc
|
61
|
+
konjac export test.docx
|
47
62
|
|
48
63
|
Extract text from a .docx document and process with a dictionary
|
49
64
|
|
50
|
-
|
51
|
-
|
65
|
+
konjac export test.docx --from japanese --to english --using pre
|
66
|
+
konjac export test.docx -f ja -t en -u pre
|
52
67
|
|
53
68
|
Import tags file back into .docx document (for .doc files, this opens the file
|
54
69
|
in word and imports the changes; for .docx files this outputs a new file named
|
55
70
|
<tt>test_imported.docx</tt>):
|
56
71
|
|
57
|
-
|
58
|
-
|
72
|
+
konjac import test.doc
|
73
|
+
konjac import test.docx
|
59
74
|
|
60
75
|
Add a word to your dictionary:
|
61
76
|
|
62
|
-
|
63
|
-
|
77
|
+
konjac add --original dog --from english --translation 犬 --to japanese
|
78
|
+
konjac add -o dog -f en -r 犬 -t ja
|
64
79
|
|
65
80
|
Translate a word using your dictionary:
|
66
81
|
|
67
|
-
|
68
|
-
|
82
|
+
konjac translate dog --from english --to japanese --word
|
83
|
+
konjac translate dog -f en -t ja -w
|
69
84
|
|
70
85
|
Suggest a word using your dictionary:
|
71
86
|
|
72
|
-
|
73
|
-
|
87
|
+
konjac suggest dog --from english --to japanese
|
88
|
+
konjac suggest dog -f en -t ja
|
89
|
+
|
90
|
+
=== Ruby
|
91
|
+
|
92
|
+
Create a Suggestor object:
|
93
|
+
|
94
|
+
require "konjac"
|
95
|
+
Konjac::Dictionary.add_word :from => :en, :original => "word",
|
96
|
+
:to => :ja, :translation => "言葉"
|
97
|
+
s = Konjac::Suggestor.new(:en, :ja)
|
98
|
+
s.suggest "word" # => [[1.0, "word", "言葉"]]
|
74
99
|
|
75
100
|
== Dictionary Format
|
76
101
|
|
@@ -79,89 +104,37 @@ Store terms in <tt>~/.konjac/dict.yml</tt>.
|
|
79
104
|
<em>Simple (two-way equivalent terms)</em> - English "I" is equivalent to Spanish
|
80
105
|
"yo":
|
81
106
|
|
82
|
-
|
83
|
-
|
84
|
-
|
107
|
+
-
|
108
|
+
en: I
|
109
|
+
es: yo
|
85
110
|
|
86
111
|
<em>Not as simple</em> - Japanese lacks a plural, therefore both "dog" and "dogs"
|
87
112
|
translate as 犬:
|
88
113
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
== Extended Example
|
97
|
-
|
98
|
-
~/.konjac/dict.yml:
|
99
|
-
|
100
|
-
-
|
101
|
-
en: I
|
102
|
-
ja: 僕
|
103
|
-
-
|
104
|
-
en: like
|
105
|
-
ja: 好き
|
106
|
-
-
|
107
|
-
en:
|
108
|
-
en: dog
|
109
|
-
ja: 犬
|
110
|
-
ja:
|
111
|
-
ja: 犬
|
112
|
-
en: dogs?
|
113
|
-
regex: true # i.e. the regular expression /dogs?/
|
114
|
-
- # Periods
|
115
|
-
en:
|
116
|
-
en: ". "
|
117
|
-
ja: 。
|
118
|
-
ja:
|
119
|
-
ja: 。
|
120
|
-
en: !ruby/regexp '/\.(?:\s|$)/'
|
121
|
-
- # Spaces between non-ASCII characters
|
122
|
-
en:
|
123
|
-
en: " "
|
124
|
-
ja: !ruby/regexp /\s{2,}/
|
125
|
-
ja:
|
126
|
-
ja: "\\1\\2"
|
127
|
-
en: !ruby/regexp /([^\w])\s([^\w])/
|
128
|
-
- # Delete extraneous spaces
|
129
|
-
en:
|
130
|
-
en: ""
|
131
|
-
ja: !ruby/regexp /\s(?=[.,:]|$)/
|
132
|
-
|
133
|
-
~/.konjac/test_en.txt:
|
134
|
-
|
135
|
-
I like dogs.
|
136
|
-
|
137
|
-
Run
|
138
|
-
|
139
|
-
konjac translate ~/.konjac/test_en.txt --to japanese
|
140
|
-
|
141
|
-
~/.konjac/test_ja.txt (result):
|
142
|
-
|
143
|
-
僕好き犬。
|
144
|
-
|
145
|
-
Now, obviously that does require some fiddling to make it more grammatical, but
|
146
|
-
it's a start (=> <tt>僕は犬が好きだ。</tt>)
|
114
|
+
-
|
115
|
+
en: dog
|
116
|
+
ja:
|
117
|
+
ja: 犬
|
118
|
+
en: dogs?
|
119
|
+
regex: true # i.e. the regular expression /dogs?/
|
147
120
|
|
148
121
|
== Documentation
|
149
122
|
|
150
123
|
Should be simple enough to generate yourself:
|
151
124
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
125
|
+
rm -rf konjac
|
126
|
+
git clone git://github.com/brymck/konjac
|
127
|
+
cd konjac
|
128
|
+
bundle update
|
129
|
+
rake rdoc
|
130
|
+
rm -rf !(doc)
|
131
|
+
mv doc/rdoc/* .
|
132
|
+
rm -rf doc
|
160
133
|
|
161
134
|
== Supplementary Stuff
|
162
135
|
|
163
|
-
{Vim
|
164
|
-
{My dictionaries}[https://github.com/brymck/konjac_yml]
|
136
|
+
* {Vim plugin}[https://github.com/brymck/konjac_vim]
|
137
|
+
* {My dictionaries}[https://github.com/brymck/konjac_yml]
|
165
138
|
|
166
139
|
== Name
|
167
140
|
|
@@ -0,0 +1,120 @@
|
|
1
|
+
#!/usr/bin/osascript
|
2
|
+
-- round up ASCII characters used for formatting in Word
|
3
|
+
global bell
|
4
|
+
global line_feed
|
5
|
+
global form_feed
|
6
|
+
global carriage_return
|
7
|
+
global format_chars
|
8
|
+
|
9
|
+
-- strip line breaks and formatting characters
|
10
|
+
to strip_line_breaks(this_line)
|
11
|
+
try
|
12
|
+
-- remove last character until no it's no longer an excluded character
|
13
|
+
repeat while last character of this_line is in format_chars
|
14
|
+
set this_line to characters 1 thru -2 of this_line as string
|
15
|
+
end repeat
|
16
|
+
return this_line as text
|
17
|
+
on error
|
18
|
+
return ""
|
19
|
+
end try
|
20
|
+
end strip_line_breaks
|
21
|
+
|
22
|
+
to get_posix_path(mac_path)
|
23
|
+
set result to POSIX path of mac_path
|
24
|
+
end get_posix_path
|
25
|
+
|
26
|
+
to extract(filename)
|
27
|
+
tell application "Microsoft Excel"
|
28
|
+
activate
|
29
|
+
open filename
|
30
|
+
set active_workbook to active workbook
|
31
|
+
set ignored_content to {missing value, "", line_feed}
|
32
|
+
|
33
|
+
-- set tags path to full path to active workbook with a .tags extension
|
34
|
+
set workbook_path to full name of active_workbook
|
35
|
+
set tags_path to workbook_path & ".diff"
|
36
|
+
|
37
|
+
-- delete tags file if it already exists
|
38
|
+
tell application "Finder"
|
39
|
+
if exists file tags_path then
|
40
|
+
delete file tags_path
|
41
|
+
end if
|
42
|
+
end tell
|
43
|
+
|
44
|
+
-- open tags file for writing
|
45
|
+
set tags_file to open for access file tags_path with write permission
|
46
|
+
set eof of tags_file to 0
|
47
|
+
|
48
|
+
write ("--- " & my get_posix_path(workbook_path)) to tags_file
|
49
|
+
write line_feed to tags_file
|
50
|
+
write ("+++ " & my get_posix_path(workbook_path)) to tags_file
|
51
|
+
write line_feed to tags_file
|
52
|
+
|
53
|
+
-- iterate through sheets
|
54
|
+
set sheet_index to 1
|
55
|
+
set sheet_count to count of sheets in active_workbook
|
56
|
+
|
57
|
+
repeat while sheet_index is less than or equal to sheet_count
|
58
|
+
set current_range to used range of sheet sheet_index in active_workbook
|
59
|
+
|
60
|
+
-- iterate through rows
|
61
|
+
set row_index to 1
|
62
|
+
set row_count to count of rows of current_range
|
63
|
+
set column_count to count of columns of current_range
|
64
|
+
|
65
|
+
repeat while row_index is less than or equal to row_count
|
66
|
+
-- iterate through columns
|
67
|
+
set column_index to 1
|
68
|
+
|
69
|
+
repeat while column_index is less than or equal to column_count
|
70
|
+
-- get text content if it's available
|
71
|
+
set text_content to my strip_line_breaks(formula of cell column_index of row row_index of current_range) as string
|
72
|
+
|
73
|
+
-- replace "soft returns" (vertical tabs) with real returns
|
74
|
+
set old_delimiters to AppleScript's text item delimiters
|
75
|
+
set AppleScript's text item delimiters to carriage_return
|
76
|
+
set split_content to every text item of text_content
|
77
|
+
set AppleScript's text item delimiters to old_delimiters
|
78
|
+
|
79
|
+
if text_content is not in ignored_content then
|
80
|
+
write ("@@ " & sheet_index & ":" & row_index & "," & column_index & " @@") to tags_file
|
81
|
+
write line_feed to tags_file
|
82
|
+
repeat with text_line in split_content
|
83
|
+
write ("-" & text_line) to tags_file as «class utf8»
|
84
|
+
write line_feed to tags_file
|
85
|
+
end repeat
|
86
|
+
repeat with text_line in split_content
|
87
|
+
write ("+" & text_line) to tags_file as «class utf8»
|
88
|
+
write line_feed to tags_file
|
89
|
+
end repeat
|
90
|
+
end if
|
91
|
+
|
92
|
+
set column_index to (column_index + 1)
|
93
|
+
end repeat
|
94
|
+
|
95
|
+
set row_index to (row_index + 1)
|
96
|
+
end repeat
|
97
|
+
|
98
|
+
-- increment sheet index
|
99
|
+
set sheet_index to (sheet_index + 1)
|
100
|
+
end repeat
|
101
|
+
|
102
|
+
-- close everything
|
103
|
+
close access tags_file
|
104
|
+
end tell
|
105
|
+
end extract
|
106
|
+
|
107
|
+
-- initialize global variables, just formatting characters here
|
108
|
+
to init_globals()
|
109
|
+
set bell to ASCII character 7
|
110
|
+
set line_feed to ASCII character 10
|
111
|
+
set form_feed to ASCII character 12
|
112
|
+
set carriage_return to ASCII character 13
|
113
|
+
set format_chars to {bell, line_feed, form_feed, carriage_return}
|
114
|
+
end init_globals
|
115
|
+
|
116
|
+
-- main()
|
117
|
+
on run argv
|
118
|
+
init_globals()
|
119
|
+
extract(item 1 of argv)
|
120
|
+
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
#!/usr/bin/osascript
|
2
|
+
global numbers_as_text
|
3
|
+
global line_feed
|
4
|
+
global vertical_tab
|
5
|
+
global carriage_return
|
6
|
+
|
7
|
+
-- parses the headers/separators inside the tags file
|
8
|
+
to parse_header(header, begin)
|
9
|
+
set at_offset to begin
|
10
|
+
|
11
|
+
repeat while character at_offset of header is in my numbers_as_text
|
12
|
+
set at_offset to (at_offset + 1)
|
13
|
+
end repeat
|
14
|
+
|
15
|
+
return at_offset
|
16
|
+
end parse_header
|
17
|
+
|
18
|
+
to get_posix_path(mac_path)
|
19
|
+
set result to POSIX path of mac_path
|
20
|
+
end get_posix_path
|
21
|
+
|
22
|
+
to import(filename)
|
23
|
+
tell application "Microsoft Excel"
|
24
|
+
activate
|
25
|
+
open filename
|
26
|
+
set active_workbook to active workbook
|
27
|
+
set ignored_content to {missing value, "", line_feed}
|
28
|
+
|
29
|
+
-- set tags path to full path to active workbook with a .tags extension
|
30
|
+
set workbook_path to full name of active_workbook
|
31
|
+
set tags_path to workbook_path & ".diff"
|
32
|
+
|
33
|
+
-- read in tags
|
34
|
+
set tags_file to open for access file tags_path
|
35
|
+
set tags to (read tags_file for (get eof tags_file) ¬
|
36
|
+
as «class utf8» using delimiter line_feed)
|
37
|
+
set tag_index to 0
|
38
|
+
set tag_length to length of tags
|
39
|
+
close access tags_file
|
40
|
+
|
41
|
+
set text_content to ""
|
42
|
+
|
43
|
+
-- iterate through sheets
|
44
|
+
set sheet_index to 0
|
45
|
+
set prev_sheet_index to 0
|
46
|
+
set row_index to 0
|
47
|
+
set prev_row_index to 0
|
48
|
+
set column_index to 0
|
49
|
+
set prev_column_index to 0
|
50
|
+
set is_new_tag to false
|
51
|
+
|
52
|
+
repeat with current_line in tags
|
53
|
+
if current_line starts with "@@ " then
|
54
|
+
set colon_offset to my parse_header(current_line, 4)
|
55
|
+
set sheet_index to text 4 thru (colon_offset - 1) ¬
|
56
|
+
of current_line as number
|
57
|
+
set comma_offset to my parse_header(current_line, colon_offset + 1)
|
58
|
+
set row_index to text (colon_offset + 1) thru (comma_offset - 1) ¬
|
59
|
+
of current_line as number
|
60
|
+
set space_offset to my parse_header(current_line, comma_offset + 1)
|
61
|
+
set column_index to text (comma_offset + 1) thru (space_offset - 1) ¬
|
62
|
+
of current_line as number
|
63
|
+
set is_new_tag to true
|
64
|
+
else if current_line starts with "+" then
|
65
|
+
if sheet_index is not 0 then
|
66
|
+
set prev_sheet_index to sheet_index
|
67
|
+
set prev_row_index to row_index
|
68
|
+
set prev_column_index to column_index
|
69
|
+
|
70
|
+
-- handle blank lines with soft returns
|
71
|
+
if length of current_line is less than 2
|
72
|
+
set this_content to ""
|
73
|
+
else
|
74
|
+
set this_content to text 2 thru (length of current_line) ¬
|
75
|
+
of current_line
|
76
|
+
end if
|
77
|
+
|
78
|
+
-- add to text content, joining with a soft return for multiple lines
|
79
|
+
if text_content is "" then
|
80
|
+
set text_content to this_content
|
81
|
+
else
|
82
|
+
set text_content to (text_content & carriage_return & this_content)
|
83
|
+
end if
|
84
|
+
set is_new_tag to false
|
85
|
+
end if
|
86
|
+
end if
|
87
|
+
|
88
|
+
-- increment tag index
|
89
|
+
set tag_index to tag_index + 1
|
90
|
+
|
91
|
+
-- write if we've moved to a new tag or reached the end of the file
|
92
|
+
if text_content is not "" and (tag_index is tag_length or is_new_tag)
|
93
|
+
set formula of cell prev_column_index of row prev_row_index of used range of sheet prev_sheet_index of active_workbook to text_content
|
94
|
+
set text_content to ""
|
95
|
+
end if
|
96
|
+
end repeat
|
97
|
+
end tell
|
98
|
+
end import
|
99
|
+
|
100
|
+
-- initialize global variables
|
101
|
+
to init_globals()
|
102
|
+
set numbers_as_text to {"1", "2", "3", "4", "5", "6", "7", "8", "9", "0"}
|
103
|
+
set line_feed to ASCII character 10
|
104
|
+
set vertical_tab to ASCII character 11
|
105
|
+
set carriage_return to ASCII character 13
|
106
|
+
end init_globals
|
107
|
+
|
108
|
+
-- main()
|
109
|
+
on run argv
|
110
|
+
init_globals()
|
111
|
+
import(item 1 of argv)
|
112
|
+
end run
|
data/lib/konjac/dictionary.rb
CHANGED
@@ -226,7 +226,7 @@ module Konjac
|
|
226
226
|
# Saves a marshalled Dictionary
|
227
227
|
def save_serialized(from_lang, to_lang, dictionaries, pairs) # :doc:
|
228
228
|
file_name = File.expand_path("~/.konjac/marshal/%s_%s_%s" %
|
229
|
-
[from_lang, to_lang, dictionaries.join("_")])
|
229
|
+
[from_lang, to_lang, [dictionaries || :dict].join("_")])
|
230
230
|
|
231
231
|
# Create directory structure if necessary
|
232
232
|
unless File.exists?(file_name)
|
@@ -252,6 +252,13 @@ module Konjac
|
|
252
252
|
|
253
253
|
# Finds dictionaries based on the supplied Array
|
254
254
|
def find_dictionaries(files) # :doc:
|
255
|
+
# Set defaults and format as array
|
256
|
+
if files.nil?
|
257
|
+
files = [:dict]
|
258
|
+
else
|
259
|
+
files = [files] unless files.is_a?(Array)
|
260
|
+
end
|
261
|
+
|
255
262
|
paths = []
|
256
263
|
files.each do |file|
|
257
264
|
file = file.to_s
|
data/lib/konjac/installer.rb
CHANGED
@@ -32,10 +32,13 @@ module Konjac
|
|
32
32
|
def install_vim
|
33
33
|
return update_vim if has_pathogen? && vim_installed?
|
34
34
|
|
35
|
-
|
35
|
+
puts I18n.t(:installing, :scope => :scripts) % I18n.t(:vim_script, :scope => :scripts)
|
36
36
|
if has_pathogen?
|
37
|
-
|
38
|
-
|
37
|
+
Dir.chdir(vim_home) do
|
38
|
+
system "git submodule add #{VIM_GIT} bundle/konjac_vim"
|
39
|
+
system "git submodule init"
|
40
|
+
system "git submodule update"
|
41
|
+
end
|
39
42
|
else
|
40
43
|
dir = Dir.mktmpdir
|
41
44
|
begin
|
@@ -43,7 +46,7 @@ module Konjac
|
|
43
46
|
FileUtils.remove_entry_secure dir
|
44
47
|
end
|
45
48
|
end
|
46
|
-
puts I18n.t(:done, :scope => :scripts)
|
49
|
+
puts I18n.t(:done, :scope => :scripts).capitalize
|
47
50
|
end
|
48
51
|
|
49
52
|
# Install the supplementary {dictionaries}[https://github.com/brymck/konjac_yml]
|
@@ -66,7 +69,10 @@ module Konjac
|
|
66
69
|
# Update the supplementary {Vim plugin}[https://github.com/brymck/konjac_vim]
|
67
70
|
def update_vim
|
68
71
|
if has_pathogen? && vim_installed?
|
69
|
-
|
72
|
+
puts I18n.t(:updating, :scope => :scripts) % I18n.t(:vim_script, :scope => :scripts)
|
73
|
+
Dir.chdir(File.join(vim_home, "bundle", "konjac_vim")) do
|
74
|
+
system "git pull origin master"
|
75
|
+
end
|
70
76
|
system File.join(File.dirname(__FILE__), "..", "bash", "update_vim")
|
71
77
|
puts I18n.t(:done, :scope => :scripts)
|
72
78
|
else
|
data/lib/konjac/office.rb
CHANGED
@@ -10,9 +10,14 @@ module Konjac
|
|
10
10
|
sub_files.each do |sub_file|
|
11
11
|
case File.extname(sub_file)
|
12
12
|
when ".doc"
|
13
|
+
return if OS.not_a_mac
|
13
14
|
system File.join(File.dirname(__FILE__), "..", "applescripts", "konjac_word_import"), sub_file
|
14
15
|
when ".ppt"
|
16
|
+
return if OS.not_a_mac
|
15
17
|
system File.join(File.dirname(__FILE__), "..", "applescripts", "konjac_powerpoint_import"), sub_file
|
18
|
+
when ".xls"
|
19
|
+
return if OS.not_a_mac
|
20
|
+
system File.join(File.dirname(__FILE__), "..", "applescripts", "konjac_excel_import"), sub_file
|
16
21
|
when ".docx"
|
17
22
|
# Build the list of paths we need to work with
|
18
23
|
dirname = File.dirname(sub_file)
|
@@ -73,13 +78,20 @@ module Konjac
|
|
73
78
|
sub_files.each do |sub_file|
|
74
79
|
case File.extname(sub_file)
|
75
80
|
when ".doc"
|
81
|
+
return if OS.not_a_mac
|
76
82
|
break unless Utils.user_allows_overwrite?(sub_file + ".diff")
|
77
83
|
|
78
84
|
system File.join(File.dirname(__FILE__), "..", "applescripts", "konjac_word_export"), sub_file
|
79
85
|
when ".ppt"
|
86
|
+
return if OS.not_a_mac
|
80
87
|
break unless Utils.user_allows_overwrite?(sub_file + ".diff")
|
81
88
|
|
82
89
|
system File.join(File.dirname(__FILE__), "..", "applescripts", "konjac_powerpoint_export"), sub_file
|
90
|
+
when ".xls"
|
91
|
+
return if OS.not_a_mac
|
92
|
+
break unless Utils.user_allows_overwrite?(sub_file + ".diff")
|
93
|
+
|
94
|
+
system File.join(File.dirname(__FILE__), "..", "applescripts", "konjac_excel_export"), sub_file
|
83
95
|
when ".docx"
|
84
96
|
# Build a list of all the paths we're working with
|
85
97
|
dirname = File.dirname(sub_file)
|
data/lib/konjac/os.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
module Konjac
|
2
|
+
# A module for determining what OS we're using
|
3
|
+
module OS
|
4
|
+
class << self
|
5
|
+
# Override string output
|
6
|
+
def to_s
|
7
|
+
RbConfig::CONFIG["host_os"]
|
8
|
+
end
|
9
|
+
|
10
|
+
# OS is a version of Mac
|
11
|
+
def mac?
|
12
|
+
@mac ||= is? /mac|darwin/
|
13
|
+
end
|
14
|
+
|
15
|
+
# OS is a version of Linux
|
16
|
+
def linux?
|
17
|
+
@linux ||= is? /linux|cygwin/
|
18
|
+
end
|
19
|
+
|
20
|
+
# OS is a version of Windows
|
21
|
+
def windows?
|
22
|
+
@windows ||= is? /mswin|^win|mingw/
|
23
|
+
end
|
24
|
+
|
25
|
+
# OS is POSIX (well, actually, this makes the somewhat bad assumption
|
26
|
+
# that non-Windows OSes are POSIX)
|
27
|
+
def posix?
|
28
|
+
!windows?
|
29
|
+
end
|
30
|
+
|
31
|
+
# Throws a message if the computer is using a command restricted to Macs
|
32
|
+
def not_a_mac
|
33
|
+
if mac?
|
34
|
+
return false
|
35
|
+
else
|
36
|
+
puts I18n.t(:mac_only)
|
37
|
+
return true
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
# Test whether the +host_os+ configuration parameter matches a specified
|
45
|
+
# regular expression
|
46
|
+
def is?(match)
|
47
|
+
match === RbConfig::CONFIG["host_os"]
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/lib/konjac/version.rb
CHANGED
data/lib/konjac.rb
CHANGED
@@ -18,6 +18,7 @@ module Konjac
|
|
18
18
|
autoload :Installer, "konjac/installer"
|
19
19
|
autoload :Language, "konjac/language"
|
20
20
|
autoload :Office, "konjac/office"
|
21
|
+
autoload :OS, "konjac/os"
|
21
22
|
autoload :Suggestor, "konjac/suggestor"
|
22
23
|
autoload :Tag, "konjac/tag"
|
23
24
|
autoload :TagManager, "konjac/tag_manager"
|
data/lib/locales/en.yml
CHANGED
@@ -3,6 +3,7 @@ en:
|
|
3
3
|
command_not_found: "Command not found: %s"
|
4
4
|
filenames_arg: <filenames>+
|
5
5
|
filenames_or_word_arg: <filenames>+ OR <text>
|
6
|
+
mac_only: This command is currently Mac-only
|
6
7
|
me: Bryan McKelvey
|
7
8
|
no_match: "No files matching \"%s\" found!"
|
8
9
|
options: options
|
@@ -39,8 +40,8 @@ en:
|
|
39
40
|
done: "done!"
|
40
41
|
subcommands:
|
41
42
|
add: Add a definition to translation memory
|
42
|
-
export: Export text tags from
|
43
|
-
import: Import text tags into
|
43
|
+
export: Export text tags from an MS Office document
|
44
|
+
import: Import text tags into an MS Office document
|
44
45
|
install: Install supplementary scripts
|
45
46
|
language: Sets the default language
|
46
47
|
list: List available dictionaries
|
data/lib/locales/ja.yml
CHANGED
@@ -3,6 +3,7 @@ ja:
|
|
3
3
|
command_not_found: "コマンドは見つかりません:%s"
|
4
4
|
filenames_arg: <ファイル名>+
|
5
5
|
filenames_or_word_arg: <ファイル名>+ または <テキスト>
|
6
|
+
mac_only: このコマンドは現在、Macのみです。
|
6
7
|
me: ブライアン・マッケルビー
|
7
8
|
no_match: "「%s」をマッチするファイルは存在しません。"
|
8
9
|
options: オプション
|
@@ -39,8 +40,8 @@ ja:
|
|
39
40
|
done: "終了!"
|
40
41
|
subcommands:
|
41
42
|
add: 翻訳メモリに定義を追加する
|
42
|
-
export:
|
43
|
-
import:
|
43
|
+
export: MSオフィス・ドキュメントからタグを抽出する
|
44
|
+
import: MSオフィス・ドキュメントにタグをインポートする
|
44
45
|
install: スクリプトなどをインストールする
|
45
46
|
language: 言語を設定する
|
46
47
|
list: 使用できる辞書を表示する
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: konjac
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-01-
|
12
|
+
date: 2012-01-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: amatch
|
16
|
-
requirement: &
|
16
|
+
requirement: &70173664402640 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70173664402640
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: git
|
27
|
-
requirement: &
|
27
|
+
requirement: &70173664402040 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70173664402040
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: highline
|
38
|
-
requirement: &
|
38
|
+
requirement: &70173664401360 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70173664401360
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: i18n
|
49
|
-
requirement: &
|
49
|
+
requirement: &70173664400940 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70173664400940
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: nokogiri
|
60
|
-
requirement: &
|
60
|
+
requirement: &70173664400520 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70173664400520
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: sdoc
|
71
|
-
requirement: &
|
71
|
+
requirement: &70173664399920 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70173664399920
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: term-ansicolor
|
82
|
-
requirement: &
|
82
|
+
requirement: &70173664421020 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :runtime
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70173664421020
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: trollop
|
93
|
-
requirement: &
|
93
|
+
requirement: &70173664420400 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: '0'
|
99
99
|
type: :runtime
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *70173664420400
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: autotest
|
104
|
-
requirement: &
|
104
|
+
requirement: &70173664419720 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ! '>='
|
@@ -109,10 +109,10 @@ dependencies:
|
|
109
109
|
version: '0'
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *70173664419720
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: autotest-fsevent
|
115
|
-
requirement: &
|
115
|
+
requirement: &70173664419300 !ruby/object:Gem::Requirement
|
116
116
|
none: false
|
117
117
|
requirements:
|
118
118
|
- - ! '>='
|
@@ -120,10 +120,10 @@ dependencies:
|
|
120
120
|
version: '0'
|
121
121
|
type: :development
|
122
122
|
prerelease: false
|
123
|
-
version_requirements: *
|
123
|
+
version_requirements: *70173664419300
|
124
124
|
- !ruby/object:Gem::Dependency
|
125
125
|
name: autotest-growl
|
126
|
-
requirement: &
|
126
|
+
requirement: &70173664418880 !ruby/object:Gem::Requirement
|
127
127
|
none: false
|
128
128
|
requirements:
|
129
129
|
- - ! '>='
|
@@ -131,10 +131,10 @@ dependencies:
|
|
131
131
|
version: '0'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
|
-
version_requirements: *
|
134
|
+
version_requirements: *70173664418880
|
135
135
|
- !ruby/object:Gem::Dependency
|
136
136
|
name: bundler
|
137
|
-
requirement: &
|
137
|
+
requirement: &70173664418440 !ruby/object:Gem::Requirement
|
138
138
|
none: false
|
139
139
|
requirements:
|
140
140
|
- - ! '>='
|
@@ -142,10 +142,10 @@ dependencies:
|
|
142
142
|
version: '0'
|
143
143
|
type: :development
|
144
144
|
prerelease: false
|
145
|
-
version_requirements: *
|
145
|
+
version_requirements: *70173664418440
|
146
146
|
- !ruby/object:Gem::Dependency
|
147
147
|
name: rspec
|
148
|
-
requirement: &
|
148
|
+
requirement: &70173664418000 !ruby/object:Gem::Requirement
|
149
149
|
none: false
|
150
150
|
requirements:
|
151
151
|
- - ! '>='
|
@@ -153,7 +153,7 @@ dependencies:
|
|
153
153
|
version: '0'
|
154
154
|
type: :development
|
155
155
|
prerelease: false
|
156
|
-
version_requirements: *
|
156
|
+
version_requirements: *70173664418000
|
157
157
|
description: A Ruby command-line utility for translating files using a YAML wordlist
|
158
158
|
email:
|
159
159
|
- bryan.mckelvey@gmail.com
|
@@ -172,12 +172,12 @@ files:
|
|
172
172
|
- Rakefile
|
173
173
|
- bin/konjac
|
174
174
|
- konjac.gemspec
|
175
|
+
- lib/applescripts/konjac_excel_export
|
176
|
+
- lib/applescripts/konjac_excel_import
|
175
177
|
- lib/applescripts/konjac_powerpoint_export
|
176
178
|
- lib/applescripts/konjac_powerpoint_import
|
177
179
|
- lib/applescripts/konjac_word_export
|
178
180
|
- lib/applescripts/konjac_word_import
|
179
|
-
- lib/bash/install_vim
|
180
|
-
- lib/bash/update_vim
|
181
181
|
- lib/konjac.rb
|
182
182
|
- lib/konjac/cli.rb
|
183
183
|
- lib/konjac/config.rb
|
@@ -186,6 +186,7 @@ files:
|
|
186
186
|
- lib/konjac/installer.rb
|
187
187
|
- lib/konjac/language.rb
|
188
188
|
- lib/konjac/office.rb
|
189
|
+
- lib/konjac/os.rb
|
189
190
|
- lib/konjac/suggestor.rb
|
190
191
|
- lib/konjac/tag.rb
|
191
192
|
- lib/konjac/tag_manager.rb
|
data/lib/bash/install_vim
DELETED
data/lib/bash/update_vim
DELETED