console/build_lan.php

(开头部分) 4KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

<?php
class build_lan extends Controller
{

    private $source_dir;
    private $target_dir;

    public function run($params = null)
    {
        $support_langs = array_keys($this->config->get('support_langs'));
        if(!$this->config->get('config_trans_api_url')){
            die("请配置翻译接口地址API url,联系QQ:279197963");
        }
        $from = $params['from']??'en';
        $to = $params['to']??'ms';
        if(!in_array($from,$support_langs) || !in_array($to,$support_langs)){
            die('Can not recognition language');
        }
        $lan_name = $params['dir']??'en-gb';
        $source_dir = $params['source_dir']??'';
        $target_dir = $params['target_dir']??'';
        //单独翻译某个目录
        if($source_dir && $target_dir){
            if($source_dir == $target_dir){return;}
            $this->source_dir = $source_dir;
            $this->target_dir = $target_dir;
            if(!file_exists($this->source_dir)){echo 'Can not find dirctory!';return;}
            if(!file_exists($this->target_dir)){mkdir($this->target_dir,'0777') or die('create folder access faile');}
            $this->create_dir($this->source_dir);
            $this->tranlate_dir($this->source_dir,$from,$to);
        }else{
        //整个前后台都翻译
        $dir_arr  = [DIR_APPLICATION.'language/',DIR_APPLICATION.'../admin/language/'];
        foreach ($dir_arr as $dir){
        if($lan_name == $to){continue;}
        $this->source_dir = $dir.$lan_name;
        $this->target_dir = $dir.$to;
        if(!file_exists($this->source_dir)){echo 'Can not find dirctory!';continue;}
        if(!file_exists($this->target_dir)){mkdir($this->target_dir,'0777') or die('create folder access faile');}
        $this->create_dir($this->source_dir);
        $this->tranlate_dir($this->source_dir,$from,$to);
        rename( $this->target_dir.'/'.$lan_name.'.php',$this->target_dir.'/'.$to.'.php') ;
        rename( $this->target_dir.'/'.$lan_name.'.png',$this->target_dir.'/'.$to.'.png') ;
        }
        }
    }

    private function create_dir($source){
        $read_dir = opendir($source);
        //创建好目录
        while($filename = readdir($read_dir))
        {
            if($filename != "." && $filename != "..")
            {
                $file = $source."/".$filename;
                $cur = $this->target_dir. str_replace($this->source_dir,'',$file);
                if(is_dir($file))
                {
                    @mkdir($cur,'0777',true);
                    $this->create_dir($file); //使用递归
后面还有 57 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。