diff --git a/filcnaplo/lib/utils/format.dart b/filcnaplo/lib/utils/format.dart index 4c7f576..72bbaa6 100644 --- a/filcnaplo/lib/utils/format.dart +++ b/filcnaplo/lib/utils/format.dart @@ -2,6 +2,7 @@ import 'package:flutter/widgets.dart'; import 'package:intl/intl.dart'; import 'package:i18n_extension/i18n_widget.dart'; import 'package:html/parser.dart'; +import 'format.i18n.dart'; extension StringFormatUtils on String { String specialChars() => this @@ -37,10 +38,10 @@ extension DateFormatUtils on DateTime { DateTime now = DateTime.now(); if (this.difference(now).inDays == 0) { - if (this.hour == 0 && this.minute == 0 && this.second == 0) return "Today"; // TODO: i18n + if (this.hour == 0 && this.minute == 0 && this.second == 0) return "Today".i18n; return DateFormat("HH:mm").format(this); } - if (this.difference(now).inDays == 1) return "Yesterday"; // TODO: i18n + if (this.difference(now).inDays == 1) return "Yesterday".i18n; String formatString; if (this.year == now.year) diff --git a/filcnaplo/lib/utils/format.i18n.dart b/filcnaplo/lib/utils/format.i18n.dart new file mode 100644 index 0000000..884042d --- /dev/null +++ b/filcnaplo/lib/utils/format.i18n.dart @@ -0,0 +1,24 @@ +import 'package:i18n_extension/i18n_extension.dart'; + +extension Localization on String { + static final _t = Translations.byLocale("hu_hu") + + { + "en_en": { + "Today": "Today", + "Yesterday": "Yesterday", + }, + "hu_hu": { + "Today": "Ma", + "Yesterday": "Tegnap", + }, + "de_de": { + "Today": "Heute", + "Yesterday": "Gestern", + } + }; + + String get i18n => localize(this, _t); + String fill(List params) => localizeFill(this, params); + String plural(int value) => localizePlural(value, this, _t); + String version(Object modifier) => localizeVersion(modifier, this, _t); +}