adopted-ember-addons / ember-light-table

Lightweight, contextual component based table for Ember
http://adopted-ember-addons.github.io/ember-light-table/
MIT License
312 stars 131 forks source link

I18n support? #311

Open ctjhoa opened 7 years ago

ctjhoa commented 7 years ago

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 commented 7 years ago

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'
    }];
  }),
offirgolan commented 7 years ago

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.

alexander-alvarez commented 7 years ago

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?

ynnoj commented 7 years ago

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'
  }]
}
offirgolan commented 7 years ago

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