babelphish 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (219) hide show
  1. data/.gitignore +6 -0
  2. data/LICENSE +1 -1
  3. data/README.rdoc +91 -1
  4. data/Rakefile +17 -31
  5. data/VERSION +1 -0
  6. data/babelphish.gemspec +268 -0
  7. data/bin/babelphish +1 -0
  8. data/config/website.yml +2 -0
  9. data/doc/classes/Babelphish.html +206 -0
  10. data/doc/classes/Babelphish/Exceptions.html +111 -0
  11. data/doc/classes/Babelphish/Exceptions/GoogleResponseError.html +111 -0
  12. data/doc/classes/Babelphish/GoogleTranslate.html +565 -0
  13. data/doc/classes/Babelphish/HtmlTranslator.html +335 -0
  14. data/doc/classes/Babelphish/Translator.html +311 -0
  15. data/doc/classes/Babelphish/YmlTranslator.html +402 -0
  16. data/doc/created.rid +1 -0
  17. data/doc/files/History_txt.html +110 -0
  18. data/doc/files/PostInstall_txt.html +108 -0
  19. data/doc/files/README_rdoc.html +255 -0
  20. data/doc/files/bin/babelphish.html +109 -0
  21. data/doc/files/lib/babelphish/exceptions_rb.html +101 -0
  22. data/doc/files/lib/babelphish/html_translator_rb.html +101 -0
  23. data/doc/files/lib/babelphish/languages_rb.html +108 -0
  24. data/doc/files/lib/babelphish/translator_rb.html +101 -0
  25. data/doc/files/lib/babelphish/yml_translator_rb.html +101 -0
  26. data/doc/files/lib/babelphish_rb.html +113 -0
  27. data/doc/files/lib/tasks/babelphish_rake.html +147 -0
  28. data/doc/fr_class_index.html +33 -0
  29. data/doc/fr_file_index.html +37 -0
  30. data/doc/fr_method_index.html +43 -0
  31. data/doc/index.html +24 -0
  32. data/doc/rdoc-style.css +208 -0
  33. data/lib/babelphish.rb +1 -1
  34. data/lib/babelphish/html_translator.rb +6 -0
  35. data/lib/babelphish/translator.rb +8 -4
  36. data/lib/babelphish/yml_translator.rb +23 -14
  37. data/lib/tasks/babelphish.rake +25 -12
  38. data/script/txt2html +71 -0
  39. data/test/html_translations/test.ar.html.erb +4 -0
  40. data/test/html_translations/test.bg.html.erb +4 -0
  41. data/test/html_translations/test.ca.html.erb +4 -0
  42. data/test/html_translations/test.cs.html.erb +4 -0
  43. data/test/html_translations/test.da.html.erb +4 -0
  44. data/test/html_translations/test.de.html.erb +4 -0
  45. data/test/html_translations/test.el.html.erb +4 -0
  46. data/test/html_translations/test.es.html.erb +4 -0
  47. data/test/html_translations/test.et.html.erb +4 -0
  48. data/test/html_translations/test.fa.html.erb +4 -0
  49. data/test/html_translations/test.fi.html.erb +4 -0
  50. data/test/html_translations/test.fr.html.erb +4 -0
  51. data/test/html_translations/test.gl.html.erb +4 -0
  52. data/test/html_translations/test.hi.html.erb +4 -0
  53. data/test/html_translations/test.hr.html.erb +4 -0
  54. data/test/html_translations/test.html.erb +4 -0
  55. data/test/html_translations/test.hu.html.erb +4 -0
  56. data/test/html_translations/test.id.html.erb +4 -0
  57. data/test/html_translations/test.it.html.erb +4 -0
  58. data/test/html_translations/test.iw.html.erb +4 -0
  59. data/test/html_translations/test.ja.html.erb +4 -0
  60. data/test/html_translations/test.ko.html.erb +4 -0
  61. data/test/html_translations/test.lt.html.erb +4 -0
  62. data/test/html_translations/test.lv.html.erb +4 -0
  63. data/test/html_translations/test.mt.html.erb +4 -0
  64. data/test/html_translations/test.nl.html.erb +4 -0
  65. data/test/html_translations/test.no.html.erb +4 -0
  66. data/test/html_translations/test.pl.html.erb +4 -0
  67. data/test/html_translations/test.pt-PT.html.erb +4 -0
  68. data/test/html_translations/test.ro.html.erb +4 -0
  69. data/test/html_translations/test.ru.html.erb +4 -0
  70. data/test/html_translations/test.sk.html.erb +4 -0
  71. data/test/html_translations/test.sl.html.erb +4 -0
  72. data/test/html_translations/test.sq.html.erb +4 -0
  73. data/test/html_translations/test.sr.html.erb +4 -0
  74. data/test/html_translations/test.sv.html.erb +4 -0
  75. data/test/html_translations/test.text.ar.html.erb +5 -0
  76. data/test/html_translations/test.text.ar.plain.erb +8 -0
  77. data/test/html_translations/test.text.bg.html.erb +5 -0
  78. data/test/html_translations/test.text.bg.plain.erb +8 -0
  79. data/test/html_translations/test.text.ca.html.erb +5 -0
  80. data/test/html_translations/test.text.ca.plain.erb +8 -0
  81. data/test/html_translations/test.text.cs.html.erb +5 -0
  82. data/test/html_translations/test.text.cs.plain.erb +8 -0
  83. data/test/html_translations/test.text.da.html.erb +5 -0
  84. data/test/html_translations/test.text.da.plain.erb +8 -0
  85. data/test/html_translations/test.text.de.html.erb +5 -0
  86. data/test/html_translations/test.text.de.plain.erb +8 -0
  87. data/test/html_translations/test.text.el.html.erb +5 -0
  88. data/test/html_translations/test.text.el.plain.erb +8 -0
  89. data/test/html_translations/test.text.es.html.erb +5 -0
  90. data/test/html_translations/test.text.es.plain.erb +8 -0
  91. data/test/html_translations/test.text.et.html.erb +5 -0
  92. data/test/html_translations/test.text.et.plain.erb +8 -0
  93. data/test/html_translations/test.text.fa.html.erb +5 -0
  94. data/test/html_translations/test.text.fa.plain.erb +8 -0
  95. data/test/html_translations/test.text.fi.html.erb +5 -0
  96. data/test/html_translations/test.text.fi.plain.erb +8 -0
  97. data/test/html_translations/test.text.fr.html.erb +5 -0
  98. data/test/html_translations/test.text.fr.plain.erb +8 -0
  99. data/test/html_translations/test.text.gl.html.erb +5 -0
  100. data/test/html_translations/test.text.gl.plain.erb +8 -0
  101. data/test/html_translations/test.text.hi.html.erb +5 -0
  102. data/test/html_translations/test.text.hi.plain.erb +8 -0
  103. data/test/html_translations/test.text.hr.html.erb +5 -0
  104. data/test/html_translations/test.text.hr.plain.erb +8 -0
  105. data/test/html_translations/test.text.html.erb +5 -0
  106. data/test/html_translations/test.text.hu.html.erb +5 -0
  107. data/test/html_translations/test.text.hu.plain.erb +8 -0
  108. data/test/html_translations/test.text.id.html.erb +5 -0
  109. data/test/html_translations/test.text.id.plain.erb +8 -0
  110. data/test/html_translations/test.text.it.html.erb +5 -0
  111. data/test/html_translations/test.text.it.plain.erb +8 -0
  112. data/test/html_translations/test.text.iw.html.erb +5 -0
  113. data/test/html_translations/test.text.iw.plain.erb +8 -0
  114. data/test/html_translations/test.text.ja.html.erb +5 -0
  115. data/test/html_translations/test.text.ja.plain.erb +8 -0
  116. data/test/html_translations/test.text.ko.html.erb +5 -0
  117. data/test/html_translations/test.text.ko.plain.erb +8 -0
  118. data/test/html_translations/test.text.lt.html.erb +5 -0
  119. data/test/html_translations/test.text.lt.plain.erb +8 -0
  120. data/test/html_translations/test.text.lv.html.erb +5 -0
  121. data/test/html_translations/test.text.lv.plain.erb +8 -0
  122. data/test/html_translations/test.text.mt.html.erb +5 -0
  123. data/test/html_translations/test.text.mt.plain.erb +8 -0
  124. data/test/html_translations/test.text.nl.html.erb +5 -0
  125. data/test/html_translations/test.text.nl.plain.erb +8 -0
  126. data/test/html_translations/test.text.no.html.erb +5 -0
  127. data/test/html_translations/test.text.no.plain.erb +8 -0
  128. data/test/html_translations/test.text.pl.html.erb +5 -0
  129. data/test/html_translations/test.text.pl.plain.erb +8 -0
  130. data/test/html_translations/test.text.plain.erb +8 -0
  131. data/test/html_translations/test.text.pt-PT.html.erb +5 -0
  132. data/test/html_translations/test.text.pt-PT.plain.erb +8 -0
  133. data/test/html_translations/test.text.ro.html.erb +5 -0
  134. data/test/html_translations/test.text.ro.plain.erb +8 -0
  135. data/test/html_translations/test.text.ru.html.erb +5 -0
  136. data/test/html_translations/test.text.ru.plain.erb +8 -0
  137. data/test/html_translations/test.text.sk.html.erb +5 -0
  138. data/test/html_translations/test.text.sk.plain.erb +8 -0
  139. data/test/html_translations/test.text.sl.html.erb +5 -0
  140. data/test/html_translations/test.text.sl.plain.erb +8 -0
  141. data/test/html_translations/test.text.sq.html.erb +5 -0
  142. data/test/html_translations/test.text.sq.plain.erb +8 -0
  143. data/test/html_translations/test.text.sr.html.erb +5 -0
  144. data/test/html_translations/test.text.sr.plain.erb +8 -0
  145. data/test/html_translations/test.text.sv.html.erb +5 -0
  146. data/test/html_translations/test.text.sv.plain.erb +8 -0
  147. data/test/html_translations/test.text.th.html.erb +5 -0
  148. data/test/html_translations/test.text.th.plain.erb +8 -0
  149. data/test/html_translations/test.text.tl.html.erb +5 -0
  150. data/test/html_translations/test.text.tl.plain.erb +8 -0
  151. data/test/html_translations/test.text.tr.html.erb +5 -0
  152. data/test/html_translations/test.text.tr.plain.erb +8 -0
  153. data/test/html_translations/test.text.uk.html.erb +5 -0
  154. data/test/html_translations/test.text.uk.plain.erb +8 -0
  155. data/test/html_translations/test.text.vi.html.erb +5 -0
  156. data/test/html_translations/test.text.vi.plain.erb +8 -0
  157. data/test/html_translations/test.text.zh-CN.html.erb +5 -0
  158. data/test/html_translations/test.text.zh-CN.plain.erb +8 -0
  159. data/test/html_translations/test.text.zh-TW.html.erb +5 -0
  160. data/test/html_translations/test.text.zh-TW.plain.erb +8 -0
  161. data/test/html_translations/test.text.zh.html.erb +5 -0
  162. data/test/html_translations/test.text.zh.plain.erb +8 -0
  163. data/test/html_translations/test.th.html.erb +4 -0
  164. data/test/html_translations/test.tl.html.erb +4 -0
  165. data/test/html_translations/test.tr.html.erb +4 -0
  166. data/test/html_translations/test.uk.html.erb +4 -0
  167. data/test/html_translations/test.vi.html.erb +4 -0
  168. data/test/html_translations/test.zh-CN.html.erb +4 -0
  169. data/test/html_translations/test.zh-TW.html.erb +4 -0
  170. data/test/html_translations/test.zh.html.erb +4 -0
  171. data/test/test_yml_translator.rb +3 -2
  172. data/test/translations/ar.yml +7 -0
  173. data/test/translations/bg.yml +7 -0
  174. data/test/translations/ca.yml +7 -0
  175. data/test/translations/cs.yml +7 -0
  176. data/test/translations/da.yml +7 -0
  177. data/test/translations/de.yml +7 -0
  178. data/test/translations/el.yml +7 -0
  179. data/test/translations/en.yml +6 -0
  180. data/test/translations/es.yml +7 -0
  181. data/test/translations/et.yml +7 -0
  182. data/test/translations/fa.yml +7 -0
  183. data/test/translations/fi.yml +7 -0
  184. data/test/translations/fr.yml +7 -0
  185. data/test/translations/gl.yml +7 -0
  186. data/test/translations/hi.yml +7 -0
  187. data/test/translations/hr.yml +7 -0
  188. data/test/translations/hu.yml +7 -0
  189. data/test/translations/id.yml +7 -0
  190. data/test/translations/it.yml +7 -0
  191. data/test/translations/iw.yml +7 -0
  192. data/test/translations/ja.yml +7 -0
  193. data/test/translations/ko.yml +7 -0
  194. data/test/translations/lt.yml +7 -0
  195. data/test/translations/lv.yml +7 -0
  196. data/test/translations/mt.yml +7 -0
  197. data/test/translations/nl.yml +7 -0
  198. data/test/translations/no.yml +8 -0
  199. data/test/translations/pl.yml +7 -0
  200. data/test/translations/pt-PT.yml +7 -0
  201. data/test/translations/ro.yml +7 -0
  202. data/test/translations/ru.yml +7 -0
  203. data/test/translations/sk.yml +7 -0
  204. data/test/translations/sl.yml +7 -0
  205. data/test/translations/sq.yml +7 -0
  206. data/test/translations/sr.yml +7 -0
  207. data/test/translations/sv.yml +7 -0
  208. data/test/translations/th.yml +7 -0
  209. data/test/translations/tl.yml +7 -0
  210. data/test/translations/tr.yml +7 -0
  211. data/test/translations/uk.yml +7 -0
  212. data/test/translations/vi.yml +7 -0
  213. data/test/translations/zh-CN.yml +7 -0
  214. data/test/translations/zh-TW.yml +7 -0
  215. data/test/translations/zh.yml +7 -0
  216. metadata +222 -49
  217. data/History.txt +0 -3
  218. data/Manifest.txt +0 -19
  219. data/PostInstall.txt +0 -2
@@ -0,0 +1,402 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Module: Babelphish::YmlTranslator</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Module</strong></td>
53
+ <td class="class-name-in-header">Babelphish::YmlTranslator</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../files/lib/babelphish/yml_translator_rb.html">
59
+ lib/babelphish/yml_translator.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ </table>
66
+ </div>
67
+ <!-- banner header -->
68
+
69
+ <div id="bodyContent">
70
+
71
+
72
+
73
+ <div id="contextContent">
74
+
75
+
76
+
77
+ </div>
78
+
79
+ <div id="method-list">
80
+ <h3 class="section-bar">Methods</h3>
81
+
82
+ <div class="name-list">
83
+ <a href="#M000015">extract_yml_translation</a>&nbsp;&nbsp;
84
+ <a href="#M000017">parse_substitutions</a>&nbsp;&nbsp;
85
+ <a href="#M000011">translate</a>&nbsp;&nbsp;
86
+ <a href="#M000014">translate_and_write_many_yml</a>&nbsp;&nbsp;
87
+ <a href="#M000012">translate_and_write_yml</a>&nbsp;&nbsp;
88
+ <a href="#M000013">translate_keys</a>&nbsp;&nbsp;
89
+ <a href="#M000016">translate_many_yml_keys</a>&nbsp;&nbsp;
90
+ </div>
91
+ </div>
92
+
93
+ </div>
94
+
95
+
96
+ <!-- if includes -->
97
+
98
+ <div id="section">
99
+
100
+
101
+ <div id="constants-list">
102
+ <h3 class="section-bar">Constants</h3>
103
+
104
+ <div class="name-list">
105
+ <table summary="Constants">
106
+ <tr class="top-aligned-row context-row">
107
+ <td class="context-item-name">SUBSTITUTION_PLACE_HOLDER</td>
108
+ <td>=</td>
109
+ <td class="context-item-value">'{{---}}'</td>
110
+ </tr>
111
+ </table>
112
+ </div>
113
+ </div>
114
+
115
+
116
+
117
+
118
+
119
+
120
+ <!-- if method_list -->
121
+ <div id="methods">
122
+ <h3 class="section-bar">Public Class methods</h3>
123
+
124
+ <div id="method-M000015" class="method-detail">
125
+ <a name="M000015"></a>
126
+
127
+ <div class="method-heading">
128
+ <a href="#M000015" class="method-signature">
129
+ <span class="method-name">extract_yml_translation</span><span class="method-args">(source, translated_source, extracted, language)</span>
130
+ </a>
131
+ </div>
132
+
133
+ <div class="method-description">
134
+ <p><a class="source-toggle" href="#"
135
+ onclick="toggleCode('M000015-source');return false;">[Source]</a></p>
136
+ <div class="method-source-code" id="M000015-source">
137
+ <pre>
138
+ <span class="ruby-comment cmt"># File lib/babelphish/yml_translator.rb, line 86</span>
139
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">extract_yml_translation</span>(<span class="ruby-identifier">source</span>, <span class="ruby-identifier">translated_source</span>, <span class="ruby-identifier">extracted</span>, <span class="ruby-identifier">language</span>)
140
+ <span class="ruby-identifier">source</span>.<span class="ruby-identifier">each_key</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span>
141
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">source</span>[<span class="ruby-identifier">key</span>].<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>)
142
+ <span class="ruby-identifier">extracted</span>[<span class="ruby-identifier">key</span>] = {}
143
+ <span class="ruby-identifier">extract_yml_translation</span>(<span class="ruby-identifier">source</span>[<span class="ruby-identifier">key</span>], <span class="ruby-identifier">translated_source</span>[<span class="ruby-identifier">key</span>], <span class="ruby-identifier">extracted</span>[<span class="ruby-identifier">key</span>], <span class="ruby-identifier">language</span>)
144
+ <span class="ruby-keyword kw">else</span>
145
+ <span class="ruby-identifier">extracted</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">translated_source</span>[<span class="ruby-identifier">key</span>][<span class="ruby-identifier">language</span>]
146
+ <span class="ruby-keyword kw">end</span>
147
+ <span class="ruby-keyword kw">end</span>
148
+ <span class="ruby-keyword kw">end</span>
149
+ </pre>
150
+ </div>
151
+ </div>
152
+ </div>
153
+
154
+ <div id="method-M000017" class="method-detail">
155
+ <a name="M000017"></a>
156
+
157
+ <div class="method-heading">
158
+ <a href="#M000017" class="method-signature">
159
+ <span class="method-name">parse_substitutions</span><span class="method-args">(translate_text)</span>
160
+ </a>
161
+ </div>
162
+
163
+ <div class="method-description">
164
+ <p><a class="source-toggle" href="#"
165
+ onclick="toggleCode('M000017-source');return false;">[Source]</a></p>
166
+ <div class="method-source-code" id="M000017-source">
167
+ <pre>
168
+ <span class="ruby-comment cmt"># File lib/babelphish/yml_translator.rb, line 122</span>
169
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse_substitutions</span>(<span class="ruby-identifier">translate_text</span>)
170
+ <span class="ruby-comment cmt"># pull out all the string substitutions so that google doesn't translate those</span>
171
+ <span class="ruby-identifier">pattern</span> = <span class="ruby-regexp re">/\{\{.+?\}\}/</span> <span class="ruby-comment cmt"># non greedy pattern match so that we properly match strings like: &quot;{{name}} on {{application_name}}&quot;</span>
172
+ <span class="ruby-identifier">replacements</span> = <span class="ruby-identifier">translate_text</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-identifier">pattern</span>)
173
+ <span class="ruby-identifier">translate_text</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-identifier">pattern</span>, <span class="ruby-constant">SUBSTITUTION_PLACE_HOLDER</span>)
174
+ <span class="ruby-identifier">replacements</span>
175
+ <span class="ruby-keyword kw">end</span>
176
+ </pre>
177
+ </div>
178
+ </div>
179
+ </div>
180
+
181
+ <div id="method-M000011" class="method-detail">
182
+ <a name="M000011"></a>
183
+
184
+ <div class="method-heading">
185
+ <a href="#M000011" class="method-signature">
186
+ <span class="method-name">translate</span><span class="method-args">(yml, overwrite = false, translate_to = nil, tos = nil)</span>
187
+ </a>
188
+ </div>
189
+
190
+ <div class="method-description">
191
+ <p>
192
+ Translates the given yml file into the specified languages. Will attempt to
193
+ auto detect the from langauge using the name of the yml file. yml - Path to
194
+ the yml file to be translated overwrite - Boolean indicating whether or not
195
+ existing translations should be overwritten. translate_to - A single
196
+ language to <a href="YmlTranslator.html#M000011">translate</a> the file
197
+ into. (Valid values are specified in languages.rb)
198
+ </p>
199
+ <pre>
200
+ When this value is nil tos or Babelphish::GoogleTranslate::LANGUAGES is used to determine the languages
201
+ </pre>
202
+ <p>
203
+ tos - An array containing the languages to <a
204
+ href="YmlTranslator.html#M000011">translate</a> the yml file into. If nil
205
+ or not specified then
206
+ </p>
207
+ <pre>
208
+ Babelphish::GoogleTranslate::LANGUAGES is used.
209
+ </pre>
210
+ <p><a class="source-toggle" href="#"
211
+ onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
212
+ <div class="method-source-code" id="M000011-source">
213
+ <pre>
214
+ <span class="ruby-comment cmt"># File lib/babelphish/yml_translator.rb, line 16</span>
215
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">translate</span>(<span class="ruby-identifier">yml</span>, <span class="ruby-identifier">overwrite</span> = <span class="ruby-keyword kw">false</span>, <span class="ruby-identifier">translate_to</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">tos</span> = <span class="ruby-keyword kw">nil</span>)
216
+ <span class="ruby-ivar">@yml</span> = <span class="ruby-identifier">yml</span>
217
+ <span class="ruby-identifier">language</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">basename</span>(<span class="ruby-identifier">yml</span>, <span class="ruby-value str">&quot;.yml&quot;</span>)
218
+ <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-constant">Babelphish</span><span class="ruby-operator">::</span><span class="ruby-constant">GoogleTranslate</span><span class="ruby-operator">::</span><span class="ruby-constant">LANGUAGES</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">language</span>)
219
+ <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{language} is not one of the available languages. Please choose a standard localized yml file. i.e. en.yml.&quot;</span>
220
+ <span class="ruby-keyword kw">return</span>
221
+ <span class="ruby-keyword kw">end</span>
222
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">translate_to</span>
223
+ <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Translating #{language} to #{translate_to}&quot;</span>
224
+ <span class="ruby-identifier">translate_and_write_yml</span>(<span class="ruby-identifier">yml</span>, <span class="ruby-identifier">translate_to</span>, <span class="ruby-identifier">language</span>, <span class="ruby-identifier">overwrite</span>)
225
+ <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Finished translating #{language} to #{translate_to}&quot;</span>
226
+ <span class="ruby-keyword kw">else</span>
227
+ <span class="ruby-identifier">translate_and_write_many_yml</span>(<span class="ruby-identifier">yml</span>, <span class="ruby-identifier">tos</span>, <span class="ruby-identifier">language</span>, <span class="ruby-identifier">overwrite</span>)
228
+ <span class="ruby-keyword kw">end</span>
229
+ <span class="ruby-keyword kw">end</span>
230
+ </pre>
231
+ </div>
232
+ </div>
233
+ </div>
234
+
235
+ <div id="method-M000014" class="method-detail">
236
+ <a name="M000014"></a>
237
+
238
+ <div class="method-heading">
239
+ <a href="#M000014" class="method-signature">
240
+ <span class="method-name">translate_and_write_many_yml</span><span class="method-args">(yml, tos, from, overwrite)</span>
241
+ </a>
242
+ </div>
243
+
244
+ <div class="method-description">
245
+ <p><a class="source-toggle" href="#"
246
+ onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
247
+ <div class="method-source-code" id="M000014-source">
248
+ <pre>
249
+ <span class="ruby-comment cmt"># File lib/babelphish/yml_translator.rb, line 67</span>
250
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">translate_and_write_many_yml</span>(<span class="ruby-identifier">yml</span>, <span class="ruby-identifier">tos</span>, <span class="ruby-identifier">from</span>, <span class="ruby-identifier">overwrite</span>)
251
+ <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-identifier">yml</span>)
252
+ <span class="ruby-identifier">source</span> = <span class="ruby-constant">YAML</span>.<span class="ruby-identifier">load_file</span>(<span class="ruby-identifier">yml</span>)
253
+ <span class="ruby-identifier">translated_source</span> = <span class="ruby-constant">YAML</span>.<span class="ruby-identifier">load_file</span>(<span class="ruby-identifier">yml</span>)
254
+ <span class="ruby-identifier">translate_many_yml_keys</span>(<span class="ruby-identifier">translated_source</span>, <span class="ruby-identifier">tos</span>, <span class="ruby-identifier">from</span>)
255
+ <span class="ruby-comment cmt"># At this point translated_source contains a translation for every language. Cut it apart into individual hashes</span>
256
+ <span class="ruby-identifier">tos</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">to</span><span class="ruby-operator">|</span>
257
+ <span class="ruby-keyword kw">next</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">to</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">from</span> <span class="ruby-comment cmt"># don't want to overwrite the source file</span>
258
+ <span class="ruby-identifier">extracted_translation</span> = {}
259
+ <span class="ruby-identifier">extract_yml_translation</span>(<span class="ruby-identifier">source</span>, <span class="ruby-identifier">translated_source</span>, <span class="ruby-identifier">extracted_translation</span>, <span class="ruby-identifier">to</span>)
260
+ <span class="ruby-comment cmt"># change the top level key from the source language to the destination language</span>
261
+ <span class="ruby-identifier">translated_filename</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">dirname</span>(<span class="ruby-identifier">yml</span>), <span class="ruby-node">&quot;#{to}.yml&quot;</span>)
262
+ <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-identifier">translated_filename</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-identifier">overwrite</span>
263
+ <span class="ruby-identifier">extracted_translation</span>[<span class="ruby-identifier">to</span>] = <span class="ruby-identifier">extracted_translation</span>[<span class="ruby-identifier">from</span>]
264
+ <span class="ruby-identifier">extracted_translation</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">from</span>)
265
+ <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">translated_filename</span>, <span class="ruby-value str">'w'</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">extracted_translation</span>.<span class="ruby-identifier">ya2yaml</span>) }
266
+ <span class="ruby-keyword kw">end</span>
267
+ <span class="ruby-keyword kw">end</span>
268
+ </pre>
269
+ </div>
270
+ </div>
271
+ </div>
272
+
273
+ <div id="method-M000012" class="method-detail">
274
+ <a name="M000012"></a>
275
+
276
+ <div class="method-heading">
277
+ <a href="#M000012" class="method-signature">
278
+ <span class="method-name">translate_and_write_yml</span><span class="method-args">(yml, to, from, overwrite)</span>
279
+ </a>
280
+ </div>
281
+
282
+ <div class="method-description">
283
+ <p><a class="source-toggle" href="#"
284
+ onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
285
+ <div class="method-source-code" id="M000012-source">
286
+ <pre>
287
+ <span class="ruby-comment cmt"># File lib/babelphish/yml_translator.rb, line 32</span>
288
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">translate_and_write_yml</span>(<span class="ruby-identifier">yml</span>, <span class="ruby-identifier">to</span>, <span class="ruby-identifier">from</span>, <span class="ruby-identifier">overwrite</span>)
289
+ <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">to</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">from</span>
290
+ <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-identifier">yml</span>)
291
+ <span class="ruby-identifier">translated_filename</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">dirname</span>(<span class="ruby-identifier">yml</span>), <span class="ruby-node">&quot;#{to}.yml&quot;</span>)
292
+ <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-identifier">translated_filename</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-identifier">overwrite</span>
293
+ <span class="ruby-identifier">source</span> = <span class="ruby-constant">YAML</span>.<span class="ruby-identifier">load_file</span>(<span class="ruby-identifier">yml</span>)
294
+ <span class="ruby-identifier">translate_keys</span>(<span class="ruby-identifier">source</span>, <span class="ruby-identifier">to</span>, <span class="ruby-identifier">from</span>)
295
+ <span class="ruby-comment cmt"># change the top level key from the source language to the destination language</span>
296
+ <span class="ruby-identifier">source</span>[<span class="ruby-identifier">to</span>] = <span class="ruby-identifier">source</span>[<span class="ruby-identifier">from</span>]
297
+ <span class="ruby-identifier">source</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">from</span>)
298
+ <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">translated_filename</span>, <span class="ruby-value str">'w'</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">source</span>.<span class="ruby-identifier">ya2yaml</span>) }
299
+ <span class="ruby-keyword kw">end</span>
300
+ </pre>
301
+ </div>
302
+ </div>
303
+ </div>
304
+
305
+ <div id="method-M000013" class="method-detail">
306
+ <a name="M000013"></a>
307
+
308
+ <div class="method-heading">
309
+ <a href="#M000013" class="method-signature">
310
+ <span class="method-name">translate_keys</span><span class="method-args">(translate_hash, to, from)</span>
311
+ </a>
312
+ </div>
313
+
314
+ <div class="method-description">
315
+ <p><a class="source-toggle" href="#"
316
+ onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
317
+ <div class="method-source-code" id="M000013-source">
318
+ <pre>
319
+ <span class="ruby-comment cmt"># File lib/babelphish/yml_translator.rb, line 45</span>
320
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">translate_keys</span>(<span class="ruby-identifier">translate_hash</span>, <span class="ruby-identifier">to</span>, <span class="ruby-identifier">from</span>)
321
+ <span class="ruby-identifier">translate_hash</span>.<span class="ruby-identifier">each_key</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span>
322
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">translate_hash</span>[<span class="ruby-identifier">key</span>].<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>)
323
+ <span class="ruby-identifier">translate_keys</span>(<span class="ruby-identifier">translate_hash</span>[<span class="ruby-identifier">key</span>], <span class="ruby-identifier">to</span>, <span class="ruby-identifier">from</span>)
324
+ <span class="ruby-keyword kw">else</span>
325
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">key</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">false</span>
326
+ <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Key #{key} was evaluated as false. Check your yml file and be sure to escape values like no with 'no'. ie 'no': 'No'&quot;</span>
327
+ <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">key</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">true</span>
328
+ <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Key #{key} was evaluated as true. Check your yml file and be sure to escape values like yes with 'yes'. ie 'yes': 'Yes'&quot;</span>
329
+ <span class="ruby-keyword kw">elsif</span> <span class="ruby-operator">!</span><span class="ruby-identifier">translate_hash</span>[<span class="ruby-identifier">key</span>].<span class="ruby-identifier">nil?</span>
330
+ <span class="ruby-identifier">replacements</span> = <span class="ruby-identifier">parse_substitutions</span>(<span class="ruby-identifier">translate_hash</span>[<span class="ruby-identifier">key</span>])
331
+ <span class="ruby-identifier">translate_hash</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-constant">Babelphish</span><span class="ruby-operator">::</span><span class="ruby-constant">Translator</span>.<span class="ruby-identifier">translate</span>(<span class="ruby-identifier">translate_hash</span>[<span class="ruby-identifier">key</span>], <span class="ruby-identifier">to</span>, <span class="ruby-identifier">from</span>)
332
+ <span class="ruby-identifier">replacements</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">r</span><span class="ruby-operator">|</span>
333
+ <span class="ruby-identifier">translate_hash</span>[<span class="ruby-identifier">key</span>].<span class="ruby-identifier">sub!</span>(<span class="ruby-constant">SUBSTITUTION_PLACE_HOLDER</span>, <span class="ruby-identifier">r</span>)
334
+ <span class="ruby-keyword kw">end</span>
335
+ <span class="ruby-keyword kw">else</span>
336
+ <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Key #{key} contains no data&quot;</span>
337
+ <span class="ruby-keyword kw">end</span>
338
+ <span class="ruby-keyword kw">end</span>
339
+ <span class="ruby-keyword kw">end</span>
340
+ <span class="ruby-keyword kw">end</span>
341
+ </pre>
342
+ </div>
343
+ </div>
344
+ </div>
345
+
346
+ <div id="method-M000016" class="method-detail">
347
+ <a name="M000016"></a>
348
+
349
+ <div class="method-heading">
350
+ <a href="#M000016" class="method-signature">
351
+ <span class="method-name">translate_many_yml_keys</span><span class="method-args">(translate_hash, tos, from)</span>
352
+ </a>
353
+ </div>
354
+
355
+ <div class="method-description">
356
+ <p><a class="source-toggle" href="#"
357
+ onclick="toggleCode('M000016-source');return false;">[Source]</a></p>
358
+ <div class="method-source-code" id="M000016-source">
359
+ <pre>
360
+ <span class="ruby-comment cmt"># File lib/babelphish/yml_translator.rb, line 97</span>
361
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">translate_many_yml_keys</span>(<span class="ruby-identifier">translate_hash</span>, <span class="ruby-identifier">tos</span>, <span class="ruby-identifier">from</span>)
362
+ <span class="ruby-identifier">translate_hash</span>.<span class="ruby-identifier">each_key</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span>
363
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">translate_hash</span>[<span class="ruby-identifier">key</span>].<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>)
364
+ <span class="ruby-identifier">translate_many_yml_keys</span>(<span class="ruby-identifier">translate_hash</span>[<span class="ruby-identifier">key</span>], <span class="ruby-identifier">tos</span>, <span class="ruby-identifier">from</span>)
365
+ <span class="ruby-keyword kw">else</span>
366
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">key</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">false</span>
367
+ <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Key #{key} was evaluated as false. Check your yml file and be sure it does not include values like no: No&quot;</span>
368
+ <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">key</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">true</span>
369
+ <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Key #{key} was evaluated as true. Check your yml file and be sure it does not include values like yes: Yes&quot;</span>
370
+ <span class="ruby-keyword kw">elsif</span> <span class="ruby-operator">!</span><span class="ruby-identifier">translate_hash</span>[<span class="ruby-identifier">key</span>].<span class="ruby-identifier">nil?</span>
371
+ <span class="ruby-identifier">replacements</span> = <span class="ruby-identifier">parse_substitutions</span>(<span class="ruby-identifier">translate_hash</span>[<span class="ruby-identifier">key</span>])
372
+ <span class="ruby-identifier">translations</span> = <span class="ruby-constant">Babelphish</span><span class="ruby-operator">::</span><span class="ruby-constant">Translator</span>.<span class="ruby-identifier">multiple_translate</span>(<span class="ruby-identifier">translate_hash</span>[<span class="ruby-identifier">key</span>], <span class="ruby-identifier">tos</span>, <span class="ruby-identifier">from</span>)
373
+ <span class="ruby-identifier">translations</span>.<span class="ruby-identifier">each_key</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">locale</span><span class="ruby-operator">|</span>
374
+ <span class="ruby-identifier">replacements</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">r</span><span class="ruby-operator">|</span>
375
+ <span class="ruby-identifier">translations</span>[<span class="ruby-identifier">locale</span>].<span class="ruby-identifier">sub!</span>(<span class="ruby-constant">SUBSTITUTION_PLACE_HOLDER</span>, <span class="ruby-identifier">r</span>)
376
+ <span class="ruby-keyword kw">end</span>
377
+ <span class="ruby-keyword kw">end</span>
378
+ <span class="ruby-identifier">translate_hash</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">translations</span>
379
+ <span class="ruby-keyword kw">else</span>
380
+ <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Key #{key} contains no data&quot;</span>
381
+ <span class="ruby-keyword kw">end</span>
382
+ <span class="ruby-keyword kw">end</span>
383
+ <span class="ruby-keyword kw">end</span>
384
+ <span class="ruby-keyword kw">end</span>
385
+ </pre>
386
+ </div>
387
+ </div>
388
+ </div>
389
+
390
+
391
+ </div>
392
+
393
+
394
+ </div>
395
+
396
+
397
+ <div id="validator-badges">
398
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
399
+ </div>
400
+
401
+ </body>
402
+ </html>
data/doc/created.rid ADDED
@@ -0,0 +1 @@
1
+ Sat, 15 Aug 2009 12:03:01 -0600
@@ -0,0 +1,110 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>File: History.txt</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="fileHeader">
50
+ <h1>History.txt</h1>
51
+ <table class="header-table">
52
+ <tr class="top-aligned-row">
53
+ <td><strong>Path:</strong></td>
54
+ <td>History.txt
55
+ </td>
56
+ </tr>
57
+ <tr class="top-aligned-row">
58
+ <td><strong>Last Update:</strong></td>
59
+ <td>Tue May 19 13:50:17 -0600 2009</td>
60
+ </tr>
61
+ </table>
62
+ </div>
63
+ <!-- banner header -->
64
+
65
+ <div id="bodyContent">
66
+
67
+
68
+
69
+ <div id="contextContent">
70
+
71
+ <div id="description">
72
+ <h2>0.1.1 2009-05-18</h2>
73
+ <ul>
74
+ <li>Initial release
75
+
76
+ </li>
77
+ </ul>
78
+
79
+ </div>
80
+
81
+
82
+ </div>
83
+
84
+
85
+ </div>
86
+
87
+
88
+ <!-- if includes -->
89
+
90
+ <div id="section">
91
+
92
+
93
+
94
+
95
+
96
+
97
+
98
+
99
+ <!-- if method_list -->
100
+
101
+
102
+ </div>
103
+
104
+
105
+ <div id="validator-badges">
106
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
107
+ </div>
108
+
109
+ </body>
110
+ </html>