本文整理汇总了PHP中HTML2PDF_locale::_directory方法的典型用法代码示例。如果您正苦于以下问题:PHP HTML2PDF_locale::_directory方法的具体用法?PHP HTML2PDF_locale::_directory怎么用?PHP HTML2PDF_locale::_directory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTML2PDF_locale
的用法示例。
在下文中一共展示了HTML2PDF_locale::_directory方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
/**
* load the locale
*
* @access public
* @param string $code
*/
public static function load($code)
{
if (self::$_directory === null) {
self::$_directory = dirname(dirname(__FILE__)) . '/locale/';
}
// must be in lower case
$code = strtolower($code);
// must be [a-z-0-9]
if (!preg_match('/^([a-z0-9]+)$/isU', $code)) {
throw new HTML2PDF_exception(0, 'invalid language code [' . self::$_code . ']');
}
// save the code
self::$_code = $code;
// get the name of the locale file
$file = self::$_directory . self::$_code . '.csv';
// the file must exist
if (!is_file($file)) {
throw new HTML2PDF_exception(0, 'language code [' . self::$_code . '] unknown. You can create the translation file [' . $file . '] and send it to the webmaster of html2pdf in order to integrate it into a future release');
}
// load the file
self::$_list = array();
$handle = fopen($file, 'r');
while (!feof($handle)) {
$line = fgetcsv($handle);
if (count($line) != 2) {
continue;
}
self::$_list[trim($line[0])] = trim($line[1]);
}
fclose($handle);
}