-
Notifications
You must be signed in to change notification settings - Fork 545
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
sortByReference
inverted (and incorrect) when using DTCG standard
#1305
Comments
Oof that's not good, definitely seems like a bug, will take a look |
Hey, any news here? I may be running into the same issue. Also this example suggest to use
Nevermind, I was actually having another issue and passing unfilteredTokens solved it: Just if someone runs into this issue when updating, I replace getReferences(refString, dictionary.tokens) with getReferences(refString, dictionary.tokens, {unfilteredTokens: dictionary.unfilteredTokens}) |
@jorenbroekema do we just need to make sure to use
But it seems like the function does not have access to the |
@lukasoppermann yeah that definitely needs to use We should add the PR welcome! |
Unfortunately ran into the same issue. I submitted a PR that should fix it for now 🫡 That being said, I feel like it might be considerable to refactor the way the usesDtcg option is used across the codebase in a whole. Right now, it's repeated a lot througout the project like: usesDtcg ? '$value' : 'value'
// or
usesDtcg ? '$type' : 'type' It actually appears to be only used this way. There are small inconsistencies in how it's written exactly, which makes it a bit harder to track. I was thinking a utility function could help standardize this. I'm not that familiar with the codebase yet, as I didn't have tooooo much time to browse through everything, so I might be missing things here! Would love to get your feedback though 😊 |
Hey @timges yeah you're right, it's a bit of a code smell to repeat that ternary operator everywhere in the codebase. I think, in hindsight, that it would have been better to just introduce a built-in processing step that always converts any dictionary to DTCG syntax no matter what. That way, we always only check for $value/$type/$description. We may even be able to do this in a non-breaking change in v4. I'm gonna create an issue for this at least because it would certainly clean up the code by a lot and prevent us needing to do a bunch of DTCG syntax integration tests, we only do that in a limited amount of tests, so DTCG syntax test coverage just really isn't great right now. Edit: Actually, this would always be a breaking change because in custom hooks that folks register, they'd get the tokens in DTCG format always, so it breaks the hooks for folks that still only use the old syntax. So this'll be a v5 improvement then.. |
100% agree with you @jorenbroekema! Thanks for the feedback 🙏 I'd definitely go for a full switch from the current standard to DTCG syntax at some point. As you mentioned, since it's a breaking change anyway, it might be best to just drop support for the old standard with v5. Test situation is a little concerning, tbh. The only other integration test suite that covers DTCG syntax seems to be Perhaps we could eliminate the |
Actually there are a couple of other places where we also have a test that's for DTCG syntax but you'd have to search for them to find them in the regular test files.
I'm pretty sure that's what I went with the first time I tried to add forward compatibility with DTCG syntax but there were some issues with this approach, I don't remember exactly from the top of my head but it was something along the lines of:
I'm not sure if it would improve test coverage either because the main reason we have these minor bugs when not taking account DTCG format is because we access |
That makes a lot of sense! Dang it. Guess we reallly have to wait for v5 then, to properly improve here. Anyways - thanks for the awesome exchange! 😊 |
v3 format:
Expected output,
$colors-red
is referenced after it is declared:Change to DTCG format:
Incorrect output,
$colors-red
is referenced before it is declared.The text was updated successfully, but these errors were encountered: