Improve localized string parsing to fix some bugs, and add more complex test cases.