svn: /web/doc-editor/trunk/php/ File.php
| From: | Yannick Torres | Date: | Sun, 02 Jan 2011 22:23:33 +0000 |
| Subject: | svn: /web/doc-editor/trunk/php/ File.php | ||
| Groups: | php.doc.web | ||
| Request: | Send a blank email to doc-web+get-1938@lists.php.net to get a copy of this message | ||
yannick Sun, 02 Jan 2011 22:23:33 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=307003
Log:
FallBack to EN patch for google translation when the original file did'nt exist. This case
append, for example when we start a translation then open it from work in progress module. In this
case, only the .new exist in {lang}.
Changed paths:
U web/doc-editor/trunk/php/File.php
Modified: web/doc-editor/trunk/php/File.php
===================================================================
--- web/doc-editor/trunk/php/File.php 2011-01-02 21:56:55 UTC (rev 307002)
+++ web/doc-editor/trunk/php/File.php 2011-01-02 22:23:33 UTC (rev 307003)
@@ -93,7 +93,10 @@
*/
public function translate()
{
- $originalContent = file_get_contents($this->full_path);
+ // We must check if the file exist.
+ // For example, when we start a translation, save it, and then open it from work in
progress module, the path (without .new) don't exist and we must use the fallback path for
translation
+
+ $originalContent = ( is_file($this->full_path) ) ?
file_get_contents($this->full_path) : file_get_contents($this->full_path_fallback);
// We search for new line caracters and mark it ! (Google API delete new line)
$originalContent = str_replace("\n", "[@]", $originalContent);
@@ -101,7 +104,6 @@
$lang = AccountManager::getInstance()->vcsLang;
$translation = false;
-
$gt = new Gtranslate;
$gt->setRequestType('curl');
$translation = $gt->translate('en', $lang, $originalContent);