Closed jayrhynas closed 3 years ago
I briefly investigated using PropertyListSerialization
to parse the .strings
files as it handles the comments correctly and parses in the same way Xcode does, however I wasn't able to find a way to maintain the line numbers in the parsed result. It may still be worth exploring this and trying to match up the line numbers after parsing, though (parse with PropertyListSerialization
, then use a regex such as "\(key)" *=
to find the matching line number).
This looks awesome, and thanks for your suggestions. In theory, @russellblickhan will look at this.
I've added some tests, they should showcase the different cases handled by this PR.
Currently, locheck will ignore lines in .strings files that contain comments. It will also ignore lines if there is not exactly one space character before and after the
=
character in the line. These forms are however considered valid by Xcode and should not be ignored.This PR extends
stringPairRegex
to match and ignore comments at the beginning and end of lines, and adjusts the regex to match*= *
instead of=
.Currently, the regex still does not handle multi-line block comments that begin or end on the same line as a valid key-value pair. I'm undecided if we should just allow unbalanced
*/
or/*
patterns at the beginning or end of a line, respectively, or if a broader multi-line parser would be more appropriate.