Permalink
Browse files

add String#translate info to readme

  • Loading branch information...
1 parent c730a5c commit 649e65bc6fc8edb41fdded1d71cfb71375683853 Jimmy Cuadra committed Dec 27, 2010
Showing with 12 additions and 1 deletion.
  1. +12 −1 README.textile
View
@@ -8,7 +8,11 @@ Simply run @gem install to_lang@.
h2. Usage
-To use *to_lang*, require the library, then call @ToLang.start@ with your Google Translate API key. At this point you will have access to all the new translation methods, which take the form @to_language@, where "language" is the language you wish to translate to. Google Translate attempts to detect the source language, but you can specify it explicitly by calling methods in the form @to_language_from_source_language@, where "source_language" is the source language. These methods are generated dynamically and will not appear in a call to @String.new.methods@ until they have been called once. Strings will, however, @respond_to?@ these methods prior to their dynamic definition.
+To use *to_lang*, require the library, then call @ToLang.start@ with your Google Translate API key. At this point you will have access to all the new translation methods, which take the form @to_language@, where "language" is the language you wish to translate to.
+
+Google Translate attempts to detect the source language, but you can specify it explicitly by calling methods in the form @to_language_from_source_language@, where "source_language" is the source language. These methods are generated dynamically and will not appear in a call to @String.new.methods@ until they have been called once. Strings will, however, @respond_to?@ these methods prior to their dynamic definition.
+
+The dynamic methods are simply syntactic sugar for @String#translate@, which you can use directly as well.
h2. Examples
@@ -29,6 +33,13 @@ bq. "a pie".to_spanish
"a pie".to_spanish_from_english
=> "un pastel"
+Using @String#translate@ directly:
+
+bq. "hello world".translate('es')
+=> "hola mundo"
+"a pie".translate('es', :from => 'en')
+=> "un pastel"
+
h2. Supported Languages
*to_lang* adds the following methods to strings. Each of these methods can be called with an explicit source language by appending @_to_source_language@ to the method name.

0 comments on commit 649e65b

Please sign in to comment.