-
Notifications
You must be signed in to change notification settings - Fork 7
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
Add support for multiple package project #23
Comments
This sounds like a great feature for the next version. Can you provide a simple detailed project setup, where the described issue is reproducible? I got a bit confused when trying to declare the assets in the multi package setup. |
I have an example setup at my github: https://github.com/remonh87/multi-package-example-flutter |
So if I get it correctly, you have an |
the generator is declared and run within the ui package |
Awesome! I checked a few configurations to get a bigger picture about the problem. Tomorrow, I will have some time to add the new functionality to the lib. |
Issue #23 Optional `package` attribute added for `Stone` annotation.
As described, v0.1.2 release introduces the |
@agta1991 thanks for picking this up quickly. I did test it with the latest package but still see a small issue in the generated code of the helper: you include the lib folder in the call to rootbundle. This should not be the case when you want to load the asset from a package. Example should become: |
This brings back another problem. The generator should know the path of the json in the builder host's file system during the build phase, but also it must know the package path which will be bundled. As I saw in your example project setup, the i18n folder is under lib. And you declare it as flutter:
assets:
- packages/app_ui/i18n/en.json But if you put it next to lib, and declare it as: flutter:
assets:
- i18n/en.json The compiler will still bundle it as packages/app_ui/i18n/en.json but it will have a matching path "i18n/en.json" with the host system. Is it critical to support mixing the asset files with the source files in lib? |
It is indeed not critical so issue can be closed. |
I used the suggested structure but then the rosetta generator cannot find the file and won't generate the keys: see for example https://github.com/remonh87/multi-package-example-flutter . |
Is your feature request related to a problem? Please describe.
This library really works great and generates a lot of boiler plate code. Unfortunately it works perfect for a single package app but does not support monorepo. For example:
I have a package called app_ui and my translation assets are located in:
lib/app_ui/translations
. In the pubspec.yaml I declare my assets like:packages/app_ui/i18n/en.json
. My main is located in the app_main package.The rosetta generator is able to find my file, can generate the code, but does not generate the proper code for loading the asset. When I start the app it crashes because rootbundle cannot load the translated file.
Describe the solution you'd like
Add support for the package name, for example:
@Stone(path: 'lib/i18n', package: "app_ui") class Translation with _$TranslationHelper { ... }
Based on this the rosetta_generator can generate the following snippet in the translationhelper:
var jsonStr = await rootBundle.loadString("packages/app_ui/i18n/${locale.languageCode}.json");
The text was updated successfully, but these errors were encountered: