lingo.dev icon indicating copy to clipboard operation
lingo.dev copied to clipboard

Respect existing i18n.json formatting to avoid unnecessary PRs

Open maxprilutskiy opened this issue 1 year ago • 3 comments

What

Our CLI's JSON serializer, that handles reads/writes of the i18n.json, overwrites i18n.json with a default format, ignoring existing formatting from tools like Prettier, that user's repo might have.

This triggers useless PRs with only format changes when used with GitHub Actions. Example: https://github.com/calcom/cal.com/pull/16505/files

Originally, we fixed that in #195 by not rewriting i18n.json when there's no meaningful changes made in it. However, the update still happens when @lingodotdev team upgrades the i18n.json structure design, and that breaks the formatting.

Replexica CLI must respect the style guide of the user's repo.

Why

  • Prevents noise in PRs and commit history
  • Respects user's existing code style choices
  • Improves compatibility with popular formatting tools
  • Reduces confusion and manual work for users

How

  1. Detect existing formatting in i18n.json (indentation, quote style, etc.)
  2. Update our JSON serializer to preserve detected formatting
  3. If no clear format is detected, fall back to our default
  4. Test with popular formatting tools (Prettier, EditorConfig, etc.)
  5. Update docs to mention this behavior

maxprilutskiy avatar Sep 05 '24 16:09 maxprilutskiy

hey, I would like to work on this issue.

Aditya-A-G avatar Oct 16 '24 02:10 Aditya-A-G

@maxprilutskiy working on it using prettier to resolve the format but the issue is the function is an async one so should I introduce promises to handle if it's okay with the project?

partik03 avatar Oct 30 '24 14:10 partik03

This would be great if it could be fixed, We use prettier, and i suspect most in the js ecossystem do.

kapir avatar Mar 04 '25 09:03 kapir