babelphish 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/babelphish/html_translator.rb +14 -1
- data/lib/babelphish.rb +1 -1
- metadata +2 -2
@@ -46,12 +46,18 @@ module Babelphish
|
|
46
46
|
|
47
47
|
text = IO.read(source_page)
|
48
48
|
|
49
|
-
# Pull out all the code blocks
|
49
|
+
# Pull out all the code blocks so Google doesn't mess with those
|
50
50
|
pattern = /\<\%.+\%\>/
|
51
51
|
holder = '{{---}}'
|
52
52
|
replacements = text.scan(pattern)
|
53
53
|
text.gsub!(pattern, holder)
|
54
54
|
|
55
|
+
# Pull out all the new lines so Google doesn't mess with those
|
56
|
+
pattern = /\n/
|
57
|
+
newline_holder = '<brr />'
|
58
|
+
newline_replacements = text.scan(pattern)
|
59
|
+
text.gsub!(pattern, newline_holder)
|
60
|
+
|
55
61
|
# Send to Google for translations
|
56
62
|
translations = Babelphish::Translator.multiple_translate(text, tos, from)
|
57
63
|
|
@@ -62,6 +68,13 @@ module Babelphish
|
|
62
68
|
end
|
63
69
|
end
|
64
70
|
|
71
|
+
# Put the newlines back in
|
72
|
+
translations.each_key do |locale|
|
73
|
+
newline_replacements.each do |r|
|
74
|
+
translations[locale].sub!(newline_holder, r)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
65
78
|
# Write the new file
|
66
79
|
translations.each_key do |locale|
|
67
80
|
translated_filename = get_translated_file(source_page, locale)
|
data/lib/babelphish.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: babelphish
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Ball
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-07-
|
12
|
+
date: 2009-07-22 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|