tranexp 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,34 @@
1
+ desc 'Release the website and new gem version'
2
+ task :deploy => [:check_version, :website, :release] do
3
+ puts "Remember to create SVN tag:"
4
+ puts "svn copy svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/trunk " +
5
+ "svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/tags/REL-#{VERS} "
6
+ puts "Suggested comment:"
7
+ puts "Tagging release #{CHANGES}"
8
+ end
9
+
10
+ desc 'Runs tasks website_generate and install_gem as a local deployment of the gem'
11
+ task :local_deploy => [:website_generate, :install_gem]
12
+
13
+ task :check_version do
14
+ unless ENV['VERSION']
15
+ puts 'Must pass a VERSION=x.y.z release version'
16
+ exit
17
+ end
18
+ unless ENV['VERSION'] == VERS
19
+ puts "Please update your version.rb to match the release version, currently #{VERS}"
20
+ exit
21
+ end
22
+ end
23
+
24
+ desc 'Install the package as a gem, without generating documentation(ri/rdoc)'
25
+ task :install_gem_no_doc => [:clean, :package] do
26
+ sh "#{'sudo ' unless Hoe::WINDOZE }gem install pkg/*.gem --no-rdoc --no-ri"
27
+ end
28
+
29
+ namespace :manifest do
30
+ desc 'Recreate Manifest.txt to include ALL files'
31
+ task :refresh do
32
+ `rake check_manifest | patch -p0 > Manifest.txt`
33
+ end
34
+ end
@@ -0,0 +1,7 @@
1
+ task :ruby_env do
2
+ RUBY_APP = if RUBY_PLATFORM =~ /java/
3
+ "jruby"
4
+ else
5
+ "ruby"
6
+ end unless defined? RUBY_APP
7
+ end
@@ -0,0 +1,17 @@
1
+ desc 'Generate website files'
2
+ task :website_generate => :ruby_env do
3
+ (Dir['website/**/*.txt'] - Dir['website/version*.txt']).each do |txt|
4
+ sh %{ #{RUBY_APP} script/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
5
+ end
6
+ end
7
+
8
+ desc 'Upload website files to rubyforge'
9
+ task :website_upload do
10
+ host = "#{rubyforge_username}@rubyforge.org"
11
+ remote_dir = "/var/www/gforge-projects/#{PATH}/"
12
+ local_dir = 'website'
13
+ sh %{rsync -aCv #{local_dir}/ #{host}:#{remote_dir}}
14
+ end
15
+
16
+ desc 'Generate and upload website files'
17
+ task :website => [:website_generate, :website_upload, :publish_docs]
@@ -0,0 +1,10 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+ require "tranexp/command"
3
+
4
+ class TestCommand < Test::Unit::TestCase
5
+ def test_run_simple
6
+ Tranexp::Http.any_instance.expects(:translate).with("metoder", "nor", "eng").returns("methods")
7
+ english = Tranexp::Command.run("metoder", "nor", "eng")
8
+ assert_equal("methods", english)
9
+ end
10
+ end
@@ -0,0 +1,16 @@
1
+ require 'test/unit'
2
+ require File.dirname(__FILE__) + '/../lib/tranexp'
3
+
4
+ require 'rubygems'
5
+ gem 'mocha'
6
+ require "mocha"
7
+
8
+ class Test::Unit::TestCase
9
+
10
+ def if_connected(&block)
11
+ unless ENV['NO_CONNECTION']
12
+ yield
13
+ end
14
+ end
15
+
16
+ end
@@ -0,0 +1,38 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestTranexpHttp < Test::Unit::TestCase
4
+ attr_reader :translate
5
+
6
+ def setup
7
+ @translate = Tranexp::Http.new
8
+ end
9
+
10
+ def test_english_to_norwegian
11
+ if_connected do
12
+ assert_nothing_thrown do
13
+ english = translate.translate("metoder", Tranexp::Http::Norwegian, Tranexp::Http::English)
14
+ assert_equal("methods", english)
15
+ end
16
+ end
17
+ end
18
+
19
+ def test_utf8
20
+ if_connected do
21
+ assert_nothing_thrown do
22
+ english = translate.translate("i would like to learn Norwegian", Tranexp::Http::English, Tranexp::Http::Norwegian)
23
+ assert_equal("jeg ville like å høre Norsk", english)
24
+ end
25
+ end
26
+ end
27
+
28
+ def test_english_to_norwegian_method_missing
29
+ translate.expects(:translate).with("metoder", "nor", "eng").returns("methods")
30
+ if_connected do
31
+ assert_nothing_thrown do
32
+ english = translate.from_nor_to_eng("metoder")
33
+ assert_equal("methods", english)
34
+ end
35
+ end
36
+ end
37
+
38
+ end
@@ -0,0 +1,190 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <link rel="stylesheet" href="stylesheets/screen.css" type="text/css" media="screen" />
6
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
7
+ <title>
8
+ tranexp
9
+ </title>
10
+ <script src="javascripts/rounded_corners_lite.inc.js" type="text/javascript"></script>
11
+ <style>
12
+
13
+ </style>
14
+ <script type="text/javascript">
15
+ window.onload = function() {
16
+ settings = {
17
+ tl: { radius: 10 },
18
+ tr: { radius: 10 },
19
+ bl: { radius: 10 },
20
+ br: { radius: 10 },
21
+ antiAlias: true,
22
+ autoPad: true,
23
+ validTags: ["div"]
24
+ }
25
+ var versionBox = new curvyCorners(settings, document.getElementById("version"));
26
+ versionBox.applyCornersToAll();
27
+ }
28
+ </script>
29
+ </head>
30
+ <body>
31
+ <div id="main">
32
+
33
+ <h1>tranexp</h1>
34
+ <div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/tranexp"; return false'>
35
+ <p>Get Version</p>
36
+ <a href="http://rubyforge.org/projects/tranexp" class="numbers">1.0.0</a>
37
+ </div>
38
+ <h1>&#x2192; &#8216;tranexp nor eng&#8217;</h1>
39
+
40
+
41
+ <h2>What</h2>
42
+
43
+
44
+ <p>Translates words or phrases from one language to another, using
45
+ <a href="http://www.tranexp.com:2000/Translate/result.shtml">tranexp website</a></p>
46
+
47
+
48
+ <h2>Installing</h2>
49
+
50
+
51
+ <p><pre class='syntax'><span class="ident">sudo</span> <span class="ident">gem</span> <span class="ident">install</span> <span class="ident">tranexp</span></pre></p>
52
+
53
+
54
+ <h2>The basics</h2>
55
+
56
+
57
+ <p>Has a command-line and <span class="caps">API</span>.</p>
58
+
59
+
60
+ <h3>Command Line</h3>
61
+
62
+
63
+ <p>To translate some text from Danish to English:</p>
64
+
65
+
66
+ <pre>cat some_danish_text.txt | tranexp dan eng
67
+
68
+ echo "jeg ville like en flaske vin" | tranexp nor
69
+ I would like a bottle of wine
70
+ </pre>
71
+
72
+ <p>That is, you pass the input text via <span class="caps">STDIN</span>. The default target language is English (&#8216;eng&#8217;).</p>
73
+
74
+
75
+ <h3><span class="caps">API</span></h3>
76
+
77
+
78
+ <p>To translate some text from English to Norwegian:</p>
79
+
80
+
81
+ <p><pre class='syntax'><span class="ident">translate</span> <span class="punct">=</span> <span class="constant">Tranexp</span><span class="punct">::</span><span class="constant">Http</span><span class="punct">.</span><span class="ident">new</span>
82
+ <span class="ident">english</span> <span class="punct">=</span> <span class="ident">translate</span><span class="punct">.</span><span class="ident">translate</span><span class="punct">(&quot;</span><span class="string">metoder</span><span class="punct">&quot;,</span> <span class="constant">Tranexp</span><span class="punct">::</span><span class="constant">Http</span><span class="punct">::</span><span class="constant">Norwegian</span><span class="punct">,</span> <span class="constant">Tranexp</span><span class="punct">::</span><span class="constant">Http</span><span class="punct">::</span><span class="constant">English</span><span class="punct">)</span>
83
+ <span class="ident">english</span> <span class="punct">=</span> <span class="ident">translate</span><span class="punct">.</span><span class="ident">translate</span><span class="punct">(&quot;</span><span class="string">metoder</span><span class="punct">&quot;,</span> <span class="punct">&quot;</span><span class="string">nor</span><span class="punct">&quot;,</span> <span class="punct">&quot;</span><span class="string">eng</span><span class="punct">&quot;)</span>
84
+ </pre></p>
85
+
86
+
87
+ <p>Or use the dynamic helper:</p>
88
+
89
+
90
+ <p><pre class='syntax'><span class="ident">translate</span><span class="punct">.</span><span class="ident">from_nor_to_eng</span><span class="punct">(&quot;</span><span class="string">metoder</span><span class="punct">&quot;)</span>
91
+ </pre></p>
92
+
93
+
94
+ <h2>Translations</h2>
95
+
96
+
97
+ <p>Tranexp supports translations between the following languages:</p>
98
+
99
+
100
+ <p><pre class='syntax'><span class="punct">{</span>
101
+ <span class="punct">&quot;</span><span class="string">English</span><span class="punct">&quot;</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">eng</span><span class="punct">&quot;,</span>
102
+ <span class="punct">&quot;</span><span class="string">BrazilianPortuguese</span><span class="punct">&quot;</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">pob</span><span class="punct">&quot;,</span>
103
+ <span class="punct">&quot;</span><span class="string">Bulgarian</span><span class="punct">&quot;</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">bul</span><span class="punct">&quot;,</span>
104
+ <span class="punct">&quot;</span><span class="string">Croatian</span><span class="punct">&quot;</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">cro</span><span class="punct">&quot;,</span>
105
+ <span class="punct">&quot;</span><span class="string">Czech</span><span class="punct">&quot;</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">che</span><span class="punct">&quot;,</span>
106
+ <span class="punct">&quot;</span><span class="string">Danish</span><span class="punct">&quot;</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">dan</span><span class="punct">&quot;,</span>
107
+ <span class="punct">&quot;</span><span class="string">Dutch</span><span class="punct">&quot;</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">dut</span><span class="punct">&quot;,</span>
108
+ <span class="punct">&quot;</span><span class="string">Spanish</span><span class="punct">&quot;</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">spa</span><span class="punct">&quot;,</span>
109
+ <span class="punct">&quot;</span><span class="string">Finnish</span><span class="punct">&quot;</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">fin</span><span class="punct">&quot;,</span>
110
+ <span class="punct">&quot;</span><span class="string">French</span><span class="punct">&quot;</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">fre</span><span class="punct">&quot;,</span>
111
+ <span class="punct">&quot;</span><span class="string">German</span><span class="punct">&quot;</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">ger</span><span class="punct">&quot;,</span>
112
+ <span class="punct">&quot;</span><span class="string">Greek</span><span class="punct">&quot;</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">grk</span><span class="punct">&quot;,</span>
113
+ <span class="punct">&quot;</span><span class="string">Hungarian</span><span class="punct">&quot;</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">hun</span><span class="punct">&quot;,</span>
114
+ <span class="punct">&quot;</span><span class="string">Icelandic</span><span class="punct">&quot;</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">ice</span><span class="punct">&quot;,</span>
115
+ <span class="punct">&quot;</span><span class="string">Italian</span><span class="punct">&quot;</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">ita</span><span class="punct">&quot;,</span>
116
+ <span class="punct">&quot;</span><span class="string">Japanese</span><span class="punct">&quot;</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">jpn</span><span class="punct">&quot;,</span>
117
+ <span class="punct">&quot;</span><span class="string">Latin American Spanish</span><span class="punct">&quot;</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">spl</span><span class="punct">&quot;,</span>
118
+ <span class="punct">&quot;</span><span class="string">Norwegian</span><span class="punct">&quot;</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">nor</span><span class="punct">&quot;,</span>
119
+ <span class="punct">&quot;</span><span class="string">Filipino</span><span class="punct">&quot;</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">tag</span><span class="punct">&quot;,</span>
120
+ <span class="punct">&quot;</span><span class="string">Polish</span><span class="punct">&quot;</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">pol</span><span class="punct">&quot;,</span>
121
+ <span class="punct">&quot;</span><span class="string">Portuguese</span><span class="punct">&quot;</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">poe</span><span class="punct">&quot;,</span>
122
+ <span class="punct">&quot;</span><span class="string">Romanian</span><span class="punct">&quot;</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">rom</span><span class="punct">&quot;,</span>
123
+ <span class="punct">&quot;</span><span class="string">Russian</span><span class="punct">&quot;</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">rus</span><span class="punct">&quot;,</span>
124
+ <span class="punct">&quot;</span><span class="string">Serbian</span><span class="punct">&quot;</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">sel</span><span class="punct">&quot;,</span>
125
+ <span class="punct">&quot;</span><span class="string">Slovenian</span><span class="punct">&quot;</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">slo</span><span class="punct">&quot;,</span>
126
+ <span class="punct">&quot;</span><span class="string">Swedish</span><span class="punct">&quot;</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">swe</span><span class="punct">&quot;,</span>
127
+ <span class="punct">&quot;</span><span class="string">Welsh</span><span class="punct">&quot;</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">wel</span><span class="punct">&quot;,</span>
128
+ <span class="punct">&quot;</span><span class="string">Turkish</span><span class="punct">&quot;</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">tur</span><span class="punct">&quot;,</span>
129
+ <span class="punct">&quot;</span><span class="string">Latin</span><span class="punct">&quot;</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">ltt</span><span class="punct">&quot;</span>
130
+ <span class="punct">}</span></pre></p>
131
+
132
+
133
+ <h2>Forum</h2>
134
+
135
+
136
+ <p><a href="http://groups.google.com/group/drnicutilities">http://groups.google.com/group/drnicutilities</a></p>
137
+
138
+
139
+ <h2>How to submit patches</h2>
140
+
141
+
142
+ <p>Read the <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/">8 steps for fixing other people&#8217;s code</a> and for section <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#8b-google-groups">8b: Submit patch to Google Groups</a>, use the Google Group above.</p>
143
+
144
+
145
+ <p>You can fetch the source from either:</p>
146
+
147
+
148
+ <ul>
149
+ <li>github: <a href="http://github.com/drnic/tranexp/tree/master">http://github.com/drnic/tranexp/tree/master</a></li>
150
+ </ul>
151
+
152
+
153
+ <pre>git clone git://github.com/drnic/tranexp.git
154
+ cd tranexp
155
+ rake test
156
+ rake install_gem
157
+ </pre>
158
+
159
+ <ul>
160
+ <li>rubyforge: <a href="http://rubyforge.org/scm/?group_id=6064">http://rubyforge.org/scm/?group_id=6064</a></li>
161
+ </ul>
162
+
163
+
164
+ <pre>git clone git://rubyforge.org/tranexp.git
165
+ cd tranexp
166
+ rake test
167
+ rake install_gem
168
+ </pre>
169
+
170
+ <h2>License</h2>
171
+
172
+
173
+ <p>This code is free to use under the terms of the <span class="caps">MIT</span> license.</p>
174
+
175
+
176
+ <h2>Contact</h2>
177
+
178
+
179
+ <p>Comments are welcome. Send an email to <a href="mailto:drnicwilliams@gmail.com">Dr Nic Williams</a> via the <a href="http://groups.google.com/group/tranexp">forum</a></p>
180
+ <p class="coda">
181
+ <a href="drnicwilliams@gmail.com">Dr Nic Williams</a>, 16th April 2008<br>
182
+ Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>,
183
+ by Daniel Cadenas via <a href="http://depgraph.rubyforge.org/">DepGraph</a>
184
+ </p>
185
+ </div>
186
+
187
+ <!-- insert site tracking codes here, like Google Urchin -->
188
+
189
+ </body>
190
+ </html>
data/website/index.txt ADDED
@@ -0,0 +1,113 @@
1
+ h1. tranexp
2
+
3
+ h1. &#x2192; 'tranexp nor eng'
4
+
5
+ h2. What
6
+
7
+ Translates words or phrases from one language to another, using
8
+ "tranexp website":http://www.tranexp.com:2000/Translate/result.shtml
9
+
10
+ h2. Installing
11
+
12
+ <pre syntax="ruby">sudo gem install tranexp</pre>
13
+
14
+ h2. The basics
15
+
16
+ Has a command-line and API.
17
+
18
+ h3. Command Line
19
+
20
+ To translate some text from Danish to English:
21
+
22
+ <pre>cat some_danish_text.txt | tranexp dan eng
23
+
24
+ echo "jeg ville like en flaske vin" | tranexp nor
25
+ I would like a bottle of wine
26
+ </pre>
27
+
28
+ That is, you pass the input text via STDIN. The default target language is English ('eng').
29
+
30
+ h3. API
31
+
32
+ To translate some text from English to Norwegian:
33
+
34
+ <pre syntax="ruby">translate = Tranexp::Http.new
35
+ english = translate.translate("metoder", Tranexp::Http::Norwegian, Tranexp::Http::English)
36
+ english = translate.translate("metoder", "nor", "eng")
37
+ </pre>
38
+
39
+ Or use the dynamic helper:
40
+
41
+ <pre syntax="ruby">translate.from_nor_to_eng("metoder")
42
+ </pre>
43
+
44
+ h2. Translations
45
+
46
+ Tranexp supports translations between the following languages:
47
+
48
+ <pre syntax="ruby">{
49
+ "English" => "eng",
50
+ "BrazilianPortuguese" => "pob",
51
+ "Bulgarian" => "bul",
52
+ "Croatian" => "cro",
53
+ "Czech" => "che",
54
+ "Danish" => "dan",
55
+ "Dutch" => "dut",
56
+ "Spanish" => "spa",
57
+ "Finnish" => "fin",
58
+ "French" => "fre",
59
+ "German" => "ger",
60
+ "Greek" => "grk",
61
+ "Hungarian" => "hun",
62
+ "Icelandic" => "ice",
63
+ "Italian" => "ita",
64
+ "Japanese" => "jpn",
65
+ "Latin American Spanish" => "spl",
66
+ "Norwegian" => "nor",
67
+ "Filipino" => "tag",
68
+ "Polish" => "pol",
69
+ "Portuguese" => "poe",
70
+ "Romanian" => "rom",
71
+ "Russian" => "rus",
72
+ "Serbian" => "sel",
73
+ "Slovenian" => "slo",
74
+ "Swedish" => "swe",
75
+ "Welsh" => "wel",
76
+ "Turkish" => "tur",
77
+ "Latin" => "ltt"
78
+ }</pre>
79
+
80
+ h2. Forum
81
+
82
+ "http://groups.google.com/group/drnicutilities":http://groups.google.com/group/drnicutilities
83
+
84
+ h2. How to submit patches
85
+
86
+ Read the "8 steps for fixing other people's code":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/ and for section "8b: Submit patch to Google Groups":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#8b-google-groups, use the Google Group above.
87
+
88
+ You can fetch the source from either:
89
+
90
+ * github: "http://github.com/drnic/tranexp/tree/master":http://github.com/drnic/tranexp/tree/master
91
+
92
+ <pre>git clone git://github.com/drnic/tranexp.git
93
+ cd tranexp
94
+ rake test
95
+ rake install_gem
96
+ </pre>
97
+
98
+ * rubyforge: "http://rubyforge.org/scm/?group_id=6064":http://rubyforge.org/scm/?group_id=6064
99
+
100
+ <pre>git clone git://rubyforge.org/tranexp.git
101
+ cd tranexp
102
+ rake test
103
+ rake install_gem
104
+ </pre>
105
+
106
+ h2. License
107
+
108
+ This code is free to use under the terms of the MIT license.
109
+
110
+ h2. Contact
111
+
112
+ Comments are welcome. Send an email to "Dr Nic Williams":mailto:drnicwilliams@gmail.com via the "forum":http://groups.google.com/group/drnicutilities
113
+