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

Can't generate files #16

Closed
speller opened this issue Mar 24, 2020 · 6 comments · Fixed by #24
Closed

Can't generate files #16

speller opened this issue Mar 24, 2020 · 6 comments · Fixed by #24

Comments

@speller
Copy link

speller commented Mar 24, 2020

When I'm running the command I'm getting the following error:

C:\develop\projects\helpdesk\app\helpdesk>flutter pub run flappy_translator
[PROGRESS] 1 words recognized

Unhandled exception:
RangeError (index): Invalid value: Valid value range is empty: 0
#0      List.[] (dart:core-patch/growable_array.dart:149:60)
#1      FlappyTranslator.generate (package:flappy_translator/flappy_translator.dart:113:39)
#2      main (file:///c:/develop/soft/flutter/.pub-cache/hosted/pub.dartlang.org/flappy_translator-1.2.2/bin/flappy_translator.dart:58:20)
#3      _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:305:32)
#4      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:174:12)
pub finished with exit code 255

Settings are placed in the pubspec.yaml file and are default from the readme page. What I'm doing wrong?

@defuncart
Copy link
Collaborator

@speller I would suspect that there is an issue with the CSV file. Could you post an example?

@speller
Copy link
Author

speller commented Jul 6, 2020

@defuncart You're right, I had wrong delimiters in the config. Now my config looks like this:

flappy_translator:
  input_file_path: "localization/localization.csv"
  output_dir: "lib"
  file_name: "i18n"
  class_name: "I18n"
  delimiter: ";"
  start_index: 1
  depend_on_context: true
  use_single_quotes: false
  replace_no_break_spaces: false

The CSV file is:

keys;en;jp
main-page;Main Page;Main Page

The output is:

>flutter pub run flappy_translator
[PROGRESS] 1 words recognized

Unhandled exception:
Could not format because the source could not be parsed:

line 8, column 19: Unexpected text 'page'.
  ╷
8 │   String get main-page => _getText("main-page");
  │                   ^^^^
  ╵
line 8, column 18: A function body must be provided.
  ╷
8 │   String get main-page => _getText("main-page");
  │                  ^
  ╵
line 8, column 18: Methods must have an explicit list of parameters.
  ╷
8 │   String get main-page => _getText("main-page");
  │                  ^
  ╵
line 8, column 18: Operator declarations must be preceded by the keyword 'operator'.
  ╷
8 │   String get main-page => _getText("main-page");
  │                  ^
  ╵
#0      DartFormatter.formatSource (package:dart_style/src/dart_formatter.dart:142:7)
#1      DartFormatter.format (package:dart_style/src/dart_formatter.dart:74:12)
#2      FlappyTranslator._writeInFile (package:flappy_translator/flappy_translator.dart:153:32)
#3      FlappyTranslator.generate (package:flappy_translator/flappy_translator.dart:146:5)
#4      main (file:///c:/develop/soft/flutter/.pub-cache/hosted/pub.dartlang.org/flappy_translator-1.2.2/bin/flappy_translator.dart:58:20)
#5      _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:299:32)
#6      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)
pub finished with exit code 255

@speller
Copy link
Author

speller commented Jul 7, 2020

Ah, hyphen. I guess it's good to add a check on that.

@defuncart
Copy link
Collaborator

@speller Good point, let me put together a quick solution.

@defuncart
Copy link
Collaborator

@speller Please let me know if #24 fixes your issue.

@speller
Copy link
Author

speller commented Jul 8, 2020

Can't try it right now, but looks like exactly what I suggested, thanks.

Also, if you would be able to add a check of the delimiter (suggest to fix it if it's wrong) that also will be useful for users, I think.

defuncart added a commit that referenced this issue Aug 23, 2020
Adds a check to ensure variable names are correct. Resolves #16.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants