setting the langauge for translation inside a formula?

Collapse
X
 
  • Time
  • Show
Clear All
new posts

  • jamie
    replied
    if any one is in a hurry here is what i did to get this working

    Code:
    <?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');
    }
    }
    and then add it in here custom/Espo/Custom/Resources/metadata/app/formula.json and clear cache

    Leave a comment:


  • jamie
    replied
    Originally posted by yuri
    Not possible, will be implemented in v9.4 I think.

    Meanwhile, I suggest creating a custom function.
    ahh good stuff thats not tooo far away, btw i wasn't too sure what scope meant in there, it was linked to an entity?

    Leave a comment:


  • yuri
    replied
    Not possible, will be implemented in v9.4 I think.

    Meanwhile, I suggest creating a custom function.

    Leave a comment:


  • setting the langauge for translation inside a formula?

    when runing a formula i need to translate some strings based on a language variable but it doesn't tell me how to in the documentation


    if there any way to set this?
Working...