public static function getTranslations(string $locale)
    {
        if (stripos($locale, '_') !== false) {
            $locale = str_ireplace("_", "-", $locale);
        }
        
        $locale = strtolower($locale);
        $localePart = explode('-', $locale)[0];
        
        $languageFilesToCheck = array(
            "root",
            $localePart,
            $locale
        );
        
        // try to see if we already preloaded the locale
        $data = new \stdClass();
        $preloaded = false;
        foreach ($languageFilesToCheck as $languageFileToCheck) {
            if (ArrayUtils::doesArrayHaveValueForKey(self::$runtimeTranslations, $languageFileToCheck, true)) {
                $preloaded = true;
                
                $partial = ArrayUtils::getArrayValueForKeyOrDefault(self::$runtimeTranslations, $locale, null, true);
                ObjectUtils::merge($data, $partial);
            }
        }
        
        if ($preloaded) {
            return $data;
        }
        
        // core locale
        foreach ($languageFilesToCheck as $languageFileToCheck) {
            if (file_exists(DIR_LOCALE . $languageFileToCheck . EXT_JSON)) {
                $partial = json_decode(file_get_contents(DIR_LOCALE . $languageFileToCheck . EXT_JSON));
                ObjectUtils::merge($data, $partial);
            }
        }
        
        // project locale
        foreach ($languageFilesToCheck as $languageFileToCheck) {
            if (file_exists(DIR_LOCALE_PROJECT . $languageFileToCheck . EXT_JSON)) {
                $partial = json_decode(file_get_contents(DIR_LOCALE_PROJECT . $languageFileToCheck . EXT_JSON));
                ObjectUtils::merge($data, $partial);
            }
        }
        
        self::$runtimeTranslations[$locale] = $data;
        return $data;
    }
public static function getTranslations(string $locale)
    {
        if (stripos($locale, '_') !== false) {
            $locale = str_ireplace("_", "-", $locale);
        }
        
        $locale = strtolower($locale);
        $localePart = explode('-', $locale)[0];
        
        $languageFilesToCheck = array(
            "root",
            $localePart,
            $locale
        );
        
        // try to see if we already preloaded the locale
        $data = new \stdClass();
        $preloaded = false;
        foreach ($languageFilesToCheck as $languageFileToCheck) {
            if (ArrayUtils::doesArrayHaveValueForKey(self::$runtimeTranslations, $languageFileToCheck, true)) {
                $preloaded = true;
                
                $partial = ArrayUtils::getArrayValueForKeyOrDefault(self::$runtimeTranslations, $locale, null, true);
                ObjectUtils::merge($data, $partial);
            }
        }
        
        if ($preloaded) {
            return $data;
        }
        
        // core locale
        foreach ($languageFilesToCheck as $languageFileToCheck) {
            if (file_exists(DIR_LOCALE . $languageFileToCheck . EXT_JSON)) {
                $partial = json_decode(file_get_contents(DIR_LOCALE . $languageFileToCheck . EXT_JSON));
                ObjectUtils::merge($data, $partial);
            }
        }
        
        // project locale
        foreach ($languageFilesToCheck as $languageFileToCheck) {
            if (file_exists(DIR_LOCALE_PROJECT . $languageFileToCheck . EXT_JSON)) {
                $partial = json_decode(file_get_contents(DIR_LOCALE_PROJECT . $languageFileToCheck . EXT_JSON));
                ObjectUtils::merge($data, $partial);
            }
        }
        
        self::$runtimeTranslations[$locale] = $data;
        return $data;
    }
public static function getTranslations ( string $ locale ) { if ( stripos ( $ locale , '_' ) !== false ) { $ locale = str_ireplace ( "_" , "-" , $ locale ) ; } $ locale = strtolower ( $ locale ) ; $ localePart = explode ( '-' , $ locale ) [ 0 ] ; $ languageFilesToCheck = array ( "root" , $ localePart , $ locale ) ; // try to see if we already preloaded the locale $ data = new \ stdClass ( ) ; $ preloaded = false ; foreach ( $ languageFilesToCheck as $ languageFileToCheck ) { if ( ArrayUtils :: doesArrayHaveValueForKey ( self :: $ runtimeTranslations , $ languageFileToCheck , true ) ) { $ preloaded = true ; $ partial = ArrayUtils :: getArrayValueForKeyOrDefault ( self :: $ runtimeTranslations , $ locale , null , true ) ; ObjectUtils :: merge ( $ data , $ partial ) ; } } if ( $ preloaded ) { return $ data ; } // core locale foreach ( $ languageFilesToCheck as $ languageFileToCheck ) { if ( file_exists ( DIR_LOCALE . $ languageFileToCheck . EXT_JSON ) ) { $ partial = json_decode ( file_get_contents ( DIR_LOCALE . $ languageFileToCheck . EXT_JSON ) ) ; ObjectUtils :: merge ( $ data , $ partial ) ; } } // project locale foreach ( $ languageFilesToCheck as $ languageFileToCheck ) { if ( file_exists ( DIR_LOCALE_PROJECT . $ languageFileToCheck . EXT_JSON ) ) { $ partial = json_decode ( file_get_contents ( DIR_LOCALE_PROJECT . $ languageFileToCheck . EXT_JSON ) ) ; ObjectUtils :: merge ( $ data , $ partial ) ; } } self :: $ runtimeTranslations [ $ locale ] = $ data ; return $ data ; }
Get all available translations for the given locale.

A language file should be a JSON file named after the locale which it concerns,
based on a combination of ISO-639 language code and ISO-3166 country code.
E.g. en_us.json, en.json, nl-nl.json etcetera.

@param string $locale
The string containing the wanted locale according to format in RFC 2616.

@return \stdClass All available translations for the given locale.
Get all available translations for the given locale .