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

Expose the file loader #51

Open
jonasraoni opened this issue Nov 29, 2021 · 1 comment
Open

Expose the file loader #51

jonasraoni opened this issue Nov 29, 2021 · 1 comment

Comments

@jonasraoni
Copy link

Hi! Thanks for the library, it has been pretty useful.

I just have one question... Would it be possible to "expose" the json file loader? I'd like to overwrite it and return my custom object.

Use case: I wrote a translation driver to make better use of the opcache, but I can't do the same for the json files.


Other issues that I had:

  1. The default translation driver doesn't work for me: I tried to load data from different locales, but it was just returning data in en_US (I didn't inspect much as I can't use the gettext extension anyway).
  2. SymfonyTranslationDriver: as I consume different data, it keeps growing in memory, it would be nice to have a setting to discard it.
  3. SymfonyTranslationDriver: when I try to load inexistent translations, it throws an InvalidArgumentException (so I had to fallback to the DummyDriver), that's ok! But the default driver doesn't throw, so it would be good to have the same behavior and maybe a setting to retrieve a default value (en_US).
@sokil
Copy link
Owner

sokil commented Dec 1, 2021

Would it be possible to "expose" the json file loader?
May you explain what do you want to do with this json loader?

There is maybe a reason to convert original debian's json files to php files on release to use opcache, so no loader will be required.

The default translation driver doesn't work for me: I tried to load data from different locales, but it was just returning data in en_US (I didn't inspect much as I can't use the gettext extension anyway).

Gettext driver trust you system locale is valid. If you use some framework with localization, it may not change system locale, just it's internal configuration. But gettext requires valid locale, so you may use \Sokil\IsoCodes\TranslationDriver\TranslationDriverInterface::setLocale manually.

SymfonyTranslationDriver: as I consume different data, it keeps growing in memory, it would be nice to have a setting to discard it.

All drivers configured manually when created \Sokil\IsoCodes\IsoCodesFactory, If you do not configure it, it will not load.

SymfonyTranslationDriver: when I try to load inexistent translations, it throws an InvalidArgumentException

Yes, behavior must be same.

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

No branches or pull requests

2 participants