public static function setlocale($category, $locale)
    {
        $return = false;

        static $categories = array(
            'LC_COLLATE' => LC_COLLATE,
            'LC_CTYPE' => LC_CTYPE,
            'LC_MONETARY' => LC_MONETARY,
            'LC_NUMERIC' => LC_NUMERIC,
            'LC_TIME' => LC_TIME,
            'LC_MESSAGES' => LC_MESSAGES
        );

        $parts = explode(';', $locale);
        if ($category === LC_ALL && count($parts) > 1) {
            // Handle case when LC_ALL is undefined and we're passing a giant
            // string with all the separate lc-type values.
            foreach ($parts as $part) {
                $part_exp = explode('=', $part, 2);
                if (
                    count($part_exp) === 2 &&
                    array_key_exists($part_exp[0], $categories)
                ) {
                    $return = setlocale(
                        $categories[$part_exp[0]],
                        $part_exp[1]
                    );
                }
            }
        } else {
            $return = setlocale($category, $locale);
        }

        return $return;
    }