Automattic\WooCommerce\Internal\Admin
Translations::build_and_save_translations()
Combine and save translations for a specific locale.
Note that this assumes \WP_Filesystem is already initialized with write access.
Method of the class: Translations{}
No Hooks.
Return
null
. Nothing (null).
Usage
// private - for code of main (parent) class only $result = $this->build_and_save_translations( $language_dir, $plugin_domain, $locale );
- $language_dir(string) (required)
- Path to language files.
- $plugin_domain(string) (required)
- Text domain.
- $locale(string) (required)
- Locale being retrieved.
Translations::build_and_save_translations() Translations::build and save translations code WC 9.6.1
private function build_and_save_translations( $language_dir, $plugin_domain, $locale ) { global $wp_filesystem; $translations_from_chunks = $this->get_translation_chunk_data( $language_dir, $plugin_domain, $locale ); if ( empty( $translations_from_chunks ) ) { return; } $cache_filename = $this->get_combined_translation_filename( $plugin_domain, $locale ); $chunk_translations_json = wp_json_encode( $translations_from_chunks ); // Cache combined translations strings to a file. $wp_filesystem->put_contents( $language_dir . $cache_filename, $chunk_translations_json ); }