Skip to content

Commit

Permalink
fix: i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
hungnt committed Nov 29, 2023
1 parent ec44900 commit b546bdf
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 16 deletions.
5 changes: 3 additions & 2 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"gruntfuggly.todo-tree",
"blaugold.melos-code",
"peterschmalfeldt.explorer-exclude",
"irongeek.vscode-env"
"irongeek.vscode-env",
"blaugold.melos-code"
]
}
}
4 changes: 3 additions & 1 deletion lib/core/presentation/hook/use_i18n.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import 'package:flutter_hooks/flutter_hooks.dart';

import 'package:erb_flutter_boilerplate/i18n/i18n.dart';

StringsVi useI18n() {
// NOTE: returns a concrete type instead of abstraction
// https://github.com/slang-i18n/slang/issues/169
I18n useI18n() {
final context = useContext();

return Translations.of(context);
Expand Down
3 changes: 2 additions & 1 deletion lib/i18n/i18n.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export '../i18n/strings.g.dart';
export 'translate_provider.dart';
export 'helper.dart';
export 'helper.dart';
export 'typedef.dart';
3 changes: 3 additions & 0 deletions lib/i18n/typedef.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import 'strings.g.dart';

typedef I18n = StringsVi;
39 changes: 27 additions & 12 deletions melos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,17 @@ command:
# Generate environment files which should not be committed to the repository.
# Instead, they are generated during the CI process before checking
# if the rest of the package's code generation is up to date.
post: flutter pub get && dart pub global activate coverage ^1.6.4 && cd packages/env && dart pub get && dart run build_runner build -d
post: flutter pub get && dart pub global activate coverage ^1.6.4 && cd packages/env && dart pub get && dart run build_runner build -d && melos run i18n

# See https://github.com/firebase/flutterfire/blob/master/melos.yaml for more examples
scripts:
# Custom lint is only applied to the packages and not the root app because of a dependency conflict with `integration_test` and `melos`
pub:
run: melos run dart:pkg --no-select && melos run flutter:pkg --no-select
run: |
dart pub get && \
melos run flutter:pkg --no-select
description: Run `dart pub get` in all packages.

dart:pkg:
run: dart pub get
exec:
failFast: true
# concurrency: 1
description: Run `dart pub get` in the selected package.
packageFilters:
noDependsOn: flutter

flutter:pkg:
run: flutter pub get
exec:
Expand Down Expand Up @@ -110,7 +103,11 @@ scripts:
description: Verify formatting was applied.

generate:
run: melos run assets && melos run env --no-select && melos run generate:pkg --no-select
run: |
melos run assets && \
melos run env --no-select && \
melos run generate:pkg --no-select && \
melos run i18n
description: Run `build_runner build` in all packages.

generate:pkg:
Expand All @@ -124,6 +121,24 @@ scripts:
noDependsOn: envied
# ignore: localization

i18n:
run: dart run slang
exec:
failFast: true
description: Run `dart run slang` generate dart file
packageFilters:
dirExists:
- lib/i18n

watch:i18n:
run: dart run slang watch
exec:
failFast: true
description: Run `dart run slang watch` auto Rebuild generate dart file
packageFilters:
dirExists:
- lib/i18n

watch:pkg:
run: dart run build_runner watch
exec:
Expand Down

0 comments on commit b546bdf

Please sign in to comment.