Closed
Description
The problem occurs when I am trying to regenerate the i18n files in Flutter's stock example app.
Following the README I run the following command:
flutter pub pub run intl_translation:generate_from_arb --output-dir=lib/i18n --generated-file-prefix=stock_ --no-use-deferred-loading lib/*.dart lib/i18n/stocks_*.arb
On Linux I got:
No @@locale or _locale field found in stocks_en, assuming 'en' based on the file name.
No @@locale or _locale field found in stocks_es, assuming 'es' based on the file name.
I suppose this is the expected output.
But on Windows I got:
Unhandled exception:
FileSystemException: Cannot open file, path = 'lib/*.dart' (OS Error: The filename, directory name, or volume label syntax is incorrect
, errno = 123)
#0 _File.throwIfError (dart:io/file_impl.dart:629)
dart-lang/intl_translation#1 _File.openSync (dart:io/file_impl.dart:473)
dart-lang/intl_translation#2 _File.readAsBytesSync (dart:io/file_impl.dart:533)
dart-lang/intl_translation#3 _File.readAsStringSync (dart:io/file_impl.dart:578)
dart-lang/intl_translation#4 MessageExtraction.parseFile (package:intl_translation/extract_messages.dart:73:28)
dart-lang/intl_translation#5 main.<anonymous closure> (http://localhost:3774/generate_from_arb.dart:97:33)
dart-lang/intl_translation#6 MappedListIterable.elementAt (dart:_internal/iterable.dart:413)
dart-lang/intl_translation#7 ListIterator.moveNext (dart:_internal/iterable.dart:342)
dart-lang/i18n#491 main (http://localhost:3774/generate_from_arb.dart:100:23)
dart-lang/i18n#492 _startIsolate.<anonymous closure> (dart:isolate-patch/dart:isolate/isolate_patch.dart:276)
dart-lang/intl_translation#10 _RawReceivePortImpl._handleMessage (dart:isolate-patch/dart:isolate/isolate_patch.dart:164)
pub finished with exit code 255
Activity
alan-knight commentedon Feb 6, 2018
I think the issue is just that on Windows you should use Windows path separators. e.g. the command should use lib*.dart and lib\i18n\stocks_*.arb
tamcy commentedon Feb 7, 2018
I afraid not. Using backslash results in the same error message:
The command works when no wildcard is used, even with forward slash:
One problem is that passing individual files would not generate a "stock_messages_all.dart" with all discovered locales.
This has been tested in PowerShell and ordinary command prompt.
alan-knight commentedon Feb 7, 2018
OK, it appears that the Windows shell is not expanding the wildcard, so we get a literal "*.dart" as the argument passed in to generate_from_arb.
What is it that doesn't work if you pass the individual files? I don't have easy access to a Windows machine, but passing in all the files explicitly on a Mac generates the files I'd expect.
tamcy commentedon Feb 8, 2018
I think I got you now. I tried to execute the command one by one, passing a single file each time. This way, only the locale found in the last executed command would be kept in main import file
messages_all.dart
.Just discovered that I can indeed pass a list of files to the command line.
I can confirm this works for me:
Thank you very much!
linenlin01 commentedon Mar 20, 2019
run the Command in “Git Bash” could solve the problem
cirediew commentedon Jul 24, 2019
This should be in the docs https://flutter.dev/docs/development/accessibility-and-localization/internationalization#appendix-using-the-dart-intl-tools
willnationsdev commentedon Jan 23, 2020
I agree, this should be in the docs. I ran into this issue while moving through the standard introductory documentation. Having a buggy experience getting essential Flutter functionality running for an app was a big turn off as I was experimenting with the framework.
SlayerOrnstein commentedon Feb 17, 2020
instead of passing a list of files you can call the wildcard by passing this argument instead.
flutter pub pub run intl_translation:generate_from_arb --output-dir=lib/i18n --generated-file-prefix=stock_ --no-use-deferred-loading (Get-ChildItem lib/*.dart) (Get-Childitem lib/i18n/stocks_*.arb)
this worked for me pretty well.
liudonghua123 commentedon Mar 26, 2020
I also got the same issue.
I wish the input files could ignore (all the files in
lib
could be passed as default). And provide platform independent solution. It should not difficult.liudonghua123 commentedon Mar 26, 2020
I tried to add glob path parser support for this lib. see dart-archive/intl_translation#92.