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

后端 未结 3 1290
误落风尘
误落风尘 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: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

提交回复
热议问题