本文整理匯總了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);
}