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

Sort language source files by name for consistent mapLocales order #722

Open
akwls opened this issue Nov 6, 2024 · 0 comments
Open

Sort language source files by name for consistent mapLocales order #722

akwls opened this issue Nov 6, 2024 · 0 comments

Comments

@akwls
Copy link

akwls commented Nov 6, 2024

I'm using easy_localization:generate in my company's Flutter app.

Recently, I added some code to our GitHub workflow to check if developers have run the easy_localization:generate command after adding or editing localization strings.

The workflow runs:

dart run easy_localization:generate -S assets/translations
dart run easy_localization:generate -S assets/translations -f keys -o locale_keys.g.dart

After that, the workflow fails if there are any code changes.

The problem is that codegen_loader.g.dart differs from the base code when the workflow is executed. The reason for this failure is that the order of the mapLocales variable in codegen_loader.g.dart is inconsistent.

For example:

Base code: {"en": en, "ko": ko}
GitHub workflow result: {"ko": ko, "en": en}

I believe this happens because, when the asset file list is retrieved from the directory, the order of files is not guaranteed. Therefore, I suggest sorting the file list based on the file names to ensure consistency

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

No branches or pull requests

1 participant