Thread: [Openupload-svn-update] SF.net SVN: openupload:[86] trunk/lib/modules/tr
Status: Beta
Brought to you by:
tsdogs
|
From: <ts...@us...> - 2008-10-27 12:21:53
|
Revision: 86
http://openupload.svn.sourceforge.net/openupload/?rev=86&view=rev
Author: tsdogs
Date: 2008-10-27 11:42:03 +0000 (Mon, 27 Oct 2008)
Log Message:
-----------
Add the loading of default template translation in case the site template one does not exsist
Modified Paths:
--------------
trunk/lib/modules/tr/array.inc.php
trunk/lib/modules/tr/gettext.inc.php
Modified: trunk/lib/modules/tr/array.inc.php
===================================================================
--- trunk/lib/modules/tr/array.inc.php 2008-10-27 11:36:38 UTC (rev 85)
+++ trunk/lib/modules/tr/array.inc.php 2008-10-27 11:42:03 UTC (rev 86)
@@ -24,6 +24,13 @@
if (file_exists($this->files['template'])) {
require_once($this->files['template']);
$this->TR['template']=$tr;
+ } else { /* load default translation */
+ $this->files['template']=app()->config['INSTALL_ROOT'].'/templates/'.
+ 'default/locale/'.$lang['id'].'.inc.php';
+ if (file_exists($this->files['template'])) {
+ require_once($this->files['template']);
+ $this->TR['template']=$tr;
+ }
}
/* setup page encoding */
if (isset($lang['charset']))
Modified: trunk/lib/modules/tr/gettext.inc.php
===================================================================
--- trunk/lib/modules/tr/gettext.inc.php 2008-10-27 11:36:38 UTC (rev 85)
+++ trunk/lib/modules/tr/gettext.inc.php 2008-10-27 11:42:03 UTC (rev 86)
@@ -12,7 +12,11 @@
$lang = app()->langs[$locale];
putenv("LANG=".$lang['locale']);
bindtextdomain('openupload',app()->config['INSTALL_ROOT'].'/locale');
- bindtextdomain('template',app()->config['INSTALL_ROOT'].'/templates/'.app()->config['site']['template'].'/locale');
+ if (is_dir(app()->config['INSTALL_ROOT'].'/templates/'.app()->config['site']['template'].'/locale')) {
+ bindtextdomain('template',app()->config['INSTALL_ROOT'].'/templates/'.app()->config['site']['template'].'/locale');
+ } else {
+ bindtextdomain('template',app()->config['INSTALL_ROOT'].'/templates/default/locale');
+ }
setlocale(LC_ALL,$lang['locale']);
/* setup page encoding */
if (isset($lang['charset']))
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ts...@us...> - 2008-10-28 17:36:30
|
Revision: 87
http://openupload.svn.sourceforge.net/openupload/?rev=87&view=rev
Author: tsdogs
Date: 2008-10-28 17:36:20 +0000 (Tue, 28 Oct 2008)
Log Message:
-----------
Rename php translator
Added Paths:
-----------
trunk/lib/modules/tr/phparray.inc.php
Removed Paths:
-------------
trunk/lib/modules/tr/array.inc.php
Deleted: trunk/lib/modules/tr/array.inc.php
===================================================================
--- trunk/lib/modules/tr/array.inc.php 2008-10-27 11:42:03 UTC (rev 86)
+++ trunk/lib/modules/tr/array.inc.php 2008-10-28 17:36:20 UTC (rev 87)
@@ -1,64 +0,0 @@
-<?php
-
-/* simple array translation */
-
-class ArrayTranslator extends translatorBase {
-var $update = false;
-var $TR;
-
- function ArrayTranslator() {
- }
-
- function init() {
- $locale = app()->user->info('lang');
- $lang = app()->langs[$locale];
- $tr = array();
- $this->files['openupload']=app()->config['INSTALL_ROOT'].'/locale/'.$lang['id'].'.inc.php';
- if (file_exists($this->files['openupload'])) {
- require_once($this->files['openupload']);
- $this->TR['openupload']=$tr;
- }
- $tr = array();
- $this->files['template']=app()->config['INSTALL_ROOT'].'/templates/'.app()->config['site']['template'].
- '/locale/'.$lang['id'].'.inc.php';
- if (file_exists($this->files['template'])) {
- require_once($this->files['template']);
- $this->TR['template']=$tr;
- } else { /* load default translation */
- $this->files['template']=app()->config['INSTALL_ROOT'].'/templates/'.
- 'default/locale/'.$lang['id'].'.inc.php';
- if (file_exists($this->files['template'])) {
- require_once($this->files['template']);
- $this->TR['template']=$tr;
- }
- }
- /* setup page encoding */
- if (isset($lang['charset']))
- header('Content-Type: text/html; charset='.$lang['charset']);
- }
-
-
- function translate($txt,$domain = 'openupload') {
-
- if (isset($this->TR[$domain][$txt])) {
- return $this->TR[$domain][$txt];
- } else {
- if ($this->update) {
- /* add the translation to the file */
- $f = @fopen($this->files[$domain],'w+');
- if ($f) {
- fwrite($f,'<?php'."\n");
- foreach ($this->TR[$domain] as $k => $v) {
- fwrite($f,'$tr[\''.str_replace("'","\'",$k).'\']=\''.str_replace("'","\'",$v).'\';'."\n");
- }
- fwrite($f,'$tr[\''.str_replace("'","\'",$txt).'\']=\''.str_replace("'","\'",$txt).'\';'."\n");
- fwrite($f,'?>');
- fclose($f);
- $this->TR[$domain][$txt]=$txt;
- }
- }
- return $txt;
- }
- }
-}
-?>
\ No newline at end of file
Added: trunk/lib/modules/tr/phparray.inc.php
===================================================================
--- trunk/lib/modules/tr/phparray.inc.php (rev 0)
+++ trunk/lib/modules/tr/phparray.inc.php 2008-10-28 17:36:20 UTC (rev 87)
@@ -0,0 +1,64 @@
+<?php
+
+/* simple array translation */
+
+class PhpArrayTranslator extends translatorBase {
+var $update = false;
+var $TR;
+
+ function PhpArrayTranslator() {
+ }
+
+ function init() {
+ $locale = app()->user->info('lang');
+ $lang = app()->langs[$locale];
+ $tr = array();
+ $this->files['openupload']=app()->config['INSTALL_ROOT'].'/locale/'.$lang['id'].'.inc.php';
+ if (file_exists($this->files['openupload'])) {
+ require_once($this->files['openupload']);
+ $this->TR['openupload']=$tr;
+ }
+ $tr = array();
+ $this->files['template']=app()->config['INSTALL_ROOT'].'/templates/'.app()->config['site']['template'].
+ '/locale/'.$lang['id'].'.inc.php';
+ if (file_exists($this->files['template'])) {
+ require_once($this->files['template']);
+ $this->TR['template']=$tr;
+ } else { /* load default translation */
+ $this->files['template']=app()->config['INSTALL_ROOT'].'/templates/'.
+ 'default/locale/'.$lang['id'].'.inc.php';
+ if (file_exists($this->files['template'])) {
+ require_once($this->files['template']);
+ $this->TR['template']=$tr;
+ }
+ }
+ /* setup page encoding */
+ if (isset($lang['charset']))
+ header('Content-Type: text/html; charset='.$lang['charset']);
+ }
+
+
+ function translate($txt,$domain = 'openupload') {
+
+ if (isset($this->TR[$domain][$txt])) {
+ return $this->TR[$domain][$txt];
+ } else {
+ if ($this->update) {
+ /* add the translation to the file */
+ $f = @fopen($this->files[$domain],'w+');
+ if ($f) {
+ fwrite($f,'<?php'."\n");
+ foreach ($this->TR[$domain] as $k => $v) {
+ fwrite($f,'$tr[\''.str_replace("'","\'",$k).'\']=\''.str_replace("'","\'",$v).'\';'."\n");
+ }
+ fwrite($f,'$tr[\''.str_replace("'","\'",$txt).'\']=\''.str_replace("'","\'",$txt).'\';'."\n");
+ fwrite($f,'?>');
+ fclose($f);
+ $this->TR[$domain][$txt]=$txt;
+ }
+ }
+ return $txt;
+ }
+ }
+}
+?>
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ts...@us...> - 2009-02-03 18:44:58
|
Revision: 222
http://openupload.svn.sourceforge.net/openupload/?rev=222&view=rev
Author: tsdogs
Date: 2009-02-03 18:44:53 +0000 (Tue, 03 Feb 2009)
Log Message:
-----------
add default utf-8 charset
Modified Paths:
--------------
trunk/lib/modules/tr/gettext.inc.php
trunk/lib/modules/tr/null.inc.php
trunk/lib/modules/tr/phparray.inc.php
Modified: trunk/lib/modules/tr/gettext.inc.php
===================================================================
--- trunk/lib/modules/tr/gettext.inc.php 2009-01-19 11:55:42 UTC (rev 221)
+++ trunk/lib/modules/tr/gettext.inc.php 2009-02-03 18:44:53 UTC (rev 222)
@@ -20,9 +20,12 @@
$r = setlocale(LC_ALL,$lang['locale']);
if ($r != $lang['locale'])
app()->message('WARNING: locale '.$lang['locale'].' not supported by your system.');
- /* setup page encoding */
- if (isset($lang['charset']))
- header('Content-Type: text/html; charset='.$lang['charset']);
+ /* setup page encoding */
+ if (!isset($lang['charset']) or $lang['charset']=='') {
+ $lang['charset']='utf8';
+ }
+ header('Content-Type: text/html; charset='.$lang['charset']);
+ app()->tpl->assign('charset',$lang['charset']);
}
Modified: trunk/lib/modules/tr/null.inc.php
===================================================================
--- trunk/lib/modules/tr/null.inc.php 2009-01-19 11:55:42 UTC (rev 221)
+++ trunk/lib/modules/tr/null.inc.php 2009-02-03 18:44:53 UTC (rev 222)
@@ -7,6 +7,12 @@
function NullTranslator() {
}
+ function init() {
+ /* setup page encoding */
+ header('Content-Type: text/html; charset=utf8');
+ app()->tpl->assign('charset','utf8');
+
+ }
function translate($txt,$domain = 'openupload') {
return $txt;
}
Modified: trunk/lib/modules/tr/phparray.inc.php
===================================================================
--- trunk/lib/modules/tr/phparray.inc.php 2009-01-19 11:55:42 UTC (rev 221)
+++ trunk/lib/modules/tr/phparray.inc.php 2009-02-03 18:44:53 UTC (rev 222)
@@ -32,9 +32,12 @@
$this->TR['template']=$tr;
}
}
- /* setup page encoding */
- if (isset($lang['charset']))
- header('Content-Type: text/html; charset='.$lang['charset']);
+ /* setup page encoding */
+ if (!isset($lang['charset']) or $lang['charset']=='') {
+ $lang['charset']='utf8';
+ }
+ header('Content-Type: text/html; charset='.$lang['charset']);
+ app()->tpl->assign('charset',$lang['charset']);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|