babelphish 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -46,12 +46,18 @@ module Babelphish
46
46
 
47
47
  text = IO.read(source_page)
48
48
 
49
- # Pull out all the code blocks to Google doesn't mess with those
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
@@ -35,7 +35,7 @@ require File.dirname(__FILE__) + '/../lib/babelphish/html_translator'
35
35
  $KCODE = 'UTF8'
36
36
 
37
37
  module Babelphish
38
- VERSION = '0.2.2'
38
+ VERSION = '0.2.3'
39
39
  GOOGLE_AJAX_URL = "http://ajax.googleapis.com/ajax/services/language/"
40
40
  MAX_RETRIES = 3
41
41
 
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.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-13 00:00:00 -06:00
12
+ date: 2009-07-22 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency