Featured post
cocoa - How do I preserve flags/width in a printf-formatted NSString used as a key for NSLocalizedString? -
i use genstrings
generate .strings
files source code files in project. though project technically cappuccino app, question should apply equally project uses .strings
files.
i have format string i'd localized: @"%d:%02d %@"
. displaying time values. if osx/ios app, i'd use built-in datetime formatting, since it's cappuccino have roll own. when run genstrings
produces value key: "%1$d:%2$d %3$@"
.
this appears in localizable.strings
file:
/* shortlocaltimeformat */ "%d:%02d %@" = "%1$d:%2$d %3$@";
by running command: genstrings -o resources/en.lproj -s cplocalizedstring *.j */*.j
again, ignore i'm using cplocalizedstring
instead of nslocalizedstrings
, *.j
instead of *.m
, these values appropriate cappuccino. notice 02
in %02d
discarded in resulting format string. if run again -nopositionalparameters
option, leaves string is: genstrings -o resources/en.lproj -nopositionalparameters -s cplocalizedstring *.j */*.j
.
/* shortlocaltimeformat */ "%d:%02d %@" = "%d:%02d %@";
is bug in genstrings
, or not possible use flags/width in format strings while keeping positional parameters?
if objective-c project, shorten format strings "%1$@ %2$@"
, use nsdateformatter
generate time string. if class not available, generate intermediate time string myself , use string parameter localized format string rather passing hours/minutes localized format string directly.
- Get link
- X
- Other Apps
Comments
Post a Comment