Detailed Description
Translates values using a single locale's translation map.
Handles a plain string, a list of strings, and a weighted list of strings (an array of ['value' => string, 'weighting' => number] entries). For a weighted list each entry's weighting is preserved unchanged and only its value is translated.
Public Member Functions | |
| __construct (array $translations=[], string $behavior=MissingTranslationBehavior::ORIGINAL) | |
| translate ($value, array &$errors) | |
| Translate a value. | |
Constructor & Destructor Documentation
◆ __construct()
| fiftyone\pipeline\translation\Translator::__construct | ( | array | $translations = [], |
| string | $behavior = MissingTranslationBehavior::ORIGINAL ) |
- Parameters
-
array<string,string> $translations source value to translation
Member Function Documentation
◆ translate()
| fiftyone\pipeline\translation\Translator::translate | ( | $value, | |
| array & | $errors ) |
Translate a value.
The value may be a string, a list of strings, or a weighted list of ['value' => ..., 'weighting' => ...] entries.
- Parameters
-
mixed $value array<
Exception> $errors collects errors when behavior is FlowError
- Returns
- mixed translated value of the same shape, or null on FlowError
