<?php

namespace app\controller;

use app\model\Order;
use app\model\Withdrawl as WithdrawlModel;
use app\model\Address as AddressModel;
use support\exception\BusinessException;
use support\Request;
use support\Response;
use Throwable;
use Web3\Contracts\Types\Address as TypesAddress;
use Workerman\Worker;

class UtilsController extends Crud
{

    public function i18n(Request $request): Response
    {
        
        $locale = $_GET['locale'];
        $key = $_GET['key'];
        $langArr=[
            'zh_CN',
            'zh_TW',
            'fi_FI',
            'ja_JP',
            'ko_KR',
            'en_US',
        ];
        foreach($langArr as $lang){
            $fn = "public/h5/i18n/".$lang.'.json';
            $json = json_decode(file_get_contents($fn), true);
            echo $locale,$key;
            if(!isset($json[$key])){
                $json[$key] = $key;
                file_put_contents($fn, json_encode($json, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
            }
        }
        return $this->success(__('successful'));
    }
}