Open oleksii-leonov opened 1 year ago
Even better would be to keep the order specified in the configuration file.
For example, the next configuration should run plugins in the specified order (filter_procs
, embed_fallback_translations
, sort_keys
):
# config/i18n.yml
translations:
- file: "app/packs/locales/generated/:locale.json"
patterns:
- '*'
filter_procs:
enabled: true
embed_fallback_translations:
enabled: true
sort_keys:
enabled: true
# NOTE: Register plugins in a specific order: # 1. Filter; 2. Fallbacks; 3. Sort.
I think you're onto something. Maybe we should categorize plugins, based on 4 behaviours:
I think the implicit aspect of trusting the config order is too brittle.
So, maybe the plugin method names should match something like that, because then it wouldn't be an issue.
class I18nJS::Plugin
def validate_schema; end
def setup; end
def filter(translations:); end
def fallbacks(translations:); end
def sort(translations:); end
def output(files:); end
end
If not that, then I think the configuration should have something like plugin_order: []
, which by default is set as the stack of plugins as they're registered.
Description
Now there is no built-in mechanism to specify an order of plugins. Sometimes, you need to run plugins in a specific order.
For example, I have made a custom
rake
task to register plugins in a specific order:Describe the solution
It would be nice to be able to specify
run_before
andrun_after
in the configuration file. For example:Alternatives you considered
Custom script or
rake
task to register plugins in a specific order.