How to use the @aurelia/i18n.TranslationBinding function in @aurelia/i18n

To help you get started, we’ve selected a few @aurelia/i18n examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aurelia / aurelia / packages / __tests__ / i18n / t / translation-parameters-render.spec.ts View on Github external
it('#render add the paramExpr to the existing TranslationBinding for the target element', function () {
    const container = setup();
    const sut: IInstructionRenderer = new TranslationParametersBindingRenderer(container.get(IExpressionParser), container.get(IObserverLocator));
    const expressionParser = container.get(IExpressionParser);
    const targetElement = DOM.createElement('span');
    const binding = new TranslationBinding(targetElement, container.get(IObserverLocator), container);
    const renderable = ({ bindings: [binding] } as unknown as IController);
    const paramExpr = expressionParser.parse('{foo: "bar"}', BindingType.BindCommand);
    const callBindingInstruction: ICallBindingInstruction = { from: paramExpr } as unknown as ICallBindingInstruction;

    sut.render(
      LifecycleFlags.none,
      DOM,
      container,
      renderable,
      targetElement,
      callBindingInstruction
    );

    assert.equal(binding.parametersExpr, paramExpr);
  });
});
github aurelia / aurelia / packages / __tests__ / i18n / t / translation-render.spec.ts View on Github external
it('#render adds expr to the existing TranslationBinding for the target element', function () {
    const container = setup();
    const sut: IInstructionRenderer = new TranslationBindBindingRenderer(container.get(IExpressionParser), {} as unknown as IObserverLocator);
    const expressionParser = container.get(IExpressionParser);
    const targetElement = DOM.createElement('span');
    const binding = new TranslationBinding(targetElement, {} as unknown as IObserverLocator, container);
    const renderable = ({ bindings: [binding] } as unknown as IController);

    const from = expressionParser.parse('simple.key', BindingType.BindCommand);
    const callBindingInstruction: ICallBindingInstruction = { from, to: '.bind' } as unknown as ICallBindingInstruction;
    sut.render(
      LifecycleFlags.none,
      DOM,
      container as unknown as IRenderContext,
      renderable,
      targetElement,
      callBindingInstruction);

    assert.equal(binding.expr, from);
  });
});