[Adium-devl] Watching a first time Adium user for 5 minutes

Evan Schoenberg evan at adiumx.com
Sun Jan 28 16:31:01 UTC 2007


On Jan 28, 2007, at 10:35 AM, Peter Hosey wrote:

> On Jan 28, 2007, at 07:19:19, Andreas Monitzer wrote:
>> On Jan 28, 2007, at 16:04, Evan Schoenberg wrote:
>>> I see.  And the separator characters let us parse the arguments  
>>> out and stick them back into a localized string wherever they may  
>>> need to roam?
>>
>> Right.
>
> No need for magic separators—this sort of thing can be done with NS/ 
> CF's positional-formatter extension.
>
> gaimString = "Gaim string for blah"
>
> cocoaLocalizedString = NSLocalizedString(gaimString, /*comment*/  
> @"blah")
> = cocoaLocalizedString = \
> 	@"Klingon word for bar: %2$@" \
> 	@"Klingon word for foo: %1$@"  \
> 	@"Klingon word for baz: %3$@"
>
> [NSString stringWithFormat:cocoaLocalizedString,
> 	@"foo",
> 	@"bar",
> 	@"baz"]
>
> Note: It really is “1$”, not “$1”. No idea why.

We use those all the time in Adium itself... the problem is that  
we're looking at the string "You have receive an authorization  
request from %s, who wants to add you to his list because %s" which  
then has %s and %s, after translation, substituted.  If we want  
*both* the string *and* to know what the string means -- and we don't  
for an auth request; that's just an arbitrary example -- then we have  
to:
1) use gettext to translate that to "AUTH_REQUEST–%s–%s"
2) do a string comparison for "AUTH_REQUEST–"
3) parse out the next two items
4) substitute them into the string via NSLocalizedString or the like

The only real advantage here I see is that it makes it easier to  
parse out the substituted values which is currently done in the few  
remaining places (are there any?) it's needed by looking at the  
strings before and after the substituted text.  If the libgaim string  
changed,we'd still have to update *something* to get the  
"translation" again.

-Evan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://adium.im/pipermail/devel_adium.im/attachments/20070128/aeb999d9/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 186 bytes
Desc: This is a digitally signed message part
URL: <http://adium.im/pipermail/devel_adium.im/attachments/20070128/aeb999d9/attachment.sig>


More information about the devel mailing list