If you open Terminal, cd
into the directory that contains these files, I find this to be the best to find those files:
find . -type f -name "*.m*" -print
This finds everything within the current .
directory that is a file -type f
that has a name of *.m
, *.mm
, *.mmmmm
, and so on (the *.m*
). You then output each resulting file -print
to the console (or a pipe). If you wish to pass each of the files to another process (using xargs
), it is best to replace -print
with -print0
so it correctly handles whitespace in the filenames.
其次,使用<代码>的,以在这些结果内替换案文。 (与澳门有关的<条码>的<>编码/代码”版本不同于“国联<条码>,将不适当处理新的条码和其他特殊性质”。) 如果你不为你工作的话,你也许需要 gr。
The basic structure of the replacement is:
sed -i "" -e s/NSLocalizedString((.*), (.*))/NSLocalizedStringFromTable(1, table, 2)/g "FILENAME"
The -i ""
replaces the file in-place (saves it to the same file that was opened). -e
just means the next text is going to be an expression. Starting the expression with s/
signifies that you are going to be doing a search-and-replace. It is usually in the format:
s/[search for this pattern]/[replace with this pattern]/g
The /g
at the end means global , or "do this for as many instances that are found on each line as possible."
查询模式,/NS LocalizedString(((*)、(*)/
,发现案文,然后复制(......)
tags(必须绕过<>条码>的括号(<<>>>>>>)。
替换模式,/NS LocalizedStringFromTable (1,表2)/
,改为NS localizedStringFromTable
,然后把第一部和第二版<代码>(*)的正数改为<1和2
。
If you had this literal value:
NSLocalizedString(@"Darn tootin ", @"How they say that is correct in some dialects");
then the result would become:
NSLocalizedStringFromTable(@"Darn tootin ", table, @"How they say that is correct in some dialects");
Now, @shellter asked in the comments whether you meant that you want the literal word table
to be in there, whether parameter 1 or parameter 2 should come from different tables, etc. That would certainly change the format of this search string.
Lastly, you can combine the two above features into one long shell script and run it in Terminal:
find . -type f -name "*.m*" -print0|
xargs -0 -I FILENAME
sed -i "" -e s/NSLocalizedString((.*), (.*))/NSLocalizedStringFromTable(1, table, 2)/g "FILENAME"
如果你打算用不同的价值代替你在原岗位上提到的“瓦尔1”和“瓦尔2”,那么你就需要具体说明。