locale = $locale; $this->translations = $this->get_translations_from_file(); } /** * Retrieve the translations * * @return array */ public function retrieve() { return $this->translations; } /** * Retrieves the translations from the JSON-file. * * @return array Array with the translations. */ protected function get_translations_from_file() { $file = plugin_dir_path( WPSEO_FILE ) . 'languages/yoast-components-' . $this->locale . '.json'; if ( file_exists( $file ) ) { $file = file_get_contents( $file ); if ( is_string( $file ) && $file !== '' ) { return json_decode( $file, true ); } } return array(); } }