[gallery] flutter pub run grinder l10n got problem
-> flutter pub run grinder l10n
Output;
grinder running generate-localizations l10n
generate-localizations
/home/aliyazdi75/flutter/bin/cache/dart-sdk/bin/dart /home/aliyazdi75/flutter/dev/tools/localization/bin/gen_l10n.dart --template-arb-file=intl_en_US.arb --output-localization-file=gallery_localizations.dart --output-class=GalleryLocalizations --preferred-supported-locales=["en_US"]
Error: Could not resolve the package 'args' in 'package:args/args.dart'.
Error: Could not resolve the package 'file' in 'package:file/local.dart'.
Error: Could not resolve the package 'path' in 'package:path/path.dart'.
../../../../flutter/dev/tools/localization/bin/gen_l10n.dart:8:8: Error: Not found: 'package:args/args.dart'
import 'package:args/args.dart' as argslib;
^
../../../../flutter/dev/tools/localization/bin/gen_l10n.dart:9:8: Error: Not found: 'package:file/local.dart'
import 'package:file/local.dart' as local;
^
../../../../flutter/dev/tools/localization/bin/gen_l10n.dart:10:8: Error: Not found: 'package:path/path.dart'
import 'package:path/path.dart' as path;
^
Error: Could not resolve the package 'file' in 'package:file/file.dart'.
Error: Could not resolve the package 'meta' in 'package:meta/meta.dart'.
../../../../flutter/dev/tools/localization/gen_l10n.dart:10:8: Error: Not found: 'package:path/path.dart'
import 'package:path/path.dart' as path;
^
../../../../flutter/dev/tools/localization/localizations_utils.dart:9:8: Error: Not found: 'package:args/args.dart'
import 'package:args/args.dart' as argslib;
^
failed with exit code 254
#0 run (package:grinder/src/run.dart:48:5)
#1 Dart.run (package:grinder/grinder_sdk.dart:75:12)
#2 generateLocalizations (file:///home/aliyazdi75/Documents/FlutterPackages/samples-master/gallery/tool/grind.dart:38:8)
#3 _LibraryMirror._invoke (dart:mirrors-patch/mirrors_impl.dart:1086:36)
#4 _ObjectMirror.invoke (dart:mirrors-patch/mirrors_impl.dart:243:25)
#5 TaskDiscovery.discoverDeclaration.<anon> (package:grinder/src/discover_tasks.dart:79:38)
#6 _rootRun (dart:async/zone.dart:1126:13)
#7 _CustomZone.run (dart:async/zone.dart:1023:19)
#8 _runZoned (dart:async/zone.dart:1518:10)
#9 runZoned (dart:async/zone.dart:1465:12)
#10 ZonedValue.withValue (package:grinder/src/utils.dart:112:12)
#11 GrinderTask.execute (package:grinder/src/grinder_task.dart:63:27)
#12 Grinder._invokeTask (package:grinder/src/grinder.dart:193:27)
#13 Grinder.start.<anon> (package:grinder/src/grinder.dart:168:16)
#14 Future.forEach.<anon> (dart:async/future.dart:492:26)
#15 Future.doWhile.<anon> (dart:async/future.dart:534:26)
#16 _RootZone.runUnaryGuarded (dart:async/zone.dart:1316:10)
#17 _RootZone.bindUnaryCallbackGuarded.<anon> (dart:async/zone.dart:1355:26)
#18 Future.doWhile (dart:async/future.dart:549:18)
#19 Future.forEach (dart:async/future.dart:490:12)
#20 Grinder.start (package:grinder/src/grinder.dart:167:21)
#21 runTasks (package:grinder/src/cli.dart:67:39)
#22 grind (package:grinder/grinder.dart:46:12)
#23 main (file:///home/aliyazdi75/Documents/FlutterPackages/samples-master/gallery/tool/grind.dart:12:33)
pub finished with exit code 1
hey @aliyazdi75 are you running the latest flutter master channel? I've run into similar problems before a flutter pub get can sometimes fix this.
Hello @rami-a , Its' running under beta channel, because of flutter web. Should I change to master channel? and I used flutter pub get before this command.
Yes, it's possible that beta channel does not have the latest version of the gen_l10n.dart script that we use. I suggest trying on master channel and seeing if it works. You can then go back to the beta channel if you'd like.
@rami-a Here's my flutter doctor on master channel:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, v1.15.4-pre.84, on Linux, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[✓] Android Studio (version 3.5)
[✓] Connected device (3 available)
• No issues found!
and failed with same error, and i'm wondered that gallery has many errors on master channel!
Interesting, could you provide some more context around what you're trying to accomplish?
Additionally, I've found that running flutter pub get from within the main flutter repo directory under packages/flutter can help.
cc @shihaohong who worked on the gen_l10n tool
I want to use this command in my own project to convert .arb files to .xml files for translation consumption, but I have same issue. It's not necessary and I'll be waiting for @shihaohong 's response. Thank you.
@aliyazdi75 Hi, could you provide some more context with the issue you're facing? Are you running into this issue with just your own project, or with the gallery as well?
From the error message shared in the first comment, it seems like the flutter repo's dependencies are not available to you, so try running flutter update-packages in the flutter/flutter repo.
Hey @shihaohong , thanks for your response.
flutter update-packages in ~/flutter/packages/flutter fixed this problem.
I really appreciate that for this tool.
No problem! I'm glad you resolved the issue :)
Hello again @shihaohong
After upgrading flutter under master seems intl_en.arb is must, cause of
flutter pub run grinder l10n
->
fatal: Arb file for a fallback, en, does not exist, even though
the following locale(s) exist: [en_AU, en_CA, en_GB, en_IE, en_IN, en_NZ, en_SG, en_US, en_ZA].
When locales specify a script code or country code, a
base locale (without the script code or country code) should
exist as the fallback. Please create a {fileName}_en.arb
file.
and have to implement all translation phrase for all supported languages.
Hi @aliyazdi75, this is a new requirement since we would like developers to support fallbacks for their languages. For example, if en_AU was selected on your device, but you did not have a set of translations for en_AU, your app would automatically default to en.
Also, please file an issue through flutter/flutter in the future instead of revisiting this one, since this tool is being developed there and not as part of the flutter gallery. If there is an issue in the gallery, you might want to create a new issue as well since this is unrelated to the original issue.
I want to make sure we're keeping the issue tracking clean between the projects and make sure only the right people are notified of these issues :) Thank you!
Thanks for your response. @shihaohong
I did fix this, but a huge problem is for example if you did not implement fa translation you can't compile program cause of LocalizationsFa extends Localizations and must implement all translation under this class.
Is this right?
If this is right I will provide an issue under flutter/flutter.
Yes, that is correct, and is expected behavior unless I'm misunderstanding. Please file an issue under flutter/flutter if there is a problem!
Thanks for your time, I've created an issue in flutter repository in this link.
@aliyazdi75 Hi, could you provide some more context with the issue you're facing? Are you running into this issue with just your own project, or with the gallery as well?
From the error message shared in the first comment, it seems like the flutter repo's dependencies are not available to you, so try running
flutter update-packagesin theflutter/flutterrepo.
It helped me resovle the same error. thanks for the help