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

gmquiroga picture gmquiroga  路  3Comments

webprofusion-chrisc picture webprofusion-chrisc  路  4Comments

pndewit picture pndewit  路  3Comments

dankerk picture dankerk  路  3Comments

jellene4eva picture jellene4eva  路  3Comments