Permalink
Browse files

fix(i18n): use attribute to enable soft dependency on i18n

  • Loading branch information...
bas080
bas080 committed May 25, 2016
1 parent 9858b96 commit cd9a7098b59316e9e1e181fc7c549fc8b7ab9c2c
Showing with 5 additions and 11 deletions.
  1. +1 −1 src/form-field.html
  2. +4 −10 src/form-field.js
@@ -1,6 +1,6 @@
<template>
<div class="form-group">
<label if.bind="!attribute.hide_label">${label}</label>
<label t.bind="label" if.bind="!attribute.hide_label">${label}</label>

<compose
if.bind="isHtmlComponent"
@@ -1,18 +1,16 @@
import {Config} from './config';
import {component} from './component';
import {bindingMode, bindable, computedFrom, inject} from 'aurelia-framework';
import {I18N} from 'aurelia-i18n';

@inject(Config, I18N, Element)
@inject(Config, Element)
export class FormFieldCustomElement {

@bindable attribute

@bindable({defaultBindingMode: bindingMode.twoWay})
value

constructor(config, i18n, element) {
this.i18n = i18n;
constructor(config, element) {
this.config = config;
this.element = element;
}
@@ -27,11 +25,7 @@ export class FormFieldCustomElement {

@computedFrom('attribute')
get label() {
let str = this.attribute.label || this.attribute.key;
if (this.config.translate) {
return this.i18n.tr(str);
}
return str;
return this.attribute.label || this.attribute.key;
}

@computedFrom('attribute')
@@ -49,7 +43,7 @@ export class FormFieldCustomElement {
*/
@computedFrom('component')
get isHtmlComponent() {
return (this.component.endsWith('.html'));
return this.component ? (this.component.endsWith('.html')) : true;
}
}

0 comments on commit cd9a709

Please sign in to comment.