Permalink
Browse files

bug: MaterialTranslate checks the value of the translate-Attribute

  • Loading branch information...
MikeMitterer committed Aug 23, 2017
1 parent 6b5e0fe commit 1609410234dd8d6c009e788033d1180fa9c9e570
Showing with 15 additions and 8 deletions.
  1. +15 −8 lib/src/directive/components/MaterialTranslate.dart
@@ -47,26 +47,33 @@ class MaterialTranslate extends MdlComponent {
void _init() {
_logger.info("MaterialTranslate - init");
/// Recommended - add SELECTOR as class
// Recommended - add SELECTOR as class
element.classes.add(_MaterialTranslateConstant.WIDGET_SELECTOR);
final String translation = element.text.replaceFirstMapped(
new RegExp('(_|l10n|L10N)\\((\'|\")([^\"\']*)(\'|\")\\)'),
(final Match match) {
_idToTranslate = match.group(3).trim();
return translator.translate(new L10N(_idToTranslate));
});
_idToTranslate = match.group(3).trim();
return translator.translate(new L10N(_idToTranslate));
});
_logger.info("-> " + _idToTranslate);
if(_idToTranslate.isNotEmpty) {
element.text = translation;
if (_idToTranslate.isNotEmpty) {
// If attribute is set to true or if attribute is available but has no
// value set
if(_fieldvalue) {
element.text = translation;
} else {
element.text = _idToTranslate;
}
}
element.classes.add(_cssClasses.IS_UPGRADED);
}
String get _fieldname => element.attributes[_MaterialTranslateConstant.WIDGET_SELECTOR].trim();
/// Returns true if attribute has not value set or if it's value is not 'no'
bool get _fieldvalue => !('no' == element.attributes[_MaterialTranslateConstant.WIDGET_SELECTOR]?.trim());
}
/// registration-Helper

0 comments on commit 1609410

Please sign in to comment.