Skip to content

intl_translation:generate_from_arb with wildcard argument doesn't work on Windows #496

Closed
@tamcy

Description

@tamcy

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

alan-knight commented on Feb 6, 2018

@alan-knight
Contributor

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

tamcy commented on Feb 7, 2018

@tamcy
Author

I afraid not. Using backslash results in the same error message:

C:\flutter\examples\stocks>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
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:12993/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:12993/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

The command works when no wildcard is used, even with forward slash:

C:\flutter\examples\stocks>flutter pub pub run intl_translation:generate_from_arb --output-dir=lib/i18n --generated-file-prefix=stock_ --no-use-deferred-loading lib/stock_strings.dart lib/i18n/stocks_en.arb
No @@locale or _locale field found in stocks_en, assuming 'en' based on the file name.

C:\flutter\examples\stocks>flutter pub pub run intl_translation:generate_from_arb --output-dir=lib/i18n --generated-file-prefix=stock_ --no-use-deferred-loading lib/stock_strings.dart lib/i18n/stocks_es.arb
No @@locale or _locale field found in stocks_es, assuming 'es' based on the file name.

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

alan-knight commented on Feb 7, 2018

@alan-knight
Contributor

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

tamcy commented on Feb 8, 2018

@tamcy
Author

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:

flutter pub pub run intl_translation:generate_from_arb --output-dir=lib/i18n --generated-file-prefix=stock_ --no-use-deferred-loading lib/stock_strings.dart lib/i18n/stocks_es.arb lib/i18n/stocks_en.arb

Thank you very much!

linenlin01

linenlin01 commented on Mar 20, 2019

@linenlin01

run the Command in “Git Bash” could solve the problem

cirediew

cirediew commented on Jul 24, 2019

@cirediew

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:

flutter pub pub run intl_translation:generate_from_arb --output-dir=lib/i18n --generated-file-prefix=stock_ --no-use-deferred-loading lib/stock_strings.dart lib/i18n/stocks_es.arb lib/i18n/stocks_en.arb

Thank you very much!

This should be in the docs https://flutter.dev/docs/development/accessibility-and-localization/internationalization#appendix-using-the-dart-intl-tools

willnationsdev

willnationsdev commented on Jan 23, 2020

@willnationsdev

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

SlayerOrnstein commented on Feb 17, 2020

@SlayerOrnstein

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

liudonghua123 commented on Mar 26, 2020

@liudonghua123

I also got the same issue.

Microsoft Windows [Version 10.0.18363.720]
(c) 2019 Microsoft Corporation. All rights reserved.

D:\code\flutter\colorful_classroom_app>flutter pub pub run intl_translation:generate_from_arb --output-dir=lib/l10n --no-use-deferred-loading lib/localization.dart 
lib/app.dart lib/l10n/intl_*.arb
Unhandled exception:
FileSystemException: Cannot open file, path = 'lib/l10n/intl_*.arb' (OS Error: The filename, directory name, or volume label syntax is incorrect.
, errno = 123)
#0      _File.throwIfError (dart:io/file_impl.dart:645:7)
dart-lang/intl_translation#1      _File.openSync (dart:io/file_impl.dart:489:5)
dart-lang/intl_translation#2      _File.readAsBytesSync (dart:io/file_impl.dart:549:18)
dart-lang/intl_translation#3      _File.readAsStringSync (dart:io/file_impl.dart:594:18)
dart-lang/intl_translation#4      loadData (file:///D:/apps/flutter/.pub-cache/hosted/pub.flutter-io.cn/intl_translation-0.17.9/bin/generate_from_arb.dart:141:18)
dart-lang/intl_translation#5      main (file:///D:/apps/flutter/.pub-cache/hosted/pub.flutter-io.cn/intl_translation-0.17.9/bin/generate_from_arb.dart:126:5)
dart-lang/intl_translation#6      _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:299:32)
dart-lang/intl_translation#7      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)
pub finished with exit code 255

D:\code\flutter\colorful_classroom_app>dir lib/l10n
Parameter format not correct - "l10n".

D:\code\flutter\colorful_classroom_app>dir lib\l10n
 Volume in drive D is Data
 Volume Serial Number is 08F2-7D08

 Directory of D:\code\flutter\colorful_classroom_app\lib\l10n

2020-03-25  22:50    <DIR>          .
2020-03-25  22:50    <DIR>          ..
2020-03-25  22:50               122 intl_en.arb
2020-03-25  22:45               196 intl_messages.arb
2020-03-25  22:50               116 intl_zh.arb
2020-03-25  22:50             2,372 messages_all.dart
2020-03-25  22:50             1,054 messages_en.dart
2020-03-25  22:50             1,066 messages_messages.dart
2020-03-25  22:50             1,048 messages_zh.dart
               7 File(s)          5,974 bytes
               2 Dir(s)  30,245,486,592 bytes free

D:\code\flutter\colorful_classroom_app>flutter pub pub run intl_translation:generate_from_arb --output-dir=lib/l10n --no-use-deferred-loading lib/localization.dart 
lib/app.dart lib\l10n\intl_*.arb
Unhandled exception:
FileSystemException: Cannot open file, path = 'lib\l10n\intl_*.arb' (OS Error: The filename, directory name, or volume label syntax is incorrect.
, errno = 123)
#0      _File.throwIfError (dart:io/file_impl.dart:645:7)
dart-lang/intl_translation#1      _File.openSync (dart:io/file_impl.dart:489:5)
dart-lang/intl_translation#2      _File.readAsBytesSync (dart:io/file_impl.dart:549:18)
dart-lang/intl_translation#3      _File.readAsStringSync (dart:io/file_impl.dart:594:18)
dart-lang/intl_translation#4      loadData (file:///D:/apps/flutter/.pub-cache/hosted/pub.flutter-io.cn/intl_translation-0.17.9/bin/generate_from_arb.dart:141:18)
dart-lang/intl_translation#5      main (file:///D:/apps/flutter/.pub-cache/hosted/pub.flutter-io.cn/intl_translation-0.17.9/bin/generate_from_arb.dart:126:5)
dart-lang/intl_translation#6      _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:299:32)
dart-lang/intl_translation#7      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)
pub finished with exit code 255

D:\code\flutter\colorful_classroom_app>

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

liudonghua123 commented on Mar 26, 2020

@liudonghua123

I tried to add glob path parser support for this lib. see dart-archive/intl_translation#92.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @tamcy@liudonghua123@alan-knight@SlayerOrnstein@cirediew

        Issue actions

          intl_translation:generate_from_arb with wildcard argument doesn't work on Windows · Issue #496 · dart-lang/i18n