ruby - How to preserve newlines with "to_lang" Google Translate -


i use to_lang translate text in rails 3 application. noticed converts newlines spaces. appropriate approach preserve newlines in original text? don't want split original text "\n", translate parts, , combine them again, since increase number of requests. ideas?

i've tested :debug => :request:

{:key=>"--", :q=>"to prevent abuse, google places limits on api requests.\nusing valid oauth 2.0 token or api key allows exceed \nanonymous limits connecting requests project.", :target=>"ru"}

and can see it's not gem fault. so, to_lang can translate arrays too. , if you'll write ["one", "two", "three"].to_russian 1 request google api.

update:

irb(main):001:0> str = "test1\ntest2\ntest3" => "test1\ntest2\ntest3" irb(main):002:0> arr = str.split("\n") => ["test1", "test2", "test3"] irb(main):003:0> str = arr.join("\n") => "test1\ntest2\ntest3" 

Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -