davadmin/admin/scripts/i18n.php
Jan Dittberner 0993d2be3a fixes #20
* message catalogs for PHP and JavaScript have been joined to davadmin.pot
 * textdomain selection has been unified in admin/i18n.inc.php
2007-12-03 14:37:35 +00:00

51 lines
1.7 KiB
PHP

<?php
/**
* JavaScript internationalization code for DAVAdmin.
*
* @author Jan Dittberner <jan@dittberner.info>
* @version $Id$
* @license GPL
* @package DAVAdmin::JavaScript
*
* 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");
$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);");
?>