Pimcore\API\Plugin\Broker::getTranslations PHP Method

getTranslations() public method

public getTranslations ( string $language ) : Array
$language string
return Array $translations
    public function getTranslations($language)
    {
        $translations = [];
        foreach ($this->_plugins as $plugin) {
            try {
                $pluginLanguageFile = $plugin->getTranslationFile($language);
                if (!empty($pluginLanguageFile)) {
                    $languageFile = PIMCORE_PLUGINS_PATH . $pluginLanguageFile;
                    if (is_file($languageFile) and strtolower(substr($languageFile, -4, 4)) == ".csv") {
                        $handle = fopen($languageFile, "r");
                        while (($data = fgetcsv($handle, 0, ",")) !== false) {
                            if (!isset($data[1])) {
                                continue;
                            }
                            $pluginTranslations[$data[0]] = $data[1];
                        }
                        fclose($handle);
                        if (is_array($pluginTranslations)) {
                            $translations = array_merge($translations, $pluginTranslations);
                        }
                    }
                }
            } catch (Exception $e) {
                Logger::error("Plugin " . get_class($plugin) . " threw Exception when trying to get translations");
            }
        }
        return $translations;
    }