

"this gem is awesome".to_spanish # = "esta joya es impresionante" - vrish88
https://github.com/jimmycuadra/to_lang

======
alvatar
Just in case you didn't know, and you have plans to actually use Google
Translate for translating web pages into Spanish... please don't. I haven't
seen a single sentence with more than 3-4 words translated properly from
English to Spanish. Even the examples shown in the README make no sense in
Spanish.

~~~
Tomek_
Really? From my experience English to Spanish translation works pretty well in
Google Translate. I've been using it a lot when I started to live in Spain and
my Spanish skills were not too great yet: people were actually complementing
me for how good my (written) Spanish is and were in huge shock when they met
me in person and it turned out that I barely can formulate any sentence. True
story.

~~~
paradoja
It depends... most of what's translated is understandable for a native
speaker, but it will be clear that it wasn't written by one. If you need to
communicate with a Spanish speaker, it will work quite well. If you need to
write a brochure or something formal... better get someone to translate for
you.

~~~
Tomek_
Well, that's quite obvious, Google Translate is not perfect, e.g. overuses
"Usted/Ustedes" or often gets lost when there's a lot of pronouns and missed
"yo", "tu", "el", but:

a) with a little big of knowledge about the language and bit of editing you
can overcome most of those stuff

b) even without editing it makes most of the stuff readable/understandable

c) works much better that competitive products (babblefish).

------
callmeed
What's causing this?

    
    
        ruby-1.8.7-p302 > "Where is the bathroom?".to_spanish
        => "\302\277D\303\263nde est\303\241 el ba\303\261o?"

~~~
comron
Listed under "Roadmap" in the readme is the following:

Investigate Unicode support for Ruby 1.8. to_lang has only been tested with
1.9.

Do you have a copy of 1.9 to test with?

~~~
callmeed
Ah, yes. Much better:

    
    
        ruby-1.9.2-p0 > "Where is the bathroom?".to_spanish
        => "¿Dónde está el baño?" 
    

Thanks

------
swah
Translate fail already... user won't understand that 'joya' means a Ruby gem
:)

~~~
burgerbrain
In context, and with the slightest amount of deductive reasoning, I don't see
why they wouldn't.

~~~
swah
Sure, but those can read basic english too.

------
stevenbedrick
Since this gem appears to use Google's public API, one important thing to keep
in mind is that there's probably a hard limit on the amount of text that can
be translated at one go. I've found that throwing more than a thousand or so
characters at GT's API results in their server throwing "URI too long" errors,
since it only works via HTTP GET.

Disclaimer: This might have changed in the five or six months since I last
messed around with Google's API, or, alternatively, this gem could be doing
something clever to try and get around the problem. Either way, I'd suggest
checking it out.

~~~
alex_c
From memory, other limitations include 100,000 characters per day, and limits
on where the API can be used (e.g. can't use it for paid services).

------
mjuhl24
This is cool, but no one should ever use this. I've used the google translator
frequently, and while it's good, it always requires me to use my knowledge of
the language I'm translating to in order to create a more correct and
meaningful translation. If you really want a site or app that is multilingual,
you need a human with good knowledge of the language to do your translations.

------
jbpr
Another similar project: <https://github.com/caius/gtranslate>

------
dholowiski
This is why even us die hard php coders sometimes yearn for RoR. .to_spanish !

~~~
nowarninglabel
<http://code.google.com/p/gtranslate-api-php/>

$gt = new Gtranslate; echo "Translating [Ciao mondo] Italian to English =>
".$gt->it_to_en("Ciao mondo");

~~~
rbanffy
I think your example demonstrates very well why one would yearn for Ruby. The
ability to give an extra method to a base class allows you to build very
expressive code.

edit: and, BTW, the to_spanish method is not defined in the
[https://github.com/jimmycuadra/to_lang/blob/master/lib/to_la...](https://github.com/jimmycuadra/to_lang/blob/master/lib/to_lang/string_methods.rb)
module.

~~~
arethuza
Even boring old C# can do that.

~~~
ryanpetrich
Not true. That's just a compiler trick

------
djhworld
how does the gem failover if the machine it is being used on isn't connected
to the internet?

~~~
getsat
You would get a SocketError exception from _getaddrinfo_ because HTTParty
(which uses Net::HTTP) can't lookup the hostname. If the hostname is already
resolved, you'd get a Errno::EHOSTUNREACH exception from _connect_ because
there is no route to Google's servers.

~~~
Uchikoma
Leaky abstraction

[http://www.joelonsoftware.com/articles/LeakyAbstractions.htm...](http://www.joelonsoftware.com/articles/LeakyAbstractions.html)

~~~
getsat
Hey, I didn't say it was awesome, I was just reporting what actually happens.
:)

