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

Merging keys - possible? Desirable? #105

Open
phantomwhale opened this issue Jun 27, 2023 · 1 comment
Open

Merging keys - possible? Desirable? #105

phantomwhale opened this issue Jun 27, 2023 · 1 comment

Comments

@phantomwhale
Copy link

I had an interesting use case, where I needed to merge 8-9 locale files in a rails app into a single app.

Easily done, I thought, and quickly concatenated all the files, and then ran yalphabetize -a over the final file.

And sadly noted that each of the files stayed in it's own en: block... ah well, I deleted all of the YAML heading lines, and ran it again, but still ended up with:

en:
  activerecord:
    attributes:
      something_from_one_file:
  activerecord:
    attributes:
      something_from_another_file:

Rather than the desired outcome of:

en:
  activerecord:
    attributes:
      something_from_one_file:
      something_from_another_file:

Is there a flag / option (or previous attempt?) of allowing "key merging" during the yalphabetize run?

I guess you ideally don't want the operation to ever be "lossy", meaning you'd not want two identically named YAML nodes with actual values (string or array) to clobber each other, and I'll admit I'm firing this idea out without really having a solid grasp on the underlying YAML data model to know if these two scenarios are easily identified when parsing files.

What are the thoughts around this? Possible? Or fraught with peril? Worth even looking into?

@samrjenkins
Copy link
Owner

@phantomwhale thanks for this. I will get back to you ASAP once I get a moment to think!

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