Skip to content

Commit

Permalink
Merge pull request #94 from simo9900/language_fr_pt
Browse files Browse the repository at this point in the history
Adding languages- French and Portuguese
  • Loading branch information
JonasWanke authored Aug 7, 2021
2 parents 4b1af92 + d908f3c commit 97b9737
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Some date/time-related parameters also have special suffixes:
* `timeOfDay`: A `Duration` between zero and 24 hours.
* `dayOfWeek`: An `int` between one and seven ([`DateTime.monday`](https://api.flutter.dev/flutter/dart-core/DateTime/monday-constant.html) through [`DateTime.sunday`](https://api.flutter.dev/flutter/dart-core/DateTime/sunday-constant.html)).

Timetable currently offers localizations for Chinese, English, German, Italian, Japanese, and Spanish.
Timetable currently offers localizations for Chinese, English, French, German, Italian, Japanese, Portuguese, and Spanish.
Even if you're just supporting English in your app, you have to add Timetable's localization delegate to your `MaterialApp`/`CupertinoApp`/`WidgetsApp`:

```dart
Expand Down
43 changes: 43 additions & 0 deletions lib/src/localization.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import 'week.dart';
/// * `de` – German
/// * `en` – English
/// * `es` – Spanish
/// * `fr` – French
/// * `it` – Italian
/// * `ja` – Japanese
/// * `pt` – Portuguese
/// * `zh_CN` – Chinese (Simplified)
/// * `zh_TW` – Chinese (Traditional)
///
Expand Down Expand Up @@ -60,10 +62,14 @@ class TimetableLocalizationsDelegate
return const TimetableLocalizationEn();
case 'es':
return const TimetableLocalizationEs();
case 'fr':
return const TimetableLocalizationFr();
case 'it':
return const TimetableLocalizationIt();
case 'ja':
return const TimetableLocalizationJa();
case 'pt':
return const TimetableLocalizationPt();
case 'zh':
if (locale.countryCode?.toLowerCase() == 'tw') {
return const TimetableLocalizationZhTw();
Expand Down Expand Up @@ -195,6 +201,24 @@ class TimetableLocalizationEs extends TimetableLocalizations {
'Semana ${week.weekOfYear}, ${week.weekBasedYear}';
}

class TimetableLocalizationFr extends TimetableLocalizations {
const TimetableLocalizationFr();

@override
List<String> weekLabels(Week week) {
return [
weekOfYear(week),
'Semaine ${week.weekOfYear}',
'S ${week.weekOfYear}',
'${week.weekOfYear}',
];
}

@override
String weekOfYear(Week week) =>
'Semaine ${week.weekOfYear}, ${week.weekBasedYear}';
}

class TimetableLocalizationIt extends TimetableLocalizations {
const TimetableLocalizationIt();

Expand Down Expand Up @@ -231,6 +255,24 @@ class TimetableLocalizationJa extends TimetableLocalizations {
'Week ${week.weekOfYear}, ${week.weekBasedYear}';
}

class TimetableLocalizationPt extends TimetableLocalizations {
const TimetableLocalizationPt();

@override
List<String> weekLabels(Week week) {
return [
weekOfYear(week),
'Semana ${week.weekOfYear}',
'S ${week.weekOfYear}',
'${week.weekOfYear}',
];
}

@override
String weekOfYear(Week week) =>
'Semana ${week.weekOfYear}, ${week.weekBasedYear}';
}

class TimetableLocalizationZhCn extends TimetableLocalizations {
const TimetableLocalizationZhCn();

Expand Down Expand Up @@ -266,3 +308,4 @@ class TimetableLocalizationZhTw extends TimetableLocalizations {
String weekOfYear(Week week) =>
'Week ${week.weekOfYear}, ${week.weekBasedYear}';
}

0 comments on commit 97b9737

Please sign in to comment.