addresses #17
* integrate Marko Samastur's translate.js with gettext and php * translate the first JavaScript strings * add scripts/i18n.php to generate the list of i18n dictionary
This commit is contained in:
parent
3b234e141d
commit
4a15c5b5b6
15 changed files with 409 additions and 12 deletions
52
admin/scripts/i18n.php
Normal file
52
admin/scripts/i18n.php
Normal file
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
/**
|
||||
* JavaScript internationalization code for DAVAdmin.
|
||||
*
|
||||
* @author Jan Dittberner <jan@dittberner.info>
|
||||
* @version $Id$
|
||||
* @license GPL
|
||||
* @package DAVAdmin
|
||||
*
|
||||
* Copyright (c) 2007 Jan Dittberner
|
||||
*
|
||||
* This file is part of DAVAdmin.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/** Include the internationalization code. */
|
||||
require_once(".." . DIRECTORY_SEPARATOR . "i18n.inc.php");
|
||||
textdomain("davadminjs");
|
||||
|
||||
$translatable = file(realpath(implode(DIRECTORY_SEPARATOR,
|
||||
array(dirname(__FILE__), "..", "..",
|
||||
"po", "transjs.txt"))));
|
||||
header("Content-Type: application/x-javascript;charset=UTF-8");
|
||||
if (is_array($translatable)) {
|
||||
print "i18nDict = ";
|
||||
$transmap = array();
|
||||
foreach ($translatable as $sentence) {
|
||||
$sentence = stripcslashes(stripcslashes(trim($sentence)));
|
||||
$transmap[$sentence] = _($sentence);
|
||||
}
|
||||
print json_encode($transmap);
|
||||
print ";";
|
||||
} else {
|
||||
print "i18nDict = {};";
|
||||
}
|
||||
|
||||
print("\n\nvar intl = new i18n(i18nDict);");
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue