Airplane_Mode_Core::get_offline_languages PHP Method

get_offline_languages() private method

Returns list of languages installed locally with full mimicked meta data.
private get_offline_languages ( array $installed_languages ) : array
$installed_languages array List of locally available languages.
return array List of available languages in offline mode.
        private function get_offline_languages($installed_languages)
        {
            // This is list of languages which are available from translations API.
            $offline_languages = $this->get_offline_translation_information();
            // Call the global WP version.
            global $wp_version;
            // Tell WordPress that all translations are recent even though they can be old.
            $date = date_i18n('Y-m-d H:is', time());
            // Set an empty array of the available languages.
            $available_languages = array();
            // Loop through our installed languages.
            foreach ($installed_languages as $lang) {
                // Try to mimick the data that WordPress puts into 'available_translations' transient.
                $settings = array('language' => $lang, 'iso' => array($lang), 'version' => $wp_version, 'updated' => $date, 'strings' => array('continue' => __('Continue')), 'package' => "https://downloads.wordpress.org/translation/core/{$wp_version}/{$lang}.zip");
                // Combine the mimicked data with data we have stored in $offline_languages to give realistic output.
                $available_languages[$lang] = array_merge($settings, $offline_languages[$lang]);
            }
            // And return our language sets.
            return $available_languages;
        }