How does incremental localization work?

前端 未结 2 411
北海茫月
北海茫月 2020-12-28 11:44

I\'m trying to build my first localized application. I have all the strings in code translated using NSLocalizedString (for use with genstrings tool). Now I\'m

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-28 12:17

    I wrote a script for git projects which automates the steps necessary (as described in the answer above) to migrate a change to a different language.

    Usage:

    migrate_changes.sh  
    

    Example:

    After you've committed your changes to the english xib file, run the script at the root of your resource folder.

    migrate_changes.sh de MyViewController
    

    Source:

    #!/bin/sh
    
    LANG_FROM='en'
    LANG_TO=$1
    XIB_FILE=$2
    
    FROM_FILE=${LANG_FROM}.lproj/${XIB_FILE}.xib
    PREV_FILE=${LANG_FROM}.lproj/${XIB_FILE}_old.xib
    TO_FILE=${LANG_TO}.lproj/${XIB_FILE}.xib
    
    # checkout old version of xib file
    git show `git log -2 --format="%H" $FROM_FILE | tail -n 1`:./$FROM_FILE > $PREV_FILE
    
    # merge changes
    ibtool --previous-file $PREV_FILE --incremental-file $TO_FILE --localize-incremental --write $TO_FILE $FROM_FILE
    
    # remove previous version
    rm $PREV_FILE
    

提交回复
热议问题