konjac 0.2.9 → 0.2.9.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/konjac/cli.rb CHANGED
@@ -12,8 +12,8 @@ module Konjac
12
12
 
13
13
  class << self
14
14
  # A list of valid subcommands
15
- SUB_COMMANDS = ["add", "export", "import", "install", "language", "list",
16
- "suggest", "translate", "update", "use"]
15
+ SUB_COMMANDS = ["add", "export", "exportxml", "import", "importxml",
16
+ "install", "language", "list", "suggest", "translate", "update", "use"]
17
17
 
18
18
  # The minimum amount by which to offset subcommands in standard display.
19
19
  # Should be equal to the length of the longest top-level flag (e.g. the
@@ -81,6 +81,19 @@ eos
81
81
  opt :help, I18n.t(:help, :scope => :opts)
82
82
  end
83
83
  Office.export_tags ARGV, opts
84
+ when "exportxml"
85
+ opts = Trollop::options do
86
+ banner sc_banner % I18n.t(:filenames_arg)
87
+ opt :from, I18n.t(:from, :scope => :opts), :type => :string
88
+ opt :to, I18n.t(:to, :scope => :opts), :type => :string
89
+ opt :output, I18n.t(:output, :scope => :opts), :type => :string
90
+ opt :force, I18n.t(:force, :scope => :opts), :default => false,
91
+ :short => :y
92
+ opt :using, I18n.t(:using, :scope => :opts), :type => :string,
93
+ :default => Config.dictionary, :multi => true
94
+ opt :help, I18n.t(:help, :scope => :opts)
95
+ end
96
+ Office.export_xml ARGV, opts
84
97
  when "import"
85
98
  opts = Trollop::options do
86
99
  banner sc_banner % I18n.t(:filenames_arg)
@@ -88,6 +101,13 @@ eos
88
101
  opt :help, I18n.t(:help, :scope => :opts)
89
102
  end
90
103
  Office.import_tags ARGV, opts
104
+ when "importxml"
105
+ opts = Trollop::options do
106
+ banner sc_banner % I18n.t(:filenames_arg)
107
+ opt :output, I18n.t(:output, :scope => :opts), :type => :string
108
+ opt :help, I18n.t(:help, :scope => :opts)
109
+ end
110
+ Office.import_xml ARGV, opts
91
111
  when "install"
92
112
  Trollop::options do
93
113
  banner sc_banner % I18n.t(:script_arg)
@@ -2,7 +2,10 @@
2
2
  module Konjac
3
3
  # A class to help with installing supplementary tools for Konjac
4
4
  module Installer
5
+ # The location of my Konjac Vim plugin repository
5
6
  VIM_GIT = "git://github.com/brymck/konjac_vim.git"
7
+
8
+ # The location fo my Konjac supplementary dictionary repository
6
9
  YML_GIT = "git://github.com/brymck/konjac_yml.git"
7
10
 
8
11
  class << self
data/lib/konjac/office.rb CHANGED
@@ -3,21 +3,34 @@ module Konjac
3
3
  # Office documents
4
4
  module Office
5
5
  class << self
6
- # Imports the text content of a tag file into a Microsoft Office
6
+ # Imports the text content of a tag file into a Microsoft Office document
7
7
  def import_tags(files, opts = {})
8
8
  sub_files = Utils.parse_files(files)
9
9
  return if sub_files.empty?
10
10
  sub_files.each do |sub_file|
11
11
  case File.extname(sub_file)
12
- when ".doc"
12
+ when ".doc", ".docx"
13
13
  return if OS.not_a_mac
14
14
  system File.join(File.dirname(__FILE__), "..", "applescripts", "konjac_word_import"), sub_file
15
- when ".ppt"
15
+ when ".ppt", ".pptx"
16
16
  return if OS.not_a_mac
17
17
  system File.join(File.dirname(__FILE__), "..", "applescripts", "konjac_powerpoint_import"), sub_file
18
- when ".xls"
18
+ when ".xls", ".xlsx"
19
19
  return if OS.not_a_mac
20
20
  system File.join(File.dirname(__FILE__), "..", "applescripts", "konjac_excel_import"), sub_file
21
+ else
22
+ puts I18n.t(:unknown) % sub_file
23
+ end
24
+ end
25
+ end
26
+
27
+ # Imports the text content of a tag file into a Word 2003+, utilizing a
28
+ # cleaned-up version of the document's original XML structure
29
+ def import_xml(files, opts = {})
30
+ sub_files = Utils.parse_files(files)
31
+ return if sub_files.empty?
32
+ sub_files.each do |sub_file|
33
+ case File.extname(sub_file)
21
34
  when ".docx"
22
35
  # Build the list of paths we need to work with
23
36
  dirname = File.dirname(sub_file)
@@ -77,21 +90,47 @@ module Konjac
77
90
  return if sub_files.empty?
78
91
  sub_files.each do |sub_file|
79
92
  case File.extname(sub_file)
80
- when ".doc"
93
+ when ".doc", ".docx"
81
94
  return if OS.not_a_mac
82
95
  break unless Utils.user_allows_overwrite?(sub_file + ".diff")
83
96
 
84
97
  system File.join(File.dirname(__FILE__), "..", "applescripts", "konjac_word_export"), sub_file
85
- when ".ppt"
98
+ when ".ppt", ".pptx"
86
99
  return if OS.not_a_mac
87
100
  break unless Utils.user_allows_overwrite?(sub_file + ".diff")
88
101
 
89
102
  system File.join(File.dirname(__FILE__), "..", "applescripts", "konjac_powerpoint_export"), sub_file
90
- when ".xls"
103
+ when ".xls", ".xlsx"
91
104
  return if OS.not_a_mac
92
105
  break unless Utils.user_allows_overwrite?(sub_file + ".diff")
93
106
 
94
107
  system File.join(File.dirname(__FILE__), "..", "applescripts", "konjac_excel_export"), sub_file
108
+ else
109
+ puts I18n.t(:unknown) % sub_file
110
+ end
111
+ end
112
+ end
113
+
114
+ # Exports the Word document in XML then extracts the tags and condenses
115
+ # like paragraphs
116
+ #
117
+ # I might deprecate this, but it exports XML. It's much faster, but
118
+ # supporting two methods might not be a great idea.
119
+ def export_xml(files, opts = {})
120
+ # Determine whether to attempt translating
121
+ if opts[:from_given] && opts[:to_given]
122
+ from_lang = Language.find(opts[:from])
123
+ to_lang = Language.find(opts[:to])
124
+ unless from_lang.nil? || to_lang.nil?
125
+ Translator.load_dictionary from_lang, to_lang, opts
126
+ attempting_to_translate = true
127
+ end
128
+ end
129
+
130
+ sub_files = Utils.parse_files(files)
131
+ return if sub_files.empty?
132
+ sub_files.each do |sub_file|
133
+ case File.extname(sub_file)
95
134
  when ".docx"
96
135
  # Build a list of all the paths we're working with
97
136
  dirname = File.dirname(sub_file)
@@ -1,4 +1,4 @@
1
1
  module Konjac
2
2
  # The current version number of Konjac
3
- VERSION = "0.2.9"
3
+ VERSION = "0.2.9.1"
4
4
  end
data/lib/locales/en.yml CHANGED
@@ -41,7 +41,9 @@ en:
41
41
  subcommands:
42
42
  add: Add a definition to translation memory
43
43
  export: Export text tags from an MS Office document
44
+ exportxml: Export XML-based text tags from a Word 2003+ document
44
45
  import: Import text tags into an MS Office document
46
+ importxml: Import XML-based text tags into a Word 2003+ document
45
47
  install: Install supplementary scripts
46
48
  language: Sets the default language
47
49
  list: List available dictionaries
data/lib/locales/ja.yml CHANGED
@@ -41,7 +41,9 @@ ja:
41
41
  subcommands:
42
42
  add: 翻訳メモリに定義を追加する
43
43
  export: MSオフィス・ドキュメントからタグを抽出する
44
+ exportxml: Word 2003+からXMLベースのタグを抽出する
44
45
  import: MSオフィス・ドキュメントにタグをインポートする
46
+ importxml: Word 2003+にXMLベースのタグをインポートする
45
47
  install: スクリプトなどをインストールする
46
48
  language: 言語を設定する
47
49
  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.9
4
+ version: 0.2.9.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-01-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: amatch
16
- requirement: &70173664402640 !ruby/object:Gem::Requirement
16
+ requirement: &70294661837240 !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: *70173664402640
24
+ version_requirements: *70294661837240
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: git
27
- requirement: &70173664402040 !ruby/object:Gem::Requirement
27
+ requirement: &70294661836600 !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: *70173664402040
35
+ version_requirements: *70294661836600
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: highline
38
- requirement: &70173664401360 !ruby/object:Gem::Requirement
38
+ requirement: &70294661836160 !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: *70173664401360
46
+ version_requirements: *70294661836160
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: i18n
49
- requirement: &70173664400940 !ruby/object:Gem::Requirement
49
+ requirement: &70294661835720 !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: *70173664400940
57
+ version_requirements: *70294661835720
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: nokogiri
60
- requirement: &70173664400520 !ruby/object:Gem::Requirement
60
+ requirement: &70294661835060 !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: *70173664400520
68
+ version_requirements: *70294661835060
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: sdoc
71
- requirement: &70173664399920 !ruby/object:Gem::Requirement
71
+ requirement: &70294661834380 !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: *70173664399920
79
+ version_requirements: *70294661834380
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: term-ansicolor
82
- requirement: &70173664421020 !ruby/object:Gem::Requirement
82
+ requirement: &70294661833800 !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: *70173664421020
90
+ version_requirements: *70294661833800
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: trollop
93
- requirement: &70173664420400 !ruby/object:Gem::Requirement
93
+ requirement: &70294661833160 !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: *70173664420400
101
+ version_requirements: *70294661833160
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: autotest
104
- requirement: &70173664419720 !ruby/object:Gem::Requirement
104
+ requirement: &70294661832520 !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: *70173664419720
112
+ version_requirements: *70294661832520
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: autotest-fsevent
115
- requirement: &70173664419300 !ruby/object:Gem::Requirement
115
+ requirement: &70294661831880 !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: *70173664419300
123
+ version_requirements: *70294661831880
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: autotest-growl
126
- requirement: &70173664418880 !ruby/object:Gem::Requirement
126
+ requirement: &70294661831460 !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: *70173664418880
134
+ version_requirements: *70294661831460
135
135
  - !ruby/object:Gem::Dependency
136
136
  name: bundler
137
- requirement: &70173664418440 !ruby/object:Gem::Requirement
137
+ requirement: &70294661847340 !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: *70173664418440
145
+ version_requirements: *70294661847340
146
146
  - !ruby/object:Gem::Dependency
147
147
  name: rspec
148
- requirement: &70173664418000 !ruby/object:Gem::Requirement
148
+ requirement: &70294661846900 !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: *70173664418000
156
+ version_requirements: *70294661846900
157
157
  description: A Ruby command-line utility for translating files using a YAML wordlist
158
158
  email:
159
159
  - bryan.mckelvey@gmail.com