-
Notifications
You must be signed in to change notification settings - Fork 988
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dev Corrected many translation issues
- Loading branch information
Showing
2 changed files
with
175 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,206 +1,206 @@ | ||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); | ||
/* | ||
* LimeSurvey | ||
* Copyright (C) 2007-2011 The LimeSurvey Project Team / Carsten Schmitz | ||
* All rights reserved. | ||
* License: GNU/GPL License v2 or later, see LICENSE.php | ||
* LimeSurvey is free software. This version may have been modified pursuant | ||
* to the GNU General Public License, and as distributed it includes or | ||
* is derivative of works licensed under the GNU General Public License or | ||
* other free or open source software licenses. | ||
* See COPYRIGHT.php for copyright notices and details. | ||
* | ||
* $Id$ | ||
* | ||
Wrapper to use phpgettext as a class and omit having an english translation | ||
USAGE: | ||
require_once($rootdir.'classes/core/language.php'); | ||
$locale = new limesurvey_lang('en'); // Char code | ||
print $locale->getTranslation("Hello World!"); | ||
*/ | ||
|
||
|
||
class Limesurvey_lang { | ||
|
||
var $gettextclass; | ||
var $langcode; | ||
|
||
function limesurvey_lang($sLanguageCode){ | ||
if(empty($sLanguageCode)) | ||
trigger_error('langcode param is undefined ', E_USER_WARNING); | ||
|
||
Yii::app()->loadHelper('sanitize'); | ||
$sLanguageCode[0]=sanitize_languagecode($sLanguageCode); | ||
$streamer = new FileReader(getcwd().'/locale/'.$sLanguageCode.'/LC_MESSAGES/'.$sLanguageCode.'.mo'); | ||
$this->gettextclass = new gettext_reader($streamer); | ||
$this->langcode = $sLanguageCode; | ||
} | ||
/* | ||
* LimeSurvey | ||
* Copyright (C) 2007-2011 The LimeSurvey Project Team / Carsten Schmitz | ||
* All rights reserved. | ||
* License: GNU/GPL License v2 or later, see LICENSE.php | ||
* LimeSurvey is free software. This version may have been modified pursuant | ||
* to the GNU General Public License, and as distributed it includes or | ||
* is derivative of works licensed under the GNU General Public License or | ||
* other free or open source software licenses. | ||
* See COPYRIGHT.php for copyright notices and details. | ||
* | ||
* $Id$ | ||
* | ||
function getlangcode() | ||
{ | ||
return $this->langcode; | ||
} | ||
function gTview($string, $escapemode = 'html') | ||
{ | ||
global $addTitleToLinks; | ||
if ( $addTitleToLinks === true) | ||
Wrapper to use phpgettext as a class and omit having an english translation | ||
USAGE: | ||
require_once($rootdir.'classes/core/language.php'); | ||
$locale = new limesurvey_lang('en'); // Char code | ||
print $locale->getTranslation("Hello World!"); | ||
*/ | ||
|
||
|
||
class Limesurvey_lang { | ||
|
||
var $gettextclass; | ||
var $langcode; | ||
|
||
function limesurvey_lang($sLanguageCode){ | ||
if(empty($sLanguageCode)) | ||
trigger_error('langcode param is undefined ', E_USER_WARNING); | ||
|
||
Yii::app()->loadHelper('sanitize'); | ||
$sLanguageCode[0]=sanitize_languagecode($sLanguageCode); | ||
$streamer = new FileReader(getcwd().'/locale/'.$sLanguageCode.'/LC_MESSAGES/'.$sLanguageCode.'.mo'); | ||
$this->gettextclass = new gettext_reader($streamer); | ||
$this->langcode = $sLanguageCode; | ||
} | ||
|
||
function getlangcode() | ||
{ | ||
return $this->gT($string, $escapemode = 'html'); | ||
return $this->langcode; | ||
} | ||
else | ||
|
||
function gTview($string, $escapemode = 'html') | ||
{ | ||
return ''; | ||
global $addTitleToLinks; | ||
if ( $addTitleToLinks === true) | ||
{ | ||
return $this->gT($string, $escapemode = 'html'); | ||
} | ||
else | ||
{ | ||
return ''; | ||
} | ||
} | ||
} | ||
|
||
function eTview($string, $escapemode = 'html') | ||
{ | ||
global $addTitleToLinks; | ||
if ( $addTitleToLinks === true) | ||
function eTview($string, $escapemode = 'html') | ||
{ | ||
$this->eT($string, $escapemode = 'html'); | ||
global $addTitleToLinks; | ||
if ( $addTitleToLinks === true) | ||
{ | ||
$this->eT($string, $escapemode = 'html'); | ||
} | ||
} | ||
} | ||
|
||
|
||
|
||
/** | ||
* This function translates plural strings to their according language | ||
* | ||
* @param $single $string The single form of the string to translate | ||
* @param $plural $string The plural form to translate | ||
* @param $number $integer Depending on the number of items the right plural form is taken | ||
* @param mixed $escapemode Different uses require the string to be escaped accordinlgy. Possible values are 'html'(default),'js' and 'unescaped' | ||
* @return string Translated string | ||
*/ | ||
function ngT($single, $plural, $number, $escapemode = 'html') | ||
{ | ||
if ($this->gettextclass) | ||
/** | ||
* This function translates plural strings to their according language | ||
* | ||
* @param $single $string The single form of the string to translate | ||
* @param $plural $string The plural form to translate | ||
* @param $number $integer Depending on the number of items the right plural form is taken | ||
* @param mixed $escapemode Different uses require the string to be escaped accordinlgy. Possible values are 'html'(default),'js' and 'unescaped' | ||
* @return string Translated string | ||
*/ | ||
function ngT($single, $plural, $number, $escapemode = 'html') | ||
{ | ||
$basestring=str_replace('‘','\'',$this->gettextclass->ngettext($single, $plural, $number)); | ||
switch ($escapemode) | ||
if ($this->gettextclass) | ||
{ | ||
case 'html': | ||
return $this->HTMLEscape($basestring); | ||
break; | ||
case 'js': | ||
return $this->javascriptEscape($basestring); | ||
break; | ||
case 'unescaped': | ||
return $basestring; | ||
break; | ||
default: | ||
return "Unsupported EscapeMode in gT method"; | ||
break; | ||
} | ||
} else { | ||
switch ($escapemode) | ||
{ | ||
case 'html': | ||
return $this->HTMLEscape($string); | ||
break; | ||
case 'js': | ||
return $this->javascriptEscape($string); | ||
break; | ||
case 'unescaped': | ||
return $string; | ||
break; | ||
default: | ||
return "Unsupported EscapeMode in gT method"; | ||
break; | ||
$basestring=str_replace('‘','\'',$this->gettextclass->ngettext($single, $plural, $number)); | ||
switch ($escapemode) | ||
{ | ||
case 'html': | ||
return $this->HTMLEscape($basestring); | ||
break; | ||
case 'js': | ||
return $this->javascriptEscape($basestring); | ||
break; | ||
case 'unescaped': | ||
return $basestring; | ||
break; | ||
default: | ||
return "Unsupported EscapeMode in gT method"; | ||
break; | ||
} | ||
} else { | ||
switch ($escapemode) | ||
{ | ||
case 'html': | ||
return $this->HTMLEscape($string); | ||
break; | ||
case 'js': | ||
return $this->javascriptEscape($string); | ||
break; | ||
case 'unescaped': | ||
return $string; | ||
break; | ||
default: | ||
return "Unsupported EscapeMode in gT method"; | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* This function does the same as gT but instead of returning it outputs the string right away | ||
* | ||
* @param string $string The string to translate | ||
* @param mixed $escapemode Different uses require the string to be escaped accordinlgy. Possible values are 'html'(default),'js' and 'unescaped' | ||
*/ | ||
function eT($string, $escapemode = 'html') | ||
{ | ||
echo $this->gT($string,$escapemode); | ||
} | ||
/** | ||
* This function does the same as gT but instead of returning it outputs the string right away | ||
* | ||
* @param string $string The string to translate | ||
* @param mixed $escapemode Different uses require the string to be escaped accordinlgy. Possible values are 'html'(default),'js' and 'unescaped' | ||
*/ | ||
function eT($string, $escapemode = 'html') | ||
{ | ||
echo $this->gT($string,$escapemode); | ||
} | ||
|
||
|
||
|
||
/** | ||
* This function translates strings to their according language | ||
* | ||
* @param string $string The string to translate | ||
* @param mixed $escapemode Different uses require the string to be escaped accordinlgy. Possible values are 'html'(default),'js' and 'unescaped' | ||
* @return string Translated string | ||
*/ | ||
function gT($string, $escapemode = 'html') | ||
{ | ||
if ($this->gettextclass) | ||
/** | ||
* This function translates strings to their according language | ||
* | ||
* @param string $string The string to translate | ||
* @param mixed $escapemode Different uses require the string to be escaped accordinlgy. Possible values are 'html'(default),'js' and 'unescaped' | ||
* @return string Translated string | ||
*/ | ||
function gT($string, $escapemode = 'html') | ||
{ | ||
$basestring=str_replace('‘','\'',$this->gettextclass->translate($string)); | ||
|
||
switch ($escapemode) | ||
if ($this->gettextclass) | ||
{ | ||
case 'html': | ||
return $this->HTMLEscape($basestring); | ||
break; | ||
case 'js': | ||
return $this->javascriptEscape($basestring); | ||
break; | ||
case 'unescaped': | ||
return $basestring; | ||
break; | ||
default: | ||
return "Unsupported EscapeMode in gT method"; | ||
break; | ||
} | ||
} else { | ||
switch ($escapemode) | ||
{ | ||
case 'html': | ||
return $this->HTMLEscape($string); | ||
break; | ||
case 'js': | ||
return $this->javascriptEscape($string); | ||
break; | ||
case 'unescaped': | ||
return $string; | ||
break; | ||
default: | ||
return "Unsupported EscapeMode in gT method"; | ||
break; | ||
$basestring=str_replace('‘','\'',$this->gettextclass->translate($string)); | ||
|
||
switch ($escapemode) | ||
{ | ||
case 'html': | ||
return $this->HTMLEscape($basestring); | ||
break; | ||
case 'js': | ||
return $this->javascriptEscape($basestring); | ||
break; | ||
case 'unescaped': | ||
return $basestring; | ||
break; | ||
default: | ||
return "Unsupported EscapeMode in gT method"; | ||
break; | ||
} | ||
} else { | ||
switch ($escapemode) | ||
{ | ||
case 'html': | ||
return $this->HTMLEscape($string); | ||
break; | ||
case 'js': | ||
return $this->javascriptEscape($string); | ||
break; | ||
case 'unescaped': | ||
return $string; | ||
break; | ||
default: | ||
return "Unsupported EscapeMode in gT method"; | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
|
||
function HTMLEscape($str) { | ||
// escape newline characters, too, in case we put a value from | ||
// a TEXTAREA into an <input type="hidden"> value attribute. | ||
return str_replace(array("\x0A","\x0D"),array(" "," "), | ||
htmlspecialchars( $str, ENT_QUOTES )); | ||
} | ||
function HTMLEscape($str) { | ||
// escape newline characters, too, in case we put a value from | ||
// a TEXTAREA into an <input type="hidden"> value attribute. | ||
return str_replace(array("\x0A","\x0D"),array(" "," "), | ||
htmlspecialchars( $str, ENT_QUOTES )); | ||
} | ||
|
||
// make a string safe to include in a JavaScript String parameter. | ||
function javascriptEscape($str, $strip_tags=false, $htmldecode=false) { | ||
$new_str =''; | ||
// make a string safe to include in a JavaScript String parameter. | ||
function javascriptEscape($str, $strip_tags=false, $htmldecode=false) { | ||
$new_str =''; | ||
|
||
if ($htmldecode==true) { | ||
$str=html_entity_decode($str,ENT_QUOTES,'UTF-8'); | ||
} | ||
if ($strip_tags==true) | ||
{ | ||
$str=strip_tags($str); | ||
if ($htmldecode==true) { | ||
$str=html_entity_decode($str,ENT_QUOTES,'UTF-8'); | ||
} | ||
if ($strip_tags==true) | ||
{ | ||
$str=strip_tags($str); | ||
} | ||
return str_replace(array('\'','"', "\n"), | ||
array("\\'",'\u0022', "\\n"), | ||
$str); | ||
} | ||
return str_replace(array('\'','"', "\n"), | ||
array("\\'",'\u0022', "\\n"), | ||
$str); | ||
} | ||
|
||
} | ||
} | ||
|
||
require_once(APPPATH.'third_party/php-gettext/streams.php'); | ||
require_once(APPPATH.'third_party/php-gettext/gettext.php'); | ||
require_once(APPPATH.'third_party/php-gettext/streams.php'); | ||
require_once(APPPATH.'third_party/php-gettext/gettext.php'); | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters