Automattic\WooCommerce\Internal\Admin
Translations::generate_translation_strings
Combine translation chunks when plugin is activated.
This function combines JSON translation data auto-extracted by GlotPress from Webpack-generated JS chunks into a single file. This is necessary since the JS chunks are not known to WordPress via wp_register_script() and wp_set_script_translations().
Method of the class: Translations{}
No Hooks.
Returns
null. Nothing (null).
Usage
// private - for code of main (parent) class only $result = $this->generate_translation_strings();
Translations::generate_translation_strings() Translations::generate translation strings code WC 10.5.0
private function generate_translation_strings() {
$locale = determine_locale();
$lang_dir = WP_LANG_DIR . '/plugins/';
// Bail early if not localized.
if ( 'en_US' === $locale ) {
return;
}
if ( ! function_exists( 'get_filesystem_method' ) ) {
require_once ABSPATH . 'wp-admin/includes/file.php';
}
$access_type = get_filesystem_method();
if ( 'direct' === $access_type ) {
\WP_Filesystem();
$this->build_and_save_translations( $lang_dir, self::$plugin_domain, $locale );
} else {
// I'm reluctant to add support for other filesystems here as it would require
// user's input on activating plugin - which I don't think is common.
return;
}
}