Localize string in custom field

I need to localize a message in a custom field. site/languages doesn’t seem to be loaded by the Panel. I also tried without success to use the i18n method on the field class.

    $message = $this->i18n([
      'en' => "welcome",
      'pt' => "bem-vindo",

What’s the best way to go about it?

Your code looks good. What happens if you use it? Do you get an error message?

It loaded the default language. Now that you said it looks fine I tried adding the country code pt_BR and it worked.

    $message = $this->i18n([
      'en'    => "welcome",
      'pt_BR' => "bem-vindo",

Thanks Lukas!

1 Like