ember-light-table icon indicating copy to clipboard operation
ember-light-table copied to clipboard

I18n support?

Open ctjhoa opened this issue 8 years ago • 5 comments

Hi, It seems that there is no ember-i18n support. For example, with columns:

import { translationMacro as t } from 'ember-i18n';
// ...
columns: computed(function() {
    return [{
      label: t('agreement.title'),
      valuePath: 'metadata.title'
    }];
  }),

Assertion Failed: Cannot translate agreement.title. <(unknown mixin):ember591> does not have an i18n. Is this something on the roadmap or is there another way?

ctjhoa avatar Jan 11 '17 21:01 ctjhoa

I found a workaround but it's kinda ugly

titleHeader: t('agreement.title'),
columns: computed('titleHeader', function() {
    return [{
      label: get(this, 'titleHeader'),
      valuePath: 'metadata.title'
    }];
  }),

ctjhoa avatar Jan 11 '17 21:01 ctjhoa

There is currently no out-of-the-box solution for this but it should be fairly easy to do by creating your own column type and overriding the label property.

In your column definition, you can pass a labelKey: 'agreement.title' instead of label: 'Foo Bar' and then use that via column.labelKey in your column type.

offirgolan avatar Jan 11 '17 21:01 offirgolan

any plans to have 'official' column types, cell-components, etc that are used a lot by the community? Or even just a poll of what people have implemented to improve documentation to show the different use cases that ember-light-table can achieve?

alexander-alvarez avatar Jan 12 '17 15:01 alexander-alvarez

Import the i18n service in the component and you can use the t helper in the columns declaration.

baseColumns: computed(function() {
  const i18n = this.get('i18n');

  return [{
    label: i18n.t('table.catalogue.name.key'),
    valuePath: 'name'
  }]
}

ynnoj avatar Feb 23 '17 20:02 ynnoj

@alexander-alvarez Yeah I need to work on adding some more default cell & column types.

offirgolan avatar Feb 27 '17 20:02 offirgolan