Skip to content

Commit

Permalink
Fix localization stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
lalomartins committed Mar 11, 2021
1 parent da2093b commit 6c75e8c
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 134 deletions.
4 changes: 4 additions & 0 deletions lib/calendar_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:flushbar/flushbar.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

import 'config.dart';
import 'widgets/achieve.dart';
import 'date_util.dart';
import 'db.dart';
Expand Down Expand Up @@ -40,6 +41,9 @@ class _CalendarPageState extends State<CalendarPage> {
thisWeek = newWeek;
});
});
WidgetsBinding.instance.addPostFrameCallback((_) {
config.useLocaleDefaults(context);
});
}

@override
Expand Down
30 changes: 19 additions & 11 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_native_timezone/flutter_native_timezone.dart';
import 'package:package_info/package_info.dart';
import 'package:provider/provider.dart';
Expand Down Expand Up @@ -67,18 +68,25 @@ class WeeklyGoalsApp extends StatelessWidget {
themeMode: config.themeMode,
initialRoute: '/',
routes: {
'/': (context) => OrientationBuilder(
builder: (BuildContext context, Orientation orientation) {
WidgetsBinding.instance.addPostFrameCallback((_) {
config.useLocaleDefaults(context);
});
return orientation == Orientation.landscape ? CalendarPage() : CompactModePage();
},
),
'settings': (context) => SettingsScreen(),
'add': (context) => AddScreen(),
'edit': (context) => EditScreen(),
'/': (context) {
return OrientationBuilder(
builder: (BuildContext context, Orientation orientation) {
return orientation == Orientation.landscape ? CalendarPage() : CompactModePage();
},
);
},
'settings': (_) => SettingsScreen(),
'add': (_) => AddScreen(),
'edit': (_) => EditScreen(),
},
localizationsDelegates: [
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
],
supportedLocales: [
const Locale('en', ''),
const Locale('ja', ''),
],
);
}
}
Loading

0 comments on commit 6c75e8c

Please sign in to comment.