Core: Support pipes inside translation strings

Created on 13 Mar 2017  路  2Comments  路  Source: ngx-translate/core

I'm submitting a ... (check one with "x")

[x] feature request

Current behavior
I'm migrating an application from AngularJS and angular-translate and I was able to use pipes inside translation strings, like:

    {
        "TEST_1": "Viewing {{ num | number:2 }} items",
        "TEST_2": "hide {{ type | translate }}",
    }

Expected/desired behavior
Be able to use pipes inside translation strings.

Reproduction of the problem
Currently you get the same translation text without parameters interpretation:

    it('should be able to get translations with nested params with pipes', () => {
        translations = {"TEST": "This is a test {{value | number}}"};
        translate.use('en');

        translate.get('TEST', {value: 12}).subscribe((res: string) => {
            expect(res).toEqual('This is a test 12');
        });
    });

Karma shows: Expected 'This is a test {{value | number}}' to equal 'This is a test 12'.

All 2 comments

I'm sorry but this is not possible in Angular because we don't have access to the compiler like we did in AngularJS...

So? what can we do?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jellene4eva picture jellene4eva  路  3Comments

rbaumi picture rbaumi  路  4Comments

louisdoe picture louisdoe  路  3Comments

chris31389 picture chris31389  路  3Comments

apreg picture apreg  路  3Comments