public function editLocaleActivity(string $appname):Renderer
    {
        $allowed = ["json", "poedit"];
        $plocale = trim($this->get("request")->get("plocale"));
        $status = $this->get("request")->get("status");
        $trans_type = trim($this->get("request")->get("trans_type"));
        $values = $this->get("request")->get("locales");

        if ("" !== $trans_type && !in_array($trans_type, $allowed)) {
            return ((new Renderer())->jsonRenderer(array("code" => 500, "msg" =>
                "Undefined translation type [$trans_type]. Set allowed translation type"))
            );
        }

        if ("" == $trans_type) {
            $trans_type = null;
        }

        if ("" == $plocale) {
            $plocale = null;
        }

        if (null !== $plocale && is_array($values) && !in_array($plocale, array_keys($values))) {
            return ((new Renderer())->jsonRenderer(array("code" => 500, "msg" =>
                "Cannot set the default locale [$plocale] : Locale must be exist in locale keys"))
            );
        }

        if (!in_array($status, [true, false])) {
            return ((new Renderer())->jsonRenderer(array("code" => 500, "msg" =>
                "Unknow status $status. Please set true or false status"))
            );
        }

        if ("" == $values) {
            $values = [];
        }

        $locale = new AppLocale($appname);
        $locale->setEnabled($status);
        $locale->setPrefer($plocale);
        $locale->setAppname($appname);
        $locale->setTranstype($trans_type);
        $locale->setValues([$values]);
        $locale->apply();

        return ((new Renderer())->jsonRenderer(array("code" => 200, "msg" => "OK")));
    }
public function editLocaleActivity(string $appname):Renderer
    {
        $allowed = ["json", "poedit"];
        $plocale = trim($this->get("request")->get("plocale"));
        $status = $this->get("request")->get("status");
        $trans_type = trim($this->get("request")->get("trans_type"));
        $values = $this->get("request")->get("locales");

        if ("" !== $trans_type && !in_array($trans_type, $allowed)) {
            return ((new Renderer())->jsonRenderer(array("code" => 500, "msg" =>
                "Undefined translation type [$trans_type]. Set allowed translation type"))
            );
        }

        if ("" == $trans_type) {
            $trans_type = null;
        }

        if ("" == $plocale) {
            $plocale = null;
        }

        if (null !== $plocale && is_array($values) && !in_array($plocale, array_keys($values))) {
            return ((new Renderer())->jsonRenderer(array("code" => 500, "msg" =>
                "Cannot set the default locale [$plocale] : Locale must be exist in locale keys"))
            );
        }

        if (!in_array($status, [true, false])) {
            return ((new Renderer())->jsonRenderer(array("code" => 500, "msg" =>
                "Unknow status $status. Please set true or false status"))
            );
        }

        if ("" == $values) {
            $values = [];
        }

        $locale = new AppLocale($appname);
        $locale->setEnabled($status);
        $locale->setPrefer($plocale);
        $locale->setAppname($appname);
        $locale->setTranstype($trans_type);
        $locale->setValues([$values]);
        $locale->apply();

        return ((new Renderer())->jsonRenderer(array("code" => 200, "msg" => "OK")));
    }
public function editLocaleActivity ( string $ appname ) : Renderer { $ allowed = [ "json" , "poedit" ] ; $ plocale = trim ( $ this -> get ( "request" ) -> get ( "plocale" ) ) ; $ status = $ this -> get ( "request" ) -> get ( "status" ) ; $ trans_type = trim ( $ this -> get ( "request" ) -> get ( "trans_type" ) ) ; $ values = $ this -> get ( "request" ) -> get ( "locales" ) ; if ( "" !== $ trans_type && ! in_array ( $ trans_type , $ allowed ) ) { return ( ( new Renderer ( ) ) -> jsonRenderer ( array ( "code" => 500 , "msg" => "Undefined translation type [$trans_type]. Set allowed translation type" ) ) ) ; } if ( "" == $ trans_type ) { $ trans_type = null ; } if ( "" == $ plocale ) { $ plocale = null ; } if ( null !== $ plocale && is_array ( $ values ) && ! in_array ( $ plocale , array_keys ( $ values ) ) ) { return ( ( new Renderer ( ) ) -> jsonRenderer ( array ( "code" => 500 , "msg" => "Cannot set the default locale [$plocale] : Locale must be exist in locale keys" ) ) ) ; } if ( ! in_array ( $ status , [ true , false ] ) ) { return ( ( new Renderer ( ) ) -> jsonRenderer ( array ( "code" => 500 , "msg" => "Unknow status $status. Please set true or false status" ) ) ) ; } if ( "" == $ values ) { $ values = [ ] ; } $ locale = new AppLocale ( $ appname ) ; $ locale -> setEnabled ( $ status ) ; $ locale -> setPrefer ( $ plocale ) ; $ locale -> setAppname ( $ appname ) ; $ locale -> setTranstype ( $ trans_type ) ; $ locale -> setValues ( [ $ values ] ) ; $ locale -> apply ( ) ; return ( ( new Renderer ( ) ) -> jsonRenderer ( array ( "code" => 200 , "msg" => "OK" ) ) ) ; }
edit one locale
@param $appname string App name
@return Renderer JSON render
@throws \Exception
edit one locale