Skip to content
Snippets Groups Projects
Commit d4e15160 authored by Tim van Dijen's avatar Tim van Dijen
Browse files

Fix Locale; If a Twig-variable is not set and then translated, these methods...

Fix Locale; If a Twig-variable is not set and then translated, these methods are called with a null parameter
parent cc64093d
No related branches found
No related tags found
No related merge requests found
......@@ -399,12 +399,15 @@ class Translate
/**
* Translate a singular text.
*
* @param string $original The string before translation.
* @param string|null $original The string before translation.
*
* @return string The translated string.
*/
public static function translateSingularGettext(string $original): string
public static function translateSingularGettext(?string $original): string
{
// This may happen if you forget to set a variable and then run undefinedVar through the trans-filter
$original = $original ?? 'undefined variable';
$text = BaseTranslator::$current->gettext($original);
if (func_num_args() === 1 || $original === null) {
......@@ -420,14 +423,17 @@ class Translate
/**
* Translate a plural text.
*
* @param string $original The string before translation.
* @param string|null $original The string before translation.
* @param string $plural
* @param string $value
*
* @return string The translated string.
*/
public static function translatePluralGettext(string $original, string $plural, string $value): string
public static function translatePluralGettext(?string $original, string $plural, string $value): string
{
// This may happen if you forget to set a variable and then run undefinedVar through the trans-filter
$original = $original ?? 'undefined variable';
$text = BaseTranslator::$current->ngettext($original, $plural, $value);
if (func_num_args() === 3) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment