g-Off / stringray

macOS command line tool for manipulating and validating  strings files
MIT License
6 stars 1 forks source link

Support String Dict files with `NSStringVariableWidthRuleType` #4

Open kudalies opened 5 years ago

kudalies commented 5 years ago

Support .stringdict files with string rule type: NSStringVariableWidthRuleType

See the example below which doesn't load during lint operation.

?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CLAM_CHOWDER</key>
    <dict>
        <key>NSStringVariableWidthRuleType</key>
        <dict>
            <key>1</key>
            <string>Clam Chowder</string>
            <key>25</key>
            <string>New England Clam Chowder</string>
        </dict>
    </dict>
    <key>CHICKEN_NOODLE_SOUP</key>
    <dict>
        <key>NSStringVariableWidthRuleType</key>
        <dict>
            <key>1</key>
            <string>Chicken Noodle</string>
            <key>25</key>
            <string>Chicken Noodle Soup</string>
        </dict>
    </dict>
</dict>
</plist>
kudalies commented 5 years ago

After more research on this NSStringVariableWidthRuleType in conjunction with the pluralization string format; They do not operate together on the same key, NSStringLocalizedFormatKey always takes precedence and will be processed instead of NSStringVariableWidthRuleType if both are present.

Therefore a stringsdictentry can be either a pluralization format string or a variable width string.

Thinking the best solution for this is to provide a model that combines these two types together. In the meantime, we can maybe just ignore NSStringVariableWidthRuleType entries until we can support both.

kudalies commented 5 years ago

Only apple dev doc on stringsdict https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPInternational/StringsdictFileFormat/StringsdictFileFormat.html

It's old and outdated, and there is a related rdar for updating this doc: http://openradar.appspot.com/38627216