|
| 1 | +// ignore_for_file: file_names |
| 2 | +// Author: Batmend Ganbaatar (https://github.com/sadespresso) |
| 3 | + |
| 4 | +import 'package:moment_dart/src/localization.dart'; |
| 5 | +import 'package:moment_dart/src/localizations/mixins/month_names.dart'; |
| 6 | +import 'package:moment_dart/src/localizations/mixins/ordinal_numbers.dart'; |
| 7 | +import 'package:moment_dart/src/localizations/mixins/simple_duration.dart'; |
| 8 | +import 'package:moment_dart/src/localizations/mixins/simple_range.dart'; |
| 9 | +import 'package:moment_dart/src/localizations/mixins/simple_relative.dart'; |
| 10 | +import 'package:moment_dart/src/localizations/mixins/simple_units.dart'; |
| 11 | +import 'package:moment_dart/src/localizations/mixins/weekday_shortforms.dart'; |
| 12 | +import 'package:moment_dart/src/types.dart'; |
| 13 | + |
| 14 | +/// Language: Turkish (Turkey) |
| 15 | +/// Country: Turkey |
| 16 | +class LocalizationTrTr extends MomentLocalization |
| 17 | + with |
| 18 | + MonthNames, |
| 19 | + Ordinal, |
| 20 | + SimpleUnits, |
| 21 | + SimpleRelative, |
| 22 | + SimpleDuration, |
| 23 | + SimpleRange, |
| 24 | + WeekdayShortForms { |
| 25 | + static LocalizationTrTr? _instance; |
| 26 | + |
| 27 | + LocalizationTrTr._internal() : super(); |
| 28 | + |
| 29 | + factory LocalizationTrTr() { |
| 30 | + _instance ??= LocalizationTrTr._internal(); |
| 31 | + |
| 32 | + return _instance!; |
| 33 | + } |
| 34 | + |
| 35 | + @override |
| 36 | + String get endonym => "Türkçe"; |
| 37 | + |
| 38 | + @override |
| 39 | + String get languageCode => "tr"; |
| 40 | + |
| 41 | + @override |
| 42 | + String get countryCode => "TR"; |
| 43 | + |
| 44 | + @override |
| 45 | + String get languageNameInEnglish => "Turkish (Turkey)"; |
| 46 | + |
| 47 | + @override |
| 48 | + String relativePast(String unit) => "$unit önce"; |
| 49 | + @override |
| 50 | + String relativeFuture(String unit) => "$unit sonra"; |
| 51 | + |
| 52 | + @override |
| 53 | + Map<int, String> get monthNames => { |
| 54 | + 1: "Ocak", |
| 55 | + 2: "Şubat", |
| 56 | + 3: "Mart", |
| 57 | + 4: "Nisan", |
| 58 | + 5: "Mayıs", |
| 59 | + 6: "Haziran", |
| 60 | + 7: "Temmuz", |
| 61 | + 8: "Ağustos", |
| 62 | + 9: "Eylül", |
| 63 | + 10: "Ekim", |
| 64 | + 11: "Kasım", |
| 65 | + 12: "Aralık", |
| 66 | + }; |
| 67 | + |
| 68 | + @override |
| 69 | + Map<int, String> get monthNamesShort => monthNames.map( |
| 70 | + (key, value) => MapEntry( |
| 71 | + key, |
| 72 | + value.substring(0, 3), |
| 73 | + ), |
| 74 | + ); |
| 75 | + |
| 76 | + @override |
| 77 | + Map<int, String> get weekdayName => { |
| 78 | + DateTime.monday: "Pazartesi", |
| 79 | + DateTime.tuesday: "Salı", |
| 80 | + DateTime.wednesday: "Çarşamba", |
| 81 | + DateTime.thursday: "Perşembe", |
| 82 | + DateTime.friday: "Cuma", |
| 83 | + DateTime.saturday: "Cumartesi", |
| 84 | + DateTime.sunday: "Pazar", |
| 85 | + }; |
| 86 | + |
| 87 | + @override |
| 88 | + Map<int, String> get weekdayNameShort => { |
| 89 | + DateTime.monday: "Pzt", |
| 90 | + DateTime.tuesday: "Sal", |
| 91 | + DateTime.wednesday: "Çar", |
| 92 | + DateTime.thursday: "Per", |
| 93 | + DateTime.friday: "Cum", |
| 94 | + DateTime.saturday: "Cmt", |
| 95 | + DateTime.sunday: "Paz", |
| 96 | + }; |
| 97 | + |
| 98 | + @override |
| 99 | + Map<int, String> get weekdayNameMin => { |
| 100 | + DateTime.monday: 'Pt', |
| 101 | + DateTime.tuesday: 'Sa', |
| 102 | + DateTime.wednesday: 'Ça', |
| 103 | + DateTime.thursday: 'Pe', |
| 104 | + DateTime.friday: 'Cu', |
| 105 | + DateTime.saturday: 'Ct', |
| 106 | + DateTime.sunday: 'Pz', |
| 107 | + }; |
| 108 | + |
| 109 | + @override |
| 110 | + FormatSetOptional overrideFormatters() { |
| 111 | + return { |
| 112 | + // From [EnglishLikeOrdinal] mixin |
| 113 | + ...formattersWithOrdinal, |
| 114 | + // From [MonthNames] mixin |
| 115 | + ...formattersForMonthNames, |
| 116 | + // From [WeekdayShortForms] mixin |
| 117 | + ...formattersForWeekdayShortForms, |
| 118 | + // Localization aware formats |
| 119 | + FormatterToken.L: (dateTime) => reformat(dateTime, "DD.MM.YYYY"), |
| 120 | + FormatterToken.l: (dateTime) => reformat(dateTime, "D.M.YYYY"), |
| 121 | + FormatterToken.LL: (dateTime) => reformat(dateTime, "D MMMM YYYY"), |
| 122 | + FormatterToken.ll: (dateTime) => reformat(dateTime, "D MMM YYYY"), |
| 123 | + FormatterToken.LLL: (dateTime) => reformat(dateTime, "D MMMM YYYY HH:mm"), |
| 124 | + FormatterToken.lll: (dateTime) => reformat(dateTime, "D MMM YYYY H:mm"), |
| 125 | + FormatterToken.LLLL: (dateTime) => |
| 126 | + reformat(dateTime, "dddd, D MMMM YYYY HH:mm"), |
| 127 | + FormatterToken.llll: (dateTime) => |
| 128 | + reformat(dateTime, "ddd, D MMM YYYY H:mm"), |
| 129 | + FormatterToken.LT: (dateTime) => reformat(dateTime, "HH:mm"), |
| 130 | + FormatterToken.LTS: (dateTime) => reformat(dateTime, "HH:mm:ss"), |
| 131 | + }; |
| 132 | + } |
| 133 | + |
| 134 | + @override |
| 135 | + String ordinalNumber(int n) { |
| 136 | + if (n == 0) return "$n'ıncı"; |
| 137 | + |
| 138 | + final int unit = n % 10; |
| 139 | + final String? unitEnding = _ordinalUnitSuffixes[unit]; |
| 140 | + |
| 141 | + if (unitEnding != null) return "$n$unitEnding"; |
| 142 | + |
| 143 | + final int tenth = (n % 100) - unit; |
| 144 | + |
| 145 | + final String? tenEnding = _ordinalNonUnitSuffixes[tenth]; |
| 146 | + if (tenEnding != null) return "$n$tenEnding"; |
| 147 | + |
| 148 | + return "$n'üncü"; |
| 149 | + } |
| 150 | + |
| 151 | + @override |
| 152 | + CalenderLocalizationData get calendarData => calenderLocalizationDataTrTr; |
| 153 | + |
| 154 | + static String last(String weekday) => "Geçen $weekday"; |
| 155 | + static String at(String date, String time) => "$date saat $time"; |
| 156 | + |
| 157 | + static const CalenderLocalizationData calenderLocalizationDataTrTr = |
| 158 | + CalenderLocalizationData( |
| 159 | + relativeDayNames: { |
| 160 | + -1: "Dün", |
| 161 | + 0: "Bugün", |
| 162 | + 1: "Yarın", |
| 163 | + }, |
| 164 | + keywords: CalenderLocalizationKeywords( |
| 165 | + at: at, |
| 166 | + lastWeekday: last, |
| 167 | + ), |
| 168 | + ); |
| 169 | + |
| 170 | + @override |
| 171 | + int get weekStart => DateTime.monday; |
| 172 | + |
| 173 | + @override |
| 174 | + Map<DurationInterval, UnitString> get units => { |
| 175 | + DurationInterval.lessThanASecond: UnitString.duo( |
| 176 | + "birkaç saniye", |
| 177 | + "birkaç sn", |
| 178 | + ), |
| 179 | + DurationInterval.aSecond: UnitString.duo( |
| 180 | + "bir saniye", |
| 181 | + "1 sn", |
| 182 | + ), |
| 183 | + DurationInterval.seconds: UnitString.duo( |
| 184 | + "$srDelta saniye", |
| 185 | + "$srDelta sn", |
| 186 | + ), |
| 187 | + DurationInterval.aMinute: UnitString.duo( |
| 188 | + "bir dakika", |
| 189 | + "1 dk", |
| 190 | + ), |
| 191 | + DurationInterval.minutes: UnitString.duo( |
| 192 | + "$srDelta dakika", |
| 193 | + "$srDelta dk", |
| 194 | + ), |
| 195 | + DurationInterval.anHour: UnitString.duo( |
| 196 | + "bir saat", |
| 197 | + "1 sa", |
| 198 | + ), |
| 199 | + DurationInterval.hours: UnitString.duo( |
| 200 | + "$srDelta saat", |
| 201 | + "$srDelta sa", |
| 202 | + ), |
| 203 | + DurationInterval.aDay: UnitString.duo( |
| 204 | + "bir gün", |
| 205 | + "1 gün", |
| 206 | + ), |
| 207 | + DurationInterval.days: UnitString.duo( |
| 208 | + "$srDelta gün", |
| 209 | + "$srDelta gün", |
| 210 | + ), |
| 211 | + DurationInterval.aWeek: UnitString.duo( |
| 212 | + "bir hafta", |
| 213 | + "1 hft", |
| 214 | + ), |
| 215 | + DurationInterval.weeks: UnitString.duo( |
| 216 | + "$srDelta hafta", |
| 217 | + "$srDelta hft", |
| 218 | + ), |
| 219 | + DurationInterval.aMonth: UnitString.duo( |
| 220 | + "bir ay", |
| 221 | + "1 ay", |
| 222 | + ), |
| 223 | + DurationInterval.months: UnitString.duo( |
| 224 | + "$srDelta ay", |
| 225 | + "$srDelta ay", |
| 226 | + ), |
| 227 | + DurationInterval.aYear: UnitString.duo( |
| 228 | + "bir yıl", |
| 229 | + "1 yıl", |
| 230 | + ), |
| 231 | + DurationInterval.years: UnitString.duo( |
| 232 | + "$srDelta yıl", |
| 233 | + "$srDelta yıl", |
| 234 | + ), |
| 235 | + }; |
| 236 | + |
| 237 | + @override |
| 238 | + SimpleRangeData get simpleRangeData => SimpleRangeData( |
| 239 | + thisWeek: "Bu hafta", |
| 240 | + thisMonth: "Bu ay", |
| 241 | + thisYear: "Bu yıl", |
| 242 | + year: (range) => "${range.year} yılı", |
| 243 | + month: (range) => monthNames[range.month]!, |
| 244 | + allAfter: (formattedDate) => "$formattedDate tarihinden sonra", |
| 245 | + allBefore: (formattedDate) => "$formattedDate tarihinden önce", |
| 246 | + customRangeAllTime: "Tüm zamanlar", |
| 247 | + ); |
| 248 | + |
| 249 | + static const Map<int, String> _ordinalUnitSuffixes = { |
| 250 | + 1: "'inci", |
| 251 | + 2: "'nci", |
| 252 | + 3: "'üncü", |
| 253 | + 4: "'üncü", |
| 254 | + 5: "'inci", |
| 255 | + 7: "'nci", |
| 256 | + 6: "'ncı", |
| 257 | + 8: "'inci", |
| 258 | + 9: "'uncu", |
| 259 | + }; |
| 260 | + |
| 261 | + static const Map<int, String> _ordinalNonUnitSuffixes = { |
| 262 | + 10: "'uncu", |
| 263 | + 20: "'nci", |
| 264 | + 30: "'uncu", |
| 265 | + 40: "'ıncı", |
| 266 | + 50: "'nci", |
| 267 | + 60: "'ıncı", |
| 268 | + 70: "'inci", |
| 269 | + 80: "'inci", |
| 270 | + 90: "'ıncı" |
| 271 | + }; |
| 272 | +} |
0 commit comments