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

exclude translations from libraries #135

Closed
koenhandekyn opened this issue Aug 16, 2019 · 5 comments
Closed

exclude translations from libraries #135

koenhandekyn opened this issue Aug 16, 2019 · 5 comments

Comments

@koenhandekyn
Copy link

koenhandekyn commented Aug 16, 2019

is there a way to exclude translations from gems, currently the tool also imports translations from devise-i18n, active_admin, etc if these are in the project ...

after some analysis, i'm concluding that LIT is using the i18n load path, which is extended by some gems. i think the proposal would be to have an option in LIT to 'discard' the i18n loadpath, or have a configurable load path.

@mlitwiniuk
Copy link
Member

@koenhandekyn you can define array of key prefixes in config/initializers/lit.rb:

Lit.ignored_keys = %w[active_admin simple_form formtastic]

@koenhandekyn
Copy link
Author

koenhandekyn commented Aug 19, 2019

some feedback

  • managed to get it working on my local machine after digging through the code. the issue i was fighting was that ignored keys kept appearing but it seemed it was related to the fact that keys where still present in the redis cache. redis-cli with a flush_all command was the trick.

  • i've then done the same for our staging server on HEROKU, added line with ignored_keys, cleared redis cache with $redis.flush_all, and deleted the keys from the database, but on HEROKU the keys keep reappearing when the app is restarted. i'm still touching in the dark about this.

     $redis.flushall
     Lit::LocalizationKey.where("localization_key LIKE 'active_admin%'").destroy_all
     Lit::LocalizationKey.where("localization_key LIKE 'formtastic%'").destroy_all

maybe i'm still doing something wrong, but feels a bit unintuitive that the ignored_keys setting is ignored for keys that still are in the cache. maybe the if statement can be written differently? i'm not doing a PR because i haven't figured out the intent of the current logic fully :)

ps: further, ignoring keys is a good workaround for now, but because some gems don't namespace their translations nicely (or they follow the standard and have keys in a common global namespace), it still feels an interesting extension to be able to play with the load-path.

@mlitwiniuk mlitwiniuk reopened this Aug 19, 2019
@mlitwiniuk
Copy link
Member

@koenhandekyn for future reference: Lit.init.cache.reset should do the trick next time

@koenhandekyn
Copy link
Author

you probably noticed the wiki addition on this topics at https://github.com/prograils/lit/wiki/Advanced-configuration - feel free to ammend ;)

@koenhandekyn
Copy link
Author

confirming that Lit.init.cache.reset seems to do the job on HEROKU

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

2 participants