I am getting crazy when I try to check the language of the system the user is using…
set processor to system attribute "sysa"
if processor is 2 then
--Sprache herausfinden
display dialog "You are having a PPC"
set x to (do shell script "defaults read .GlobalPreferences AppleLanguages")
set theString to x
set languages_new to (characters 2 thru 3 of theString) as string
set language_akt to languages_new
display dialog language_akt
else if processor is 10 then
display dialog "You are having an Intel"
set x to (do shell script "defaults read com.apple.dock loc")
set theString to x
set languages_new to (characters 1 thru 2 of theString) as string
set language_akt to languages_new
display dialog language_akt
end if
On my Ibook the 2 is working, on another Intel (Macbook Pro) the 10 is working - and on another Intel (Macbook Pro) the 10 is not working… All machines are running on 10.4.8…
Please can you check the code on your machines and tell me where it is working and where not…
set hardware_descr to do shell script "system_profiler SPHardwareDataType | grep 'Model' | cut -c 22-"
set machine_hw_name to do shell script "uname -m"
set SystemLanguage to do shell script "defaults read .GlobalPreferences AppleCollationOrder"
Is there a possibility to check more methods - something like this:
if processor is 2 then
try
--Sprache herausfinden
display dialog "You are having a PPC"
set x to (do shell script "defaults read .GlobalPreferences AppleLanguages")
set theString to x
set languages_new to (characters 2 thru 3 of theString) as string
set language_akt to languages_new
display dialog language_akt
on error
set SystemLanguage to do shell script "defaults read .GlobalPreferences AppleCollationOrder"
end try
else if processor is 10 then
try
display dialog "You are having an Intel"
set x to (do shell script "defaults read com.apple.dock loc")
set theString to x
set languages_new to (characters 1 thru 2 of theString) as string
set language_akt to languages_new
display dialog language_akt
on error
set SystemLanguage to do shell script "defaults read .GlobalPreferences AppleCollationOrder"
end try
end if
now I trying this - could you please tell me, wheter this is a good solution?
if processor is 2 then
try set x to (do shell script "defaults read .GlobalPreferences AppleLanguages")
on error
try
set x to do shell script "defaults read .GlobalPreferences AppleCollationOrder")
on error
set x to do shell script "defaults read com.apple.dock.loc"
end try
end try
else if ....
It seems that there where some typos.
For me this one works:
try
set x to text 2 thru 3 of (do shell script "defaults read .GlobalPreferences AppleLanguages")
on error
try
set x to do shell script "defaults read .GlobalPreferences AppleCollationOrder"
on error
set x to text 1 thru 2 of (do shell script "defaults read com.apple.dock.loc")
end try
end try
In fact the three are working on my G5 under 10.4.8
I extract two chars so that the result is the same for every line of code: “fr” here.
user locale contains the language which has been chosen during a system installation process.
It doesn’t change when you change the language setting in the International pane
The error message shows that you can not use the (key)word »Language«. Rename to »myLanguage« for a valid variable name and it works perfect:
tell application "System Events"
set myLanguage to word 1 of ¬
(do shell script "defaults read .GlobalPreferences AppleLanguages")
if (myLanguage is in {"de", "German", "Deutsch"}) then
set LANG to 1
else
set LANG to 2
end if
end tell