Skip to content

Add parallel option #733

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

aergonaut
Copy link

PR Checklist

PR Structure

  • This PR has reasonably narrow scope (if not, break it down into smaller
    PRs).
  • This PR avoids mixing refactoring changes with feature changes (split into
    two PRs otherwise).
  • This PR's title starts is concise and descriptive.

Thoroughness

  • This PR adds tests for the most critical parts of the new functionality or
    fixes.
  • I've updated any docs, .md files, etc… affected by this change.

What

This PR adds a parallel option to I18nJs.call, which is passed to the export_group method. When parallel: true and the group uses :locale placeholder, export_group will use concurrent-ruby's Promise to parallelize exporting each file.

I have included a benchmark script in this PR which compares the time needed to export 100 locale files with 5_000 strings each. Here are some example results:

❯ ruby test/benchmarks/parallel_export.rb
              user     system      total        real
baseline  4.199457   0.144715   4.344172 (  4.376356)
parallel  1.999492   0.071311   2.070803 (  2.064344)

Parallelization makes the process takes about 50% less time.

Why

In an app with many strings and many locales, exporting can take a significant amount of time, because each locale is exported sequentially. This slows down the feedback loop, making developers wait longer to see the effects of a change.

Known limitations

[TODO or N/A]

@aergonaut aergonaut requested a review from fnando as a code owner March 24, 2025 03:39
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

Successfully merging this pull request may close these issues.

1 participant