diff options
| author | Eltrac Koalar <hi@guhub.cn> | 2020-10-07 20:40:09 +0800 |
|---|---|---|
| committer | Eltrac Koalar <hi@guhub.cn> | 2020-10-07 20:40:09 +0800 |
| commit | e6f3df7eaf6881a303358289dadb904824872d45 (patch) | |
| tree | 57a98fea6448ee3b306af9f0127cd764697100a3 /libs/Language.php | |
| parent | 49506af621b073a3acd1cd53d54771d0695108ee (diff) | |
bring back the 1.x files to master
Diffstat (limited to 'libs/Language.php')
| -rw-r--r-- | libs/Language.php | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/libs/Language.php b/libs/Language.php new file mode 100644 index 0000000..d24ae77 --- /dev/null +++ b/libs/Language.php @@ -0,0 +1,41 @@ +<?php +if (!defined('__TYPECHO_ROOT_DIR__')) exit; + +/** + * Language.php + * 多语言 / 多語言 / Multi-Languages + * + * Author: Eltrac(BigCoke233) + * License: MIT + */ + +class Lang +{ + public static function getLang() { + $provided_lang = glob(Helper::options()->themeFile("lang/*.php")); + if(in_array($GLOBALS['miraclesLang'].'.php', $provided_lang)){ + require_once("lang/"+$GLOBALS['miraclesLang'].".php"); + $GLOBALS['miraclesLangError']=false; + }else{ + require_once("lang/zh-cn.php"); + $GLOBALS['miraclesLangError']=true; + } + } +} + +//快速获取对应语言文本 +function gt($a, $b) { + return $GLOBALS[$a][$b]; +} +function gtecho($a, $b) { + echo $GLOBALS[$a][$b]; +} +//有参数的文本获取 +function gta($a, $b, $c) { + $content = str_replace('%s', $c, $GLOBALS[$a][$b]); + return $content; +} +function gtaecho($a, $b, $c) { + $content = str_replace('%s', $c, $GLOBALS[$a][$b]); + echo $content; +}
\ No newline at end of file |
