Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

intl: Migrate from package:flutter_gen; include generated files #1058

Merged
merged 5 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
# Dart files generated from the files next to them, or by Pigeon:
*.g.dart -diff

# Generated files for localizations.
lib/generated/l10n/*.dart -diff

# Generated files for testing migrations:
test/model/schemas/*.dart -diff
test/model/schemas/*.json -diff
Expand Down
7 changes: 1 addition & 6 deletions docs/translation.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,7 @@ changes to the ARB file.

### Using a translated string in the code

To use in our widgets, you need to import the generated bindings:
```
import 'package:flutter_gen/gen_l10n/zulip_localizations.dart';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super nit: the main migration commit should update this line, because otherwise the instruction is incorrect as of that commit

(then the later commit can delete, like in this revision, along with that nice commit message explaining why it used to be needed and no longer is)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-import 'package:flutter_gen/gen_l10n/zulip_localizations.dart';
+import '/generated/l10n/zulip_localizations.dart';

If this nit were the only thing remaining in this revision I'd probably just go ahead and merge it, but since we have another round anyway: this (temporary) advice should match what we actually do in the source files 🙂, which follows #1058 (comment) .

```

Then in your widget code, pull the localizations object
To use in your widget code, pull the localizations object
off of the Flutter build context:
```
Widget build(BuildContext context) {
Expand Down
2 changes: 2 additions & 0 deletions l10n.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Docs on this config file:
# https://docs.flutter.dev/ui/accessibility-and-localization/internationalization#configuring-the-l10nyaml-file

synthetic-package: false
arb-dir: assets/l10n
output-dir: lib/generated/l10n
template-arb-file: app_en.arb
required-resource-attributes: true
output-localization-file: zulip_localizations.dart
Expand Down
Loading