inc/MultiLang
class-merchant-no-plugin-support.php
2.4 KB
1 month ago
class-merchant-polylang-support.php
5.5 KB
1 month ago
class-merchant-translator.php
6.7 KB
1 month ago
class-merchant-wpml-support.php
6.7 KB
1 month ago
interface-language-strategy.php
3.0 KB
1 month ago
class-merchant-no-plugin-support.php in Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant 2.3.1, at inc/MultiLang/class-merchant-no-plugin-support.php
| 1 | <?php |
| 2 | |
| 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | exit; // Exit if accessed directly |
| 5 | } |
| 6 | |
| 7 | /** |
| 8 | * Merchant - No Plugin Support |
| 9 | * |
| 10 | * This class is not meant to be used directly. It will be used by the Merchant_Translator class. |
| 11 | */ |
| 12 | if ( ! class_exists( 'Merchant_No_Plugin_Support' ) ) { |
| 13 | class Merchant_No_Plugin_Support implements Merchant_Language_Strategy { |
| 14 | |
| 15 | /** |
| 16 | * Register a string for translation. |
| 17 | * |
| 18 | * @param string $string_to_register The string to translate. |
| 19 | * @param string $context The context of the string. |
| 20 | * @param bool $multiline Whether the string is multiline or not. |
| 21 | */ |
| 22 | public function register_string( $string_to_register, $context, $multiline = false ): void { |
| 23 | // Do nothing. |
| 24 | } |
| 25 | |
| 26 | /** |
| 27 | * Translate a string. |
| 28 | * |
| 29 | * @param string $string_to_translate The string to translate. |
| 30 | * |
| 31 | * @return string |
| 32 | */ |
| 33 | public function translate_string( $string_to_translate ) { |
| 34 | return $string_to_translate; |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Get WordPress language code |
| 39 | * |
| 40 | * @return string |
| 41 | */ |
| 42 | public function get_current_lang() { |
| 43 | return get_locale(); |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Translate a taxonomy term — passthrough (no multilingual plugin active). |
| 48 | * |
| 49 | * @param string|int $term The term slug or term ID. |
| 50 | * @param string $taxonomy The taxonomy name. |
| 51 | * @param string|null $language Target language code (ignored). |
| 52 | * |
| 53 | * @return string|int Same value as input. |
| 54 | * |
| 55 | * @since 2.1.9 |
| 56 | */ |
| 57 | public function translate_term( $term, $taxonomy, $language = null ) { |
| 58 | return $term; |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * Switch the active language context — no-op without a plugin. |
| 63 | * |
| 64 | * @param string $language Language code (ignored). |
| 65 | * |
| 66 | * @return void |
| 67 | * |
| 68 | * @since 2.1.9 |
| 69 | */ |
| 70 | public function switch_language( $language ) { |
| 71 | // No-op: no multilingual plugin active. |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * Restore the language context — no-op without a plugin. |
| 76 | * |
| 77 | * @return void |
| 78 | * |
| 79 | * @since 2.1.9 |
| 80 | */ |
| 81 | public function restore_language() { |
| 82 | // No-op: no multilingual plugin active. |
| 83 | } |
| 84 | |
| 85 | /** |
| 86 | * Get the default language code — not applicable without a plugin. |
| 87 | * |
| 88 | * @return string Empty string. |
| 89 | * |
| 90 | * @since 2.1.9 |
| 91 | */ |
| 92 | public function get_default_language() { |
| 93 | return ''; |
| 94 | } |
| 95 | |
| 96 | /** |
| 97 | * {@inheritDoc} |
| 98 | */ |
| 99 | public function get_all_languages_code() { |
| 100 | return ''; |
| 101 | } |
| 102 | |
| 103 | /** |
| 104 | * {@inheritDoc} |
| 105 | */ |
| 106 | public function get_post_language( $post_id ) { |
| 107 | return ''; |
| 108 | } |
| 109 | } |
| 110 | } |