Automattic\WooCommerce\Internal\Admin
Translations::load_script_translation_file
Load translation strings from language packs for dynamic imports.
Метод класса: Translations{}
Хуков нет.
Возвращает
string. New file location for the script being translated.
Использование
$Translations = new Translations(); $Translations->load_script_translation_file( $file, $handle, $domain );
- $file(строка) (обязательный)
- File location for the script being translated.
- $handle(строка) (обязательный)
- Script handle.
- $domain(строка) (обязательный)
- Text domain.
Код Translations::load_script_translation_file() Translations::load script translation file WC 11.2.2
public function load_script_translation_file( $file, $handle, $domain ) {
// Make sure the main app script is being loaded.
if ( WC_ADMIN_APP !== $handle ) {
return $file;
}
// Make sure we're handing the correct domain.
if ( self::$plugin_domain !== $domain ) {
return $file;
}
$locale = determine_locale();
$cache_filename = $this->get_combined_translation_filename( $domain, $locale );
$cache_path = WP_LANG_DIR . '/plugins/' . $cache_filename;
// Rebuild the combined file on demand, since it is only generated on language pack updates and plugin activation.
if ( ! is_readable( $cache_path ) && ! $this->regeneration_attempted ) {
$this->regeneration_attempted = true;
$this->generate_translation_strings();
}
// Fall back so the app's own translation file still loads.
if ( ! is_readable( $cache_path ) ) {
return $file;
}
return $cache_path;
}