svn: /web/doc-editor/trunk/php/ GTranslate.php

[email protected] (Yannick Torres)
Newsgroups php.doc.web
Message-ID <[email protected]>
yannick                                  Sat, 13 Mar 2010 09:43:52 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=296140

Log:
Fix bug #51287

Bug: http://bugs.php.net/51287 (Open) Problem with the pt_BR auto translation
      
Changed paths:
    U   web/doc-editor/trunk/php/GTranslate.php

Modified: web/doc-editor/trunk/php/GTranslate.php
===================================================================
--- web/doc-editor/trunk/php/GTranslate.php	2010-03-13 04:15:22 UTC (rev 296139)
+++ web/doc-editor/trunk/php/GTranslate.php	2010-03-13 09:43:52 UTC (rev 296140)
@@ -278,12 +278,19 @@

         public function translate($langFrom, $langTo, $string)
         {
+            // Wrapper to $langTo for google API
+            $notFound["pt_BR"] = "pt"; // Bug #51287 by moacir
+
+            if( $notFound[$langTo] ) {
+                      $langTo = $notFound[$langTo];
+            }
+
             $languages = Array($langFrom, $langTo);

             // If the passed string is to large, we try to truncate it and make multi-query
             if( strlen($string) > 5000 ) {

-                $strings = explode('§',wordwrap($string, 4000, '§'));
+                $strings = explode('§',wordwrap($string, 4000, '§'));

                 for( $i=0; $i < count($strings); $i++ ) {
                     $this->returnTranslation .= $this->query($languages,$strings[$i]);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.