libretranslatr
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
class HistoryItem {
|
||||
final String sourceLang;
|
||||
final String targetLang;
|
||||
final String sourceText;
|
||||
final String translatedText;
|
||||
final DateTime timestamp;
|
||||
|
||||
HistoryItem({
|
||||
required this.sourceLang,
|
||||
required this.targetLang,
|
||||
required this.sourceText,
|
||||
required this.translatedText,
|
||||
required this.timestamp,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'sourceLang': sourceLang,
|
||||
'targetLang': targetLang,
|
||||
'sourceText': sourceText,
|
||||
'translatedText': translatedText,
|
||||
'timestamp': timestamp.toIso8601String(),
|
||||
};
|
||||
|
||||
factory HistoryItem.fromJson(Map<String, dynamic> json) => HistoryItem(
|
||||
sourceLang: json['sourceLang'] as String,
|
||||
targetLang: json['targetLang'] as String,
|
||||
sourceText: json['sourceText'] as String,
|
||||
translatedText: json['translatedText'] as String,
|
||||
timestamp: DateTime.parse(json['timestamp'] as String),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
class Language {
|
||||
final String code;
|
||||
final String name;
|
||||
final List<String> targets;
|
||||
|
||||
const Language({
|
||||
required this.code,
|
||||
required this.name,
|
||||
this.targets = const [],
|
||||
});
|
||||
|
||||
factory Language.fromJson(Map<String, dynamic> json) {
|
||||
return Language(
|
||||
code: json['code'] as String,
|
||||
name: json['name'] as String,
|
||||
targets: (json['targets'] as List?)?.map((e) => e.toString()).toList() ??
|
||||
const [],
|
||||
);
|
||||
}
|
||||
|
||||
/// "Otomatik Algıla" seçeneğini temsil eden özel dil.
|
||||
static const auto = Language(code: 'auto', name: 'Otomatik Algıla');
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) => other is Language && other.code == code;
|
||||
|
||||
@override
|
||||
int get hashCode => code.hashCode;
|
||||
}
|
||||
Reference in New Issue
Block a user