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

How to structure translations in library and applications #109

Open
MarcVanDaele90 opened this issue Mar 17, 2022 · 2 comments
Open

How to structure translations in library and applications #109

MarcVanDaele90 opened this issue Mar 17, 2022 · 2 comments
Labels
third-party feature This feature was contributed by someone else and depends on the contributor to respond/fix

Comments

@MarcVanDaele90
Copy link

I have both a library project/package which has some translations and an application (using this library) that also has translations.
The directory structure looks roughly like this

  • Library/
    • lib/
    • assets/locales/*.po
  • App/
    • lib/main.dart
    • assets/locales/*.po

Both the library project and the app project have a

  static Future<void> loadTranslations() async {
    translations +=
    await GettextImporter().fromAssetDirectory("assets/locales");
    print("i18n: translation = $translations");
  }

but when calling the loadTranslations of the Library, it seems to read the *.po files from the assets/locales directory of the App.
How can I indicate hat it should read from the "assets/locales" directory of the library project?

Do you have a fix for my setup or suggestions on how to improve my setup?
For example, is it somehow possible to indicate the package when loading assets? Similar to Image.asset() which has a package property.
Also loading GettextImporter().fromAssetDirectory("packages/<library package name>/assets/locales"); seems to have no effect

@MarcVanDaele90
Copy link
Author

MarcVanDaele90 commented Mar 17, 2022

Sorry, using GettextImporter().fromAssetDirectory("packages/<library package name>/assets/locales") does work.
If you happen to have suggestions to improve my setup/structure, please let me know. Otherwise, feel free to close this issue.

@marcglasberg
Copy link
Owner

The gettext importer is contributed by @bauerj
Maybe he can help you.

@marcglasberg marcglasberg added the third-party feature This feature was contributed by someone else and depends on the contributor to respond/fix label Nov 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
third-party feature This feature was contributed by someone else and depends on the contributor to respond/fix
Projects
None yet
Development

No branches or pull requests

2 participants