Skip to main content
Added casting bit.
Source Link
mpdonadio
  • 38.1k
  • 8
  • 89
  • 142

You can get the string value by calling the magic function ->__tostring() or casting the object to a (string). But most time you don't need to do this, because if you use the translation object in a string context it will return the translated string automatically.

You can't change the original string in the translation object. You have to generate a new one with the t-function:

$button['#value'] = $this->t('new text');

You can get the string value by calling the magic function ->__tostring(). But most time you don't need to do this, because if you use the translation object in a string context it will return the translated string automatically.

You can't change the original string in the translation object. You have to generate a new one with the t-function:

$button['#value'] = $this->t('new text');

You can get the string value by calling the magic function ->__tostring() or casting the object to a (string). But most time you don't need to do this, because if you use the translation object in a string context it will return the translated string automatically.

You can't change the original string in the translation object. You have to generate a new one with the t-function:

$button['#value'] = $this->t('new text');
Source Link
4uk4
  • 101.7k
  • 7
  • 173
  • 217

You can get the string value by calling the magic function ->__tostring(). But most time you don't need to do this, because if you use the translation object in a string context it will return the translated string automatically.

You can't change the original string in the translation object. You have to generate a new one with the t-function:

$button['#value'] = $this->t('new text');