| 1 |
<?php |
| 2 |
|
| 3 |
if ( ! defined( 'ABSPATH' ) ) { |
| 4 |
exit; // Exit if accessed directly |
| 5 |
} |
| 6 |
|
| 7 |
/** |
| 8 |
* Merchant - Polylang 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_PolyLang_Support' ) ) { |
| 13 |
class Merchant_PolyLang_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 ) { |
| 23 |
pll_register_string( $context, $string_to_register, 'Merchant', $multiline ); |
| 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 pll__( $string_to_translate ); |
| 35 |
} |
| 36 |
|
| 37 |
/** |
| 38 |
* Get Current language code |
| 39 |
* |
| 40 |
* @return string |
| 41 |
*/ |
| 42 |
public function get_current_lang() { |
| 43 |
return pll_current_language(); |
| 44 |
} |
| 45 |
} |
| 46 |
} |