使用 IBTools 批量本地化?

发布于 2024-11-03 20:28:54 字数 143 浏览 0 评论 0原文

有没有办法使用单个命令在一堆 NIB 文件上运行 IBTools?我正在尝试从 NIB 中提取字符串。我应该为每个 NIB 运行一次 ibtools 吗?

我发现多次运行 IBTools 很乏味。 (我只有 9 个 NIB 文件。情况可能更糟......)

Is there a way to run IBTools on a bunch of NIB files with a single command? I'm trying to extract strings from NIBs. Am I supposed to run ibtools once for each NIB?

I find it tedious to run IBTools so many times. (I have only 9 NIB files. It could be worse...)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

云雾 2024-11-10 20:28:54

我不认为 ibtool 可以将多个文件作为参数。我看到的唯一方法是编写一个 bash 脚本来执行此任务。

#!/bin/bash

find . -name "*.xib" | while read FILENAME;
do
  ibtool --export-strings-file $FILENAME.strings $FILENAME
done

I don't think ibtool can take multiple files as argument. The only way I see would be to write a bash script to perform this task.

#!/bin/bash

find . -name "*.xib" | while read FILENAME;
do
  ibtool --export-strings-file $FILENAME.strings $FILENAME
done
五里雾 2024-11-10 20:28:54

这是我为相同操作制作的功能更齐全的脚本:

#!/bin/bash
# Argument = -o output_dir -i input_dir

usage()
{
cat << EOF
usage: $0 [options]

This script generates strings files from all xibs in a given directory.

OPTIONS:
   -h      Show this message
   -i      Input directory where XIBs are located [./]
   -o      Output directory where .strings files will be generated
EOF
}

INPUT_DIRECTORY="."
OUTPUT_DIRECTORY="."

while getopts “hi:o:” OPTION
do
     case $OPTION in
         h)
             usage
             exit 1
             ;;
         i)
             INPUT_DIRECTORY=$OPTARG
             ;;
         o)
             OUTPUT_DIRECTORY=$OPTARG
             ;;
         ?)
             usage
             exit
             ;;
     esac
done

if [[ -z $INPUT_DIRECTORY ]] || [[ -z $OUTPUT_DIRECTORY ]]
then
     usage
     exit 1
fi

# do the generation

find $INPUT_DIRECTORY -name "*.xib" | while read FILENAME;
do
  XIBNAME=$(basename "$FILENAME")
  XIBNAME="${XIBNAME%.*}"
  ibtool --generate-strings-file $OUTPUT_DIRECTORY/$XIBNAME.strings $FILENAME
done

Here is a much more full featured script I made to use for the same operation:

#!/bin/bash
# Argument = -o output_dir -i input_dir

usage()
{
cat << EOF
usage: $0 [options]

This script generates strings files from all xibs in a given directory.

OPTIONS:
   -h      Show this message
   -i      Input directory where XIBs are located [./]
   -o      Output directory where .strings files will be generated
EOF
}

INPUT_DIRECTORY="."
OUTPUT_DIRECTORY="."

while getopts “hi:o:” OPTION
do
     case $OPTION in
         h)
             usage
             exit 1
             ;;
         i)
             INPUT_DIRECTORY=$OPTARG
             ;;
         o)
             OUTPUT_DIRECTORY=$OPTARG
             ;;
         ?)
             usage
             exit
             ;;
     esac
done

if [[ -z $INPUT_DIRECTORY ]] || [[ -z $OUTPUT_DIRECTORY ]]
then
     usage
     exit 1
fi

# do the generation

find $INPUT_DIRECTORY -name "*.xib" | while read FILENAME;
do
  XIBNAME=$(basename "$FILENAME")
  XIBNAME="${XIBNAME%.*}"
  ibtool --generate-strings-file $OUTPUT_DIRECTORY/$XIBNAME.strings $FILENAME
done
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文