| 1 |
<?php |
| 2 |
|
| 3 |
namespace BitCode\BitForm\Core\Util\Translation\Contract; |
| 4 |
|
| 5 |
/** |
| 6 |
* Adapter contract for one multilingual plugin — lookup only. TranslationManager |
| 7 |
* wires the provider to the public filters; a provider hooks nothing on its own. |
| 8 |
* |
| 9 |
* Plugins with a string store additionally implement |
| 10 |
* StringRegistrationProviderInterface; the ones that translate rendered HTML |
| 11 |
* do not, and are not forced into empty method bodies. |
| 12 |
* |
| 13 |
* No strict scalar type hints on hook-reachable methods (translate, |
| 14 |
* getCurrentLanguage) — WP filters can pass null. |
| 15 |
*/ |
| 16 |
interface TranslationProviderInterface |
| 17 |
{ |
| 18 |
/** |
| 19 |
* Cheap probe: defined()/function_exists()/class_exists() only, no DB access. |
| 20 |
* |
| 21 |
* @return bool |
| 22 |
*/ |
| 23 |
public static function isAvailable(); |
| 24 |
|
| 25 |
/** |
| 26 |
* Resolved language for the current request, memoized; '' when unknown. |
| 27 |
* |
| 28 |
* @return string |
| 29 |
*/ |
| 30 |
public function getCurrentLanguage(); |
| 31 |
|
| 32 |
/** |
| 33 |
* `bitform_translate_form_string` delegate. |
| 34 |
* |
| 35 |
* @param mixed $string |
| 36 |
* @param mixed $context stable context key (e.g. "fld-abc-lbl", "msg-content-3") |
| 37 |
* @param mixed $formId |
| 38 |
* |
| 39 |
* @return mixed translated string, or the input unchanged |
| 40 |
*/ |
| 41 |
public function translate($string, $context = '', $formId = 0); |
| 42 |
|
| 43 |
/** |
| 44 |
* True when the plugin translates the rendered HTML itself; the manager then |
| 45 |
* skips the string filter on frontend renders to avoid double translation. |
| 46 |
* |
| 47 |
* @return bool |
| 48 |
*/ |
| 49 |
public function translatesRenderedHtml(); |
| 50 |
|
| 51 |
/** |
| 52 |
* AJAX context: adopt the submitter's page language. |
| 53 |
* |
| 54 |
* @param string $requestLang sanitized bf_lang from the payload, '' if none |
| 55 |
*/ |
| 56 |
public function onAjaxInit($requestLang); |
| 57 |
} |
| 58 |
|