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.6 4.7.7 4.7.8 4.7.9 4.8.0 4.9.0 4.9.1 5.0.1 5.0.2 5.1.1 5.1.2 5.1.3 5.2.0 5.2.1 5.3.2 5.3.3.1 5.3.4 5.3.5 5.3.6 5.3.7
woocommerce-multilingual / inc / class-wcml-locale.php
woocommerce-multilingual / inc Last commit date
admin-menus 1 month ago currencies 1 month ago template-classes 1 month ago translation-editor 1 month ago class-wcml-ajax-setup.php 1 month ago class-wcml-attributes.php 1 month ago class-wcml-capabilities.php 1 month ago class-wcml-cart-removed-items-widget.php 1 year ago class-wcml-cart-switch-lang-functions.php 1 month ago class-wcml-cart-sync-warnings.php 1 month ago class-wcml-cart.php 1 month ago class-wcml-comments.php 1 month ago class-wcml-compatibility.php 1 month ago class-wcml-coupons.php 1 month ago class-wcml-dependencies.php 1 month ago class-wcml-emails.php 1 month ago class-wcml-endpoints.php 1 month ago class-wcml-install.php 1 month ago class-wcml-languages-upgrader.php 1 month ago class-wcml-locale.php 1 month ago class-wcml-orders.php 1 month ago class-wcml-products-screen-options.php 1 month ago class-wcml-products.php 1 month ago class-wcml-reports.php 1 month ago class-wcml-requests.php 1 month ago class-wcml-resources.php 1 month ago class-wcml-store-pages.php 1 month ago class-wcml-terms.php 1 month ago class-wcml-tp-support.php 1 month ago class-wcml-troubleshooting.php 1 month ago class-wcml-upgrade.php 1 month ago class-wcml-url-translation.php 1 month ago class-wcml-wc-gateways.php 1 month ago class-wcml-wc-shipping.php 1 month ago class-wcml-wc-strings.php 1 month ago class-wcml-widgets.php 1 month ago constants.php 1 month ago functions-pure.php 1 month ago functions.php 1 month ago installer-loader.php 1 month ago missing-php-functions.php 1 month ago wcml-core-functions.php 1 month ago wcml-switch-lang-request.php 1 month ago
class-wcml-locale.php
81 lines
1 <?php
2
3 class WCML_Locale {
4 private $sitepress;
5
6 public function __construct( $sitepress ) {
7 $this->sitepress = $sitepress;
8
9 add_filter( 'locale', [ $this, 'update_product_action_locale_check' ] );
10 }
11
12 public static function load_locale() {
13 add_filter( 'lang_dir_for_domain', [ __CLASS__, 'force_path_for_embedded_translation_files' ], 10, 3 );
14 return load_plugin_textdomain( 'woocommerce-multilingual', false, WCML_PLUGIN_FOLDER . '/locale' );
15 }
16
17 public static function force_path_for_embedded_translation_files( $path, $domain, $locale ) {
18 if ( 'woocommerce-multilingual' !== $domain ) {
19 return $path;
20 }
21
22 $isEmbeddedTranslationFile = function( $locale ) {
23 return in_array(
24 $locale,
25 [
26 'de_DE',
27 'el',
28 'es_ES',
29 'fr_FR',
30 'he_IL',
31 'it_IT',
32 'ja',
33 'nl_NL',
34 'pl_PL',
35 'pt_BR',
36 'sv_SE',
37 'zn_CN',
38 ],
39 true
40 );
41 };
42
43 if ( $isEmbeddedTranslationFile( $locale ) ) {
44 return trailingslashit( WCML_LOCALE_PATH );
45 }
46
47 return $path;
48 }
49
50 public function switch_locale( $lang_code = false ) {
51 global $l10n, $st_gettext_hooks;
52 static $original_l10n;
53
54 if ( ! empty( $lang_code ) ) {
55 if ( null !== $st_gettext_hooks ) {
56 $st_gettext_hooks->switch_language_hook( $lang_code );
57 }
58
59 $original_l10n = $l10n['woocommerce-multilingual'] ?? null;
60 if ( null !== $original_l10n ) {
61 unset( $l10n['woocommerce-multilingual'] );
62 }
63
64 return load_textdomain(
65 'woocommerce-multilingual',
66 WCML_LOCALE_PATH . '/woocommerce-multilingual-' . $this->sitepress->get_locale( $lang_code ) . '.mo'
67 );
68
69 } else {
70 $l10n['woocommerce-multilingual'] = $original_l10n;
71 }
72 }
73
74 public function update_product_action_locale_check( $locale ) {
75 if ( isset( $_POST['action'] ) && 'wpml_translation_dialog_save_job' === $_POST['action'] ) {
76 return $this->sitepress->get_locale( $_POST['job_details']['target'] );
77 }
78 return $locale;
79 }
80 }
81