Skip to content

Commit

Permalink
feat: add i18nHook
Browse files Browse the repository at this point in the history
  • Loading branch information
glemartret committed Feb 2, 2024
1 parent 92d3397 commit 6aa6933
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions lib/src/localization/i18n_hook.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import 'package:flutter/widgets.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:i18n_extension/i18n_widget.dart';

void useI18n() {
final context = useContext();
final deviceLocale =
Localizations.maybeLocaleOf(context) ?? const Locale('en');

Future(() {
I18n.of(context).locale = deviceLocale;
});
return;
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: "A new Flutter project."
# Prevent accidental publishing to pub.dev.
publish_to: 'none'

version: 1.0.0+5
version: 1.0.0+6

environment:
sdk: '>=3.2.0 <4.0.0'
Expand Down

0 comments on commit 6aa6933

Please sign in to comment.