私は解決策を見つけました
$ cat ocstr.awk
# If the code contains @"LBL_....", replace it with C_LBL_... and
# remember the labels for later.
match($0, /@"LBL_[0-9]*\"/) {
S=$0; P=""
do # Loop until there's nothing left in the right half
{
A[L=substr(S, RSTART+2, RLENGTH-3)]++; # Remember label
P=P substr(S, 1, RSTART-1) "C_" L;
S=substr(S, RSTART+RLENGTH);
}
while(match(S, /@"LBL_[0-9]*\"/)); # Keep hunting for more labels
$0=P S; # Update the line to be printed
}
# If we are given file.pm, print into file.m
{ O=FILENAME;
sub(/[.]pm$/, ".m", O);
print > O; }
END {
for(L in A) printf("NSString *const C_%s = @\"%s\";\n", L, L);
}
$ awk -f ocstr.awk dir/*.pm > list
$ cat list
NSString *const C_LBL_10011 = @"LBL_10011";
NSString *const C_LBL_10012 = @"LBL_10012";
NSString *const C_LBL_10804 = @"LBL_10804";
NSString *const C_LBL_10000 = @"LBL_10000";
$ cat dir/*.m
tableviewlogin.backgroundView = nil;
[welcometitle setFont:[UIFont fontWithName:FONTB size:FONTSIZETITLE]];
[welcometitle setText:[MSharedFunctions UF8ErrorMessageForCode:C_LBL_10000]];
[welcometitle setTextAlignment:UITextAlignmentCenter];
NSString *buttontitle = [MSharedFunctions UF8ErrorMessageForCode:C_LBL_10012];
[forgotpassword setTitle:buttontitle forState:UIControlStateNormal];
[forgotpassword setTitle:buttontitle forState:UIControlStateHighlighted];
[self.navigationItem setTitle:[MSharedFunctions UF8ErrorMessageForCode:C_LBL_10011]];
[[self tabBarItem] setTitle:[MSharedFunctions UF8ErrorMessageForCode:C_LBL_10804]];
$