painful_translate 0.0.3 → 0.0.4
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.
- checksums.yaml +4 -4
- data/README.md +10 -0
- data/lib/painful_translate/translation_page.rb +1 -1
- data/lib/painful_translate/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 307185bf883610a70014e7e98485ed16734011fe
|
4
|
+
data.tar.gz: 7d968b974be68291a53805860a237f1ebe6836b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb718f6c3b2d6d82f6d7a563e9500632596985b7bcca0b1381510ebe72683c2205b4bba1e8eedb7dd3d316a18b3b784fa88ea567a62761dcc2516507f9274028
|
7
|
+
data.tar.gz: 4892b4abf5c0344a83b854f8755d72bf75b47e40e4729bbd6d56e1438ecddac4a5c54046a61b74a6e7ab6374a0637fde3dcbc1eb7389b1c871ce13d28ec8b877
|
data/README.md
CHANGED
@@ -47,6 +47,16 @@ Sorry, not built yet
|
|
47
47
|
|
48
48
|
---
|
49
49
|
|
50
|
+
## Important Caveat
|
51
|
+
|
52
|
+
You can't translate strings with "\n" (newline) characters in it. This is because this translator uses newlines spread out batch translations to Google. So if you decide to try something like the following:
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
# Will behave unpredictably
|
56
|
+
PainfulTranslate.translate("Dear abbey,\n I am a big idiot", "please respond" :to => :es, :from => :en)
|
57
|
+
```
|
58
|
+
Every translations after the one where you introduced offending line will be off by the one came before it... and, because I haven't gotten around to writing code that will throw an error, you may need to prepare your anus for some serious post-production pain when your entire site is out of context
|
59
|
+
|
50
60
|
## A note on capybara and selenium and how this thing works
|
51
61
|
|
52
62
|
This gem will open up selenium via capybara which, for most of you, will mean it actually opens up firefox and visits https://translate.google.com . It then fills out the translation form, and fetches the translated answer from the webpage. In other words, this is exactly what you (as a lowly human) would do if you had to translate something with Google. Consequently, this process is slow and painful.
|
@@ -5,6 +5,6 @@ class PainfulTranslate::TranslationPage
|
|
5
5
|
end
|
6
6
|
def translation_output_strings
|
7
7
|
sleep 2.seconds # give some time for Jewgle to look the page
|
8
|
-
session.find(:xpath, '//*[@id="result_box"]').
|
8
|
+
session.find(:xpath, '//*[@id="result_box"]').native.text.split "\n"
|
9
9
|
end
|
10
10
|
end
|