How to find duplicate keys in localizable.strings files automatically?

后端 未结 3 1279
误落风尘
误落风尘 2021-02-04 10:41

When using localizable.strings with many entries in your XCode project you sooner or later may use a key more than once. Is it possible to let XCode find that case and issue a w

相关标签:
3条回答
  • 2021-02-04 11:01
    more Filename.strings | tr -d ' ' | sort | uniq -d | grep -v '^$'
    
    0 讨论(0)
  • 2021-02-04 11:07

    cut -d' ' -f1 Localizable.strings | sort | uniq -c

    type this command in the terminal and you get a list saying how often each key is used.

    use -d instead of -c and you only get duplicates

    the script:

    #!/bin/bash
    
    c=`expr $SCRIPT_INPUT_FILE_COUNT - 1`
    for i in $(seq 0 $c)
        do
    
        var="SCRIPT_INPUT_FILE_$i"
        FILENAME=${!var}
    
        DUPES=`cut -d' ' -f1 "$FILENAME" | sort | uniq -d`
    
        while read -r line; do
            if [[ $line == "\""* ]] ;
            then
                echo "warning: $line used multiple times -"
            fi
        done <<< "$DUPES"
    done
    

    screenshot

    0 讨论(0)
  • 2021-02-04 11:18

    cut -d'=' -f1 Localizable.strings | sort | uniq -d

    You looking phrases separated by equal sign, not a first word in each string.

    0 讨论(0)
提交回复
热议问题