How to get the translation of a picklist value? #53
-
Hello there, I want to get the translated string of a picklist value. I have a picklist named Status, and I have two values in it: PLL_CREATED, PLL_COMPLETE In "Language Management", I've added PLL_CREATED -> Created, and PLL_COMPLETE -> Completed In my custom workflow, how can I get translated string of PLL_CREATED or PLL_COMPLETE? To get the picklist value, I use I tried using FYI, I use two languages in my CRM, and I want the translated string to be the same language as the user who uses the custom workflow. Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Please also note: The module is a custom module, and I found out that the translation file doesn't exist in /languages, but in /custom/languages. |
Beta Was this translation helpful? Give feedback.
-
it's quite simple: /**
* Functions that gets translated string.
*
* @param string $key - string which need to be translated
* @param string $moduleName - module scope in which the translation need to be check
* @param string|null $language - language of translation
* @param bool $encode - When no translation was found do encode the output
* @param string $secondModuleName - Additional module name to be translated when not in $moduleName
*
* @return string - translated string
*/
public static function translate(string $key, string $moduleName = '_Base', ?string $language = null, bool $encode = true, ?string $secondModuleName = null) |
Beta Was this translation helpful? Give feedback.
it's quite simple:
\App\Language::translate($recordModel->get('status_picklist'), $recordModel->getModuleName(), $langFromUser);