Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i18n doesn't work in filter inputs placeholders #596

Open
jualoppaz opened this issue Mar 15, 2018 · 0 comments
Open

i18n doesn't work in filter inputs placeholders #596

jualoppaz opened this issue Mar 15, 2018 · 0 comments

Comments

@jualoppaz
Copy link

jualoppaz commented Mar 15, 2018

Hi!

I'm introducing i18n in my ng-table with ngx-translate library.

When I change language by this:

this.translate.use(lang)

all texts are translated but filter inputs placeholders.

By the moment, the only way that allows me implement this feature is handling the language change and setting manually the texts:


// Previous code
let column1 = {
    name: 'first_name',
    sort: false,
    filtering: {
        filterString: '',
        placeholder: ''
    }
};

let column2 = {
    name: 'last_name',
    sort: false,
    filtering: {
        filterString: '',
        placeholder: ''
    }
};

let column3 = {
    name: 'email',
    sort: false,
    filtering: {
        filterString: '',
        placeholder: ''
    }
};

... // More code

// Important code
this.translate.onLangChange.subscribe((event: LangChangeEvent) => {
    Observable.forkJoin(
          this.translate.get('List.Filter.First Name'),
          this.translate.get('List.Filter.Last Name'),
          this.translate.get('List.Filter.Email'),
    ).subscribe(result => {
          column1['filtering']['placeholder'] = result[0];
          column2['filtering']['placeholder'] = result[1];
          column3['filtering']['placeholder'] = result[2];

          this.columns = [column1, column2, column3];

          this.config = {
              paging: true,
              sorting: { columns: this.columns },
              filtering: { filterString: '' },
              className: ['table-striped', 'table-bordered']
        };
    });
});

Is there any way for translate filter inputs placeholders without handling language change event?

Thank you so much.

@jualoppaz jualoppaz changed the title i18n in all components i18n doesn't work in filter inputs placeholder Mar 15, 2018
@jualoppaz jualoppaz changed the title i18n doesn't work in filter inputs placeholder i18n doesn't work in filter inputs placeholders Mar 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant