setting the langauge for translation inside a formula?
Collapse
X
-
if any one is in a hurry here is what i did to get this working
and then add it in here custom/Espo/Custom/Resources/metadata/app/formula.json and clear cacheCode:<?php namespace Espo\Custom\FormulaFunctions; use Espo\Core\Formula\ArgumentList; use Espo\Core\Formula\Functions\BaseFunction; use Espo\Core\Formula\Processor; use Espo\Core\Utils\Language\LanguageFactory; class translateTo extends BaseFunction { public function __construct( Processor $processor, private LanguageFactory $languageFactory, ) { $this->processor = $processor; } public function process(ArgumentList $args) { if (count($args) < 1) { $this->throwTooFewArguments(2); } $args = $this->evaluate($args); $language = $this->languageFactory->create($args[1]); return $language->translate($args[0], 'snipits', 'snipits'); } }👍 1Comment

Comment