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

Filter: i18n #1234

Closed
denaldhushi opened this issue Dec 7, 2020 · 4 comments
Closed

Filter: i18n #1234

denaldhushi opened this issue Dec 7, 2020 · 4 comments

Comments

@denaldhushi
Copy link

Hi there,

I need the filter to be in the multiple languages, not only in English, as it is right now.
I tried to add i18n in filter in this way:
file: packages/toast-ui.grid/src/i18n/index.ts

const messages: OptI18nLanguage = {
  en: {
    display: {
      noData: 'No data.',
      loadingData: 'Loading data.',
      resizeHandleGuide:
        'You can change the width of the column by mouse drag, and initialize the width by double-clicking.',
      contain: 'Contains',
      eq: 'Equals',
      ne: 'Not equals',
      start: 'Starts with',
      end: 'Ends with',
      after: 'After',
      afterEq: 'After or Equal',
      before: 'Before',
      beforeEq: 'Before or Equal',
    },
....

file: packages/toast-ui.grid/src/helper/filter.ts

import i18n from '../i18n';
....
export const filterSelectOption: FilterSelectOption = {
  number: {
    eq: '=',
    lt: '<',
    gt: '>',
    lte: '<=',
    gte: '>=',
    ne: '!=',
  },
  text: {
    contain: i18n.get('display.contain'),
    eq: i18n.get('display.eq'),
    ne: i18n.get('display.ne'),
    start: i18n.get('display.start'),
    end: i18n.get('display.end'),
  },
  date: {
    eq: i18n.get('display.eq'),
    ne: i18n.get('display.ne'),
    after: i18n.get('display.after'),
    afterEq: i18n.get('display.afterEq'),
    before: i18n.get('display.before'),
    beforeEq: i18n.get('display.beforeEq'),
  },
};

file: packages/toast-ui.grid/types/options.d.ts

export interface OptI18nData {
  display?: {
    noData?: string;
    loadingData?: string;
    resizeHandleGuide?: string;
    contain?: string;
    eq?: string;
    ne?: string;
    start?: string;
    end?: string;
    after?: string;
    afterEq?: string;
    before?: string;
    beforeEq?: string;
  };

And it looks is working correct here..
1

but when I build it with: lerna run build --scope tui-grid
and I add the generated tui-grid.js file in my project, values that I added are in file, but the filters in UI are empty.
Can you see it when I am wrong or I have missing something please ?

@js87zz
Copy link
Contributor

js87zz commented Dec 9, 2020

@denaldhushi
It looks like a timing problem. The text of the filter is set before i18n setup is completed. We need to improve it for supporting filter i18n properly. Thank you for your contributing!

@denaldhushi
Copy link
Author

Do you have any update about that issue?

@js87zz
Copy link
Contributor

js87zz commented Feb 3, 2021

@denaldhushi
Not yet..😓 Due to the ongoing with other projects, the new feature or bug fixes may be slow. If I start working on it, I will leave a comment.

@js87zz
Copy link
Contributor

js87zz commented Apr 27, 2021

@denaldhushi
This i18n for filter has been added in v4.17.0. Thanks!

// our internal example 
const messages: OptI18nLanguage = {
  en: {
    // ...
    filter: {
      contains: 'Contains',
      eq: 'Equals',
      ne: 'Not equals',
      start: 'Starts with',
      end: 'Ends with',
      after: 'After',
      afterEq: 'After or Equal',
      before: 'Before',
      beforeEq: 'Before or Equal',
      apply: 'Apply',
      clear: 'Clear',
      selectAll: 'Select All',
      emptyValue: 'Empty Value',
    },
  },
}

@js87zz js87zz closed this as completed Apr 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants