0

I have a webform hook that processes some conditionals depending on a country name dropdown on the webform.

The conditionals need to compare to the English name because there are many various conditions. But the country name from the webform may be translated to a different (non-English) language.

I have the non-English country name in my code and I'd like to translate it to English for my conditionals. Is this possible?

From my webform handler hook:

 $country = $data['country']['country'];

How can I translate the country name above to English in my code?

3
  • Have you tried using t function in php or in twig ? Have a look in drupal.org/docs/8/api/translation-api/overview – GiorgosK Nov 6 '20 at 6:16
  • It's the other way around: Wrap the English country name with t() and then use the language interface to translate it to other languages. English needs to be the source. – leymannx Nov 6 '20 at 7:36
  • Thank you both, t() is what I tried first but could not figure out how to translate force translating from English to another language, or visa-versa. – quantumized Nov 6 '20 at 16:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.