Discussion:
How to display StandardAlert in Powerplant while localization
(too old to reply)
Neel
2006-03-02 14:21:49 UTC
Permalink
Hi
Trying to display StandardAlert in Powerplant while localization.
Want to display simplified chinese string .i.e.Str255 dst =
"\p总阈值"; which is already converted to UTF8, using XCODE
IDE. The original en string is "Global Threshold". Now I am trying to
display it using StandardAlert in PP, but it does not display any
characters at all....Have a look at the following code snippet....

******************************************************************************
AlertStdAlertParamRec SARecord;
SInt16* outItemHit;
Str255 dst = "\p总阈值";

CFStringRef cfS = NULL;
SARecord.filterProc = nil;
SARecord.movable = true;
SARecord.helpButton = false;
SARecord.defaultText = "\pYes";;
SARecord.otherText = "\pNo";;
SARecord.cancelText = "\pCancel";;
SARecord.defaultButton = kAlertStdAlertOKButton;
SARecord.cancelButton = kAlertStdAlertCancelButton;
SARecord.position = kWindowDefaultPosition;

cfS = CFStringCreateWithPascalString(kCFAllocatorDefault, dst,
kCFStringEncodingUTF8);
ConstStringPtr uStr = CFStringGetPascalStringPtr(cfS,
CFStringGetSystemEncoding());

::StandardAlert(kAlertNoteAlert,"\pUnicode Message" ,uStr, &SARecord,
outItemHit);
********************************************************************************************************


Thanks for all help.
Regards,
Neel
Stephen Chu
2006-03-02 16:28:22 UTC
Permalink
Post by Neel
Hi
Trying to display StandardAlert in Powerplant while localization.
Want to display simplified chinese string .i.e.Str255 dst =
"\p总阈值"; which is already converted to UTF8, using XCODE
IDE. The original en string is "Global Threshold". Now I am trying to
display it using StandardAlert in PP, but it does not display any
characters at all....Have a look at the following code snippet....
******************************************************************************
AlertStdAlertParamRec SARecord;
SInt16* outItemHit;
Str255 dst = "\p总阈值";
CFStringRef cfS = NULL;
SARecord.filterProc = nil;
SARecord.movable = true;
SARecord.helpButton = false;
SARecord.defaultText = "\pYes";;
SARecord.otherText = "\pNo";;
SARecord.cancelText = "\pCancel";;
SARecord.defaultButton = kAlertStdAlertOKButton;
SARecord.cancelButton = kAlertStdAlertCancelButton;
SARecord.position = kWindowDefaultPosition;
cfS = CFStringCreateWithPascalString(kCFAllocatorDefault, dst,
kCFStringEncodingUTF8);
ConstStringPtr uStr = CFStringGetPascalStringPtr(cfS,
CFStringGetSystemEncoding());
::StandardAlert(kAlertNoteAlert,"\pUnicode Message" ,uStr, &SARecord,
outItemHit);
******************************************************************************
**************************
Thanks for all help.
Regards,
Neel
Check out CreateStandardAlert and RunStandardAlert. They use CFString
instead of pascal strings.
Neel
2006-03-08 14:43:22 UTC
Permalink
Thanks for reply Stephen.
Neel
2006-03-10 05:04:43 UTC
Permalink
I am trying to change application locale dynamically, for that i
need to know the current culture/language of machine so that i can
switch application locale to the same language.
following is the snippet of code which return me the "en_IN". Please
have a look,

CFLocaleRef userLocaleRef = CFLocaleCopyCurrent();
CFStringRef l_CurrentLocale, l_CanStr;
l_CurrentLocale = CFLocaleGetIdentifier(userLocaleRef);

char buffer[255];
memset(buffer, '\0', sizeof(buffer));
l_CanStr =
CFLocaleCreateCanonicalLocaleIdentifierFromString(kCFAllocatorDefault,
l_CurrentLocale);
CFStringGetCString(l_CanStr, buffer, 255, CFStringGetSystemEncoding());
Alert(buffer);
// output is en_IN.

Now, if i change "System Preferences->International->Language" to other
language suppose "Chinese" then i would be expecting something like
"ch_ " as string output but it does not work, it shows always en_IN.
Why so ? Where should i make change to get the current language/culture
of the Macintosh OS X 10.3.5 dynamically ?

My application .plist looks like:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple
Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<array/>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>0</key>
<string></string>
<key>CFBundleTypeName</key>
<string>Text file</string>
<key>CFBundleTypeOSTypes</key>
<array>
<string>TEXT</string>
</array>
<key>CFBundleTypeRole</key>
<string>Application</string>
</dict>
</array>
<key>CFBundleGetInfoString</key>
...........

Please suggest.
Thanks in advance.

Loading...