I added the 3 needed instructions in the script given in message #5.
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mardi 17 mars 2020 08:11:52
I added the 3 needed instructions in the script given in message #5.
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mardi 17 mars 2020 08:11:52
Thank you Yvan! Really Appreciate it!
I have one final question. Sometimes or rather most of the times in Keynote, I will have multiple floating windows open. Like Colour Picker, Build Order, and Font List. I notices that this script will not work when floating windows from Keynote are open.
Here is the error message.
How can we fix this?
Thank you, Yvan!
I was upon that when I saw your question.
replace the instruction
tell window 1
by
tell (first window whose subrole is "AXStandardWindow")
message #5 is edited accordingly.
Is it useful to add a test issuing a warning if the radio buttons related to compression aren’t available ?
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mardi 17 mars 2020 11:49:03
Thank you for the fix Yvan! Awesome and really appreciate it!
I don’t think it would be useful for the warning as the radio buttons related to compression will always be available since we are in Custom mode.
Thanks for the help, Yvan!
Hello Yvan,
I notice a bug and an issue in the script. I am not really sure what is causing it.
When I set both field to 1 and 0, and each time I export the keynote, the video file gets much longer. I have to manually enter 1 and 0 in the keynote movie export to export it out correctly.
set value of text field 1 to "1" -- must be a string -- ADDED
set value of text field 2 to "0" -- must be a string -- ADDED
I am wondering, what is causing the issue? Is there a way to fix this?
Thank you.
The disease of many experienced programmers is that they cannot convey the essence to inexperienced in a simple way. I hope most like the English interface, just like me. Although I perfectly know Russian, Greek, Georgian.
For example, if you use a simple programming language, then the above scripts can be reduced to this. Just compare with your monsters:
tell application id "com.apple.systemevents" to tell process "Keynote"
set frontmost to true
tell menu bar 1 to tell menu bar item "File" to tell menu 1
tell menu item "Export To" to tell menu 1 to click menu item "Movie…"
end tell
delay 0.1
tell window 1 to tell sheet 1
set value of 1st text field whose help is "Type how many seconds to wait between slides." to "10"
set value of 1st text field whose help is "Type how many seconds to wait between builds." to "8"
tell (1st pop up button whose help is "Choose a size for the movie.")
perform action "AXShowMenu"
delay 0.1
click menu item "Custom..." of menu 1
end tell
set value of 1st text field whose help is "Type the width you want for the movie." to "1920"
set value of 1st text field whose help is "Type the height you want for the movie." to "1080"
click (1st radio button whose title is "Apple ProRes 4444")
delay 0.1
click button "Next…"
end tell
end tell
Here is your original script without GUI scripting. I fixed in it 2 errors and it works now.
For the movie export format you have 4 constants: small, medium, large, native size. They respond to 360p, 540p, 720p, native size. You should use always KeyNote’s constant (for exapmple, instead of 720p you should use large. The compiler automatically changes it to italic 720p, but now it is what should be. (That is, it is other, proper 720p). If you do not make changes in the script in future, it remains correct. If you change the script, always put large again, to fix the issue again. This was first error.
Correct UTI of keyNote document is “com.apple.iwork.keynote.sffkey” and not “com.apple.iwork.keynote.key”. This was second error.
Filtering process is simpler (see here). Handler checkForIdentifier no need at all.
No need Posix files, Posix paths and do shell scripts…
Your fixed script (I use native size, you can use small, medium, large instead):
property destinationFolder : (path to desktop folder)
on run
-- TRIGGERED WHEN USER LAUNCHES DROPLET. PROMPT FOR PRESENTATION FILE(S):
set theItems to (choose file of type "com.apple.iwork.keynote.sffkey" with prompt "Pick the Keynote presentation(s) to export to movie:" with multiple selections allowed)
open theItems
end run
on open theItems
-- TRIGGERED WHEN USER DRAGS ITEMS ONTO THE DROPLET
display dialog "This droplet will export dragged-on Keynote presentation files as movies" & return & return & "The movies will be encoded to MPEG format using H.264 compression." with icon 1
set filesToProcess to {}
-- filter the dragged-on items for Keynote presentation files
repeat with anItem in theItems
tell application id "com.apple.systemevents" to set anUTI to type identifier of anItem
if anUTI is "com.apple.iwork.keynote.sffkey" then set the end of the filesToProcess to anItem
end repeat
if filesToProcess is {} then
activate
display alert "INCOMPATIBLE ITEMS" message "None of the items were Keynote presentations."
else
-- process the presentations
my exportPresentationsToMovies(filesToProcess)
end if
end open
on exportPresentationsToMovies(thePresentations)
tell application "Keynote"
activate
if playing is true then tell front document to stop
try
repeat with aPresentation in thePresentations
open aPresentation
set the documentName to name of the front document
set destinationFile to my deriveFileNameForNewFileInFolder(documentName, destinationFolder)
with timeout of 1200 seconds -- 20 minutes
export front document to file destinationFile as QuickTime movie with properties {movie format:native size}
end timeout
close front document saving no
display notification documentName with title "Keynote Movie Export"
end repeat
on error errorMessage
activate
display alert "EXPORT ERROR" message errorMessage
error number -128
end try
end tell
end exportPresentationsToMovies
on deriveFileNameForNewFileInFolder(sourceItemBaseName, targetFolderHFSAlias)
-- Routine that derives a none-conflicting file name
set targetName to ((targetFolderHFSAlias & sourceItemBaseName) as text) & ".m4v"
try
alias targetName
on error
return targetName
end try
set n to 1
repeat
set targetName to ((targetFolderHFSAlias & sourceItemBaseName) as text) & "(" & n & ").m4v"
try
alias targetName
set n to n + 1
on error
return targetName
end try
end repeat
end deriveFileNameForNewFileInFolder
I apologizes but you are wrong.
On my machine, keynote documents are given the UTI “com.apple.iwork.keynote.key”.
Look at the file :
“Keynote.app:Contents:Info.plist”
You will learn that
Keynote Presentation document may be :
com.apple.iwork.keynote.key – package
com.apple.iwork.keynote.sffkey – flat file
com.apple.iwork.keynote.key-tef – package
com.apple.iwork.keynote.kpf – package
You may run the script below to check that.
set theApp to path to application id "com.apple.iWork.Keynote"
set thePlist to ((theApp as text) & "Contents:Info.plist") as «class furl»
set answer to choose from list {"Xcode", "BBEdit"} with title "Choose the application to open the plist" with prompt "Xcode: look at the properties “Document types” " & linefeed & "BBEdit: look at keys “UTTypeConformsTo”"
if answer is false then error number -128
set opener to item 1 of answer as text
tell application opener to open thePlist
On my side I never see com.apple.iwork.keynote.kpf items
and my memory tell me that com.apple.iwork.keynote.key-tef are grabbed from docs generated under iOS (but it may be a wrong souvenir).
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mercredi 25 mars 2020 10:55:39
Thanks for the info. I have only flat file presentations on my Mac. So, I can’t test the last script with other UTIs. If it works, then we can provide the list of UTIs in choose file dialog, and we can check if the file’s identifier is in the UTIs list in the on open handler.
When I posted a code asking for com.apple.iwork.keynote.key UTI, it’s what I had as files available here.
I knew the com.apple.iwork.keynote.sffkey one but I forgot to insert it in the list passed to choose file.
Below is your completed script
property destinationFolder : (path to desktop folder)
property permittedUTIs : {"com.apple.iwork.keynote.key", "com.apple.iwork.keynote.sffkey", "com.apple.iwork.keynote.key-tef", "com.apple.iwork.keynote.kpf"} -- ADDED
on run
-- TRIGGERED WHEN USER LAUNCHES DROPLET. PROMPT FOR PRESENTATION FILE(S):
set theItems to (choose file of type permittedUTIs with prompt "Pick the Keynote presentation(s) to export to movie:" with multiple selections allowed) -- EDITED
open theItems
end run
on open theItems
-- TRIGGERED WHEN USER DRAGS ITEMS ONTO THE DROPLET
display dialog "This droplet will export dragged-on Keynote presentation files as movies" & return & return & "The movies will be encoded to MPEG format using H.264 compression." with icon 1
set filesToProcess to {}
-- filter the dragged-on items for Keynote presentation files
repeat with anItem in theItems
tell application id "com.apple.systemevents" to set anUTI to type identifier of anItem
if anUTI is in permittedUTIs then set the end of the filesToProcess to anItem -- EDITED
end repeat
if filesToProcess is {} then
activate
display alert "INCOMPATIBLE ITEMS" message "None of the items were Keynote presentations."
else
-- process the presentations
my exportPresentationsToMovies(filesToProcess)
end if
end open
on exportPresentationsToMovies(thePresentations)
tell application "Keynote"
activate
if playing is true then tell front document to stop
try
repeat with aPresentation in thePresentations
open aPresentation
set the documentName to name of the front document
set destinationFile to my deriveFileNameForNewFileInFolder(documentName, destinationFolder)
with timeout of 1200 seconds -- 20 minutes
export front document to file destinationFile as QuickTime movie with properties {movie format:native size}
end timeout
close front document saving no
display notification documentName with title "Keynote Movie Export"
end repeat
on error errorMessage
activate
display alert "EXPORT ERROR" message errorMessage
error number -128
end try
end tell
end exportPresentationsToMovies
on deriveFileNameForNewFileInFolder(sourceItemBaseName, targetFolderHFSAlias)
-- Routine that derives a none-conflicting file name
set targetName to ((targetFolderHFSAlias & sourceItemBaseName) as text) & ".m4v"
try
alias targetName
on error
return targetName
end try
set n to 1
repeat
set targetName to ((targetFolderHFSAlias & sourceItemBaseName) as text) & "(" & n & ").m4v"
try
alias targetName
set n to n + 1
on error
return targetName
end try
end repeat
end deriveFileNameForNewFileInFolder
I applied it upon a “com.apple.iwork.keynote.key” file.
VLC executed the created m4v file without problem.
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mercredi 25 mars 2020 11:40:25
Cool
It would be fine to get feedback from users having documents with UTI com.apple.iwork.keynote.key-tef or com.apple.iwork.keynote.kpf
This way, helpers like us would be aware of behaviors which they can’t test.
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mercredi 25 mars 2020 13:05:27
Hello Yvan!
Any fix on this? I got mixed up with the code from KniazidisR.
Thank you.
How many slides has your presentation? I tested with 4 slides using my GUI script. The duration of created movie was 20 seconds. When I set values manually it creates movie with duration = 4 seconds. Indeed, it is very strange. It seems to me that setting to 1 second doesn’t work, and remains default value = 5 seconds per slide!!!
The solution founded.
Mm, yes. I barely figured it out … It turns out that you first need to focus the text field. Otherwise, Keynote ignores the new values:
set movieName to "myNewKeynoteMovie"
tell application id "com.apple.systemevents" to tell process "Keynote"
set frontmost to true
tell menu bar 1 to tell menu bar item "File" to tell menu 1
tell menu item "Export To" to tell menu 1 to click menu item "Movie…"
end tell
delay 0.1
tell window 1 to tell sheet 1
tell (1st text field whose help is "Type how many seconds to wait between slides.")
set focused to true -- ADDED
set value to "1"
end tell
tell (1st text field whose help is "Type how many seconds to wait between builds.")
set focused to true -- ADDED
set value to "0"
end tell
delay 1
tell (1st pop up button whose help is "Choose a size for the movie.")
perform action "AXShowMenu"
delay 0.1
click menu item "Custom..." of menu 1
end tell
set value of 1st text field whose help is "Type the width you want for the movie." to "1920"
set value of 1st text field whose help is "Type the height you want for the movie." to "1080"
click (1st radio button whose title is "Apple ProRes 4444")
delay 0.1
click button "Next…"
end tell
delay 1
click text field 1 of sheet 1 of window 1
keystroke movieName & return -- naming the movie
delay 1
repeat while sheet 1 of window 1 exists -- show creating movie progress
delay 0.1
end repeat
end tell
English is not used by everybody.
Here is a “partially” localized version.
----------------------------------------------------------------
use AppleScript version "2.5"
use framework "Foundation"
use scripting additions
----------------------------------------------------------------
set thisLocale to current application's NSLocale's currentLocale()
set langX to thisLocale's localeIdentifier as string --> "fr_FR"
set lang2 to thisLocale's languageCode as text --> "fr"
set sys2 to (system attribute "sys2") as integer
tell application "Keynote"
set x to "1543.title"
set loc to localized string x from table "MainMenu"
if loc = x then
if sys2 < 14 then
if lang2 = "ar" then
set loc to "تصدير إلى"
else if lang2 = "ca" then
set loc to "¿¿¿"
else if lang2 = "cs" then
set loc to "Exportovat do"
else if lang2 = "da" then
set loc to "¿¿¿"
else if lang2 = "de" then
set loc to "¿¿¿"
else if lang2 = "el" then
set loc to "Εξαγωγή σε"
else if lang2 = "en_AU" then
set loc to "Export To"
else if lang2 = "en_GB" then
set loc to "Export To"
else if lang2 = "en" then
set loc to "Export To"
else if lang2 = "es_419" then
set loc to "Exportar a"
else if lang2 = "es" then
set loc to "Exportar a"
else if lang2 = "fi" then
set loc to "¿¿¿"
else if lang2 = "fr_CA" then
set loc to "Exporter vers"
else if lang2 = "fr" then
set loc to "Exporter vers"
else if lang2 = "he" then
set loc to "ייצא אל"
else if lang2 = "hi" then
set loc to "इसमें एक्सपोर्ट करें"
else if lang2 = "hr" then
set loc to "Eksportiraj u"
else if lang2 = "hu" then
set loc to "Exportálás"
else if lang2 = "id" then
set loc to "Ekspor Ke"
else if lang2 = "it" then
set loc to "¿¿¿"
else if lang2 = "ja" then
set loc to "¿¿¿"
else if lang2 = "ko" then
set loc to "다음으로 내보내기"
else if lang2 = "ms" then
set loc to "Eksport Ke"
else if lang2 = "nl" then
set loc to "Exporteer naar"
else if lang2 = "no" then
set loc to "¿¿¿"
else if lang2 = "pl" then
set loc to "Eksportuj do"
else if lang2 = "pt_PT" then
set loc to "Exportar Para"
else if lang2 = "pt" then
set loc to "Exportar Para"
else if lang2 = "ro" then
set loc to "Exportă în format"
else if lang2 = "ru" then
set loc to "¿¿¿"
else if lang2 = "sk" then
set loc to "¿¿¿"
else if lang2 = "sv" then
set loc to "¿¿¿"
else if lang2 = "th" then
set loc to "ส่งออกไปยัง"
else if lang2 = "tr" then
set loc to "¿¿¿"
else if lang2 = "uk" then
set loc to "¿¿¿"
else if lang2 = "vi" then
set loc to "Xuất ra"
else if lang2 = "zh_CN" then
set loc to "导出为"
else if lang2 = "zh_HK" then
set loc to "輸出至"
else if lang2 = "zh_TW" then
set loc to "輸出至"
else
set loc to "Export To"
end if
else -- Mojave or higher
set loc to "Export to"
end if
end if
set exportTo_loc to loc
-- set x to "1787.title"
-- set loc to localized string x from table "MainMenu" -- doesn't cover the entire range
if lang2 = "ar" then
set loc to "فيلم…"
else if lang2 = "ca" then
set loc to "Vídeo…"
else if lang2 = "cs" then
set loc to "Film…"
else if lang2 = "da" then
set loc to "Film…"
else if lang2 = "de" then
set loc to "Film …"
else if lang2 = "el" then
set loc to "Ταινία…"
else if lang2 = "en_AU" then
set loc to "Movie…"
else if lang2 = "en_GB" then
set loc to "Movie…"
else if lang2 = "en" then
set loc to "Movie…"
else if lang2 = "es_419" then
set loc to "Video…"
else if lang2 = "es" then
set loc to "Vídeo…"
else if lang2 = "fi" then
set loc to "Elokuva…"
else if lang2 = "fr_CA" then
set loc to "Vidéo…"
else if lang2 = "fr" then
set loc to "Vidéo…"
else if lang2 = "he" then
set loc to "סרטון…"
else if lang2 = "hi" then
set loc to "फ़िल्म…"
else if lang2 = "hr" then
set loc to "Film…"
else if lang2 = "hu" then
set loc to "Film…"
else if lang2 = "id" then
set loc to "Film…"
else if lang2 = "it" then
set loc to "Filmato…"
else if lang2 = "ja" then
set loc to "ムービー…"
else if lang2 = "ko" then
set loc to "동영상…"
else if lang2 = "ms" then
set loc to "Filem…"
else if lang2 = "nl" then
set loc to "Film…"
else if lang2 = "no" then
set loc to "Film…"
else if lang2 = "pl" then
set loc to "Film…"
else if lang2 = "pt_PT" then
set loc to "Filme…"
else if lang2 = "pt" then
set loc to "Filme…"
else if lang2 = "ro" then
set loc to "Film…"
else if lang2 = "ru" then
set loc to "Фильм…"
else if lang2 = "sk" then
set loc to "Film…"
else if lang2 = "sv" then
set loc to "Film…"
else if lang2 = "th" then
set loc to "ภาพยนตร์…"
else if lang2 = "tr" then
set loc to "Film…"
else if lang2 = "uk" then
set loc to "Фільм…"
else if lang2 = "vi" then
set loc to "Phim…"
else if lang2 = "zh_CN" then
set loc to "影片…"
else if lang2 = "zh_HK" then
set loc to "影片⋯"
else if lang2 = "zh_TW" then
set loc to "影片⋯"
else
set loc to "Movie…"
end if
set movieDots_loc to loc
set x to "kn.exportQuickTime.goToNextSlideAfterField"
set exportQuickTimeGoToNextSlideAfterField_loc to localized string x from table "TMAToolTips"
set x to "kn.exportQuickTime.goToNextBuildAfterField"
set exportQuickTimeGoToNextBuildAfterField_loc to localized string x from table "TMAToolTips"
set x to "260.title"
set loc to localized string x from table "KNMacExportQuickTimeFormatOptionsView"
if loc = x then
if sys2 < 14 then
if lang2 = "ar" then
set loc to "مخصص..."
else if lang2 = "ca" then
set loc to "Personalitzar…"
else if lang2 = "cs" then
set loc to "Vlastní…"
else if lang2 = "da" then
set loc to "Speciel…"
else if lang2 = "de" then
set loc to "Eigene …"
else if lang2 = "el" then
set loc to "Προσαρμογή…"
else if lang2 = "en_AU" then
set loc to "Custom..."
else if lang2 = "en_GB" then
set loc to "Custom..."
else if lang2 = "en" then
set loc to "Custom..."
else if lang2 = "es_419" then
set loc to "Personalizar…"
else if lang2 = "es" then
set loc to "Personalizar…"
else if lang2 = "fi" then
set loc to "Muokattu…"
else if lang2 = "fr_CA" then
set loc to "Personnaliser…"
else if lang2 = "fr" then
set loc to "Personnaliser…"
else if lang2 = "he" then
set loc to "מותאם אישית…"
else if lang2 = "hi" then
set loc to "कस्टम..."
else if lang2 = "hr" then
set loc to "Po izboru..."
else if lang2 = "hu" then
set loc to "Egyéni..."
else if lang2 = "id" then
set loc to "Khusus..."
else if lang2 = "it" then
set loc to "Personalizzata…"
else if lang2 = "ja" then
set loc to "カスタム…"
else if lang2 = "ko" then
set loc to "사용자화..."
else if lang2 = "ms" then
set loc to "Tersuai…"
else if lang2 = "nl" then
set loc to "Aangepast..."
else if lang2 = "no" then
set loc to "Tilpasset…"
else if lang2 = "pl" then
set loc to "Własna…"
else if lang2 = "pt_PT" then
set loc to "Personalizar…"
else if lang2 = "pt" then
set loc to "Personalizar…"
else if lang2 = "ro" then
set loc to "Personalizat…"
else if lang2 = "ru" then
set loc to "Настроить…"
else if lang2 = "sk" then
set loc to "Vlastné…"
else if lang2 = "sv" then
set loc to "Anpassat..."
else if lang2 = "th" then
set loc to "กำหนดเอง…"
else if lang2 = "tr" then
set loc to "Özel..."
else if lang2 = "uk" then
set loc to "власний варіант…"
else if lang2 = "vi" then
set loc to "Tùy chỉnh..."
else if lang2 = "zh_CN" then
set loc to "自定…"
else if lang2 = "zh_HK" then
set loc to "自訂⋯"
else if lang2 = "zh_TW" then
set loc to "自訂⋯"
else
set loc to "Custom…"
end if
else -- Mojave or higher
set loc to "Custom..."
end if
end if
set customDots_loc to loc
set x to "kn.exportQuickTime.formatCustomWidthField"
set exportQuickTimeFormatCustomWidthField_loc to localized string x from table "TMAToolTips"
set x to "kn.exportQuickTime.formatCustomHeightField"
set exportQuickTimeFormatCustomHeightField_loc to localized string x from table "TMAToolTips"
set x to "kn.exportQuickTime.formatPopUp"
set exportQuickTimeFormatPopUp_loc to localized string x from table "TMAToolTips"
set x to "Next" & character id 92 & "U2026"
set nextDots_loc to localized string x from table "TSApplication"
end tell
set movieName to "myNewKeynoteMovie"
tell application id "com.apple.systemevents" to tell process "Keynote"
set frontmost to true
tell menu bar 1 to tell menu bar item 3 to tell menu 1
tell menu item exportTo_loc to tell menu 1 to click menu item movieDots_loc
end tell
delay 0.1
tell window 1 to tell sheet 1
tell (1st text field whose help is exportQuickTimeGoToNextSlideAfterField_loc)
set focused to true -- ADDED
set value to "1"
end tell
tell (1st text field whose help is exportQuickTimeGoToNextBuildAfterField_loc)
set focused to true -- ADDED
set value to "0"
end tell
delay 1
tell (1st pop up button whose help is exportQuickTimeFormatPopUp_loc)
perform action "AXShowMenu"
delay 0.1
click menu item customDots_loc of menu 1
end tell
set value of 1st text field whose help is exportQuickTimeFormatCustomWidthField_loc to "1920"
set value of 1st text field whose help is exportQuickTimeFormatCustomHeightField_loc to "1080"
click (1st radio button whose title is "Apple ProRes 4444") -- isn't localized
delay 0.1
click button nextDots_loc
end tell
delay 1
click text field 1 of sheet 1 of window 1
keystroke movieName & return -- naming the movie
delay 1
repeat while sheet 1 of window 1 exists -- show creating movie progress
delay 0.1
end repeat
end tell
I’m busy to enhance the cases where there is a test after the call to localized string because these tests don’t treat every cases.
As you may see several strings are missing.
At this time I didn’t found them.
The links between the property which I named lang2 is right for most cases.
For languages grabbing their string in a lproj named like en_GB.lproj,
I am unable to build the exact link.
I tried to install and activate some of them (like “pt” Portuguese from Brazil and “pt_PT”
Portuguese from Portugal) but on my machine they were given the same couples:
set langX to thisLocale's localeIdentifier as string --> "pt_FR"
set lang2 to thisLocale's languageCode as text --> "pt"
So I didn’t understood how the system link them to the correct spelling.
If someone knows the correct incantation, I am interested.
I apologize if I introduced typos when I inserted the strings belonging to languages which I totally ignore.
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) jeudi 26 mars 2020 22:25:15
When I said that I love the English interface, I did not want to offend others. Anyone can choose the interface they need from your script and the script will be as concise as English. Special thanks for the Greek interface.
NOTE: if you created the correspondence of the language and the value in the form of records at the beginning of the script, then your script can be greatly reduced.
I say this because this is not the first time I have seen this bad practice of hard-coded verification of conditions for truth:
set langRecord to {ar:"مخصص...", ca:"Personalitzar…"}
set lang2 to "ar"
set the clipboard to langRecord
set langRecordAsList to the clipboard as list
repeat with i from 1 to count langRecordAsList by 2
if lang2 is item i of langRecordAsList then
set loc to item (i + 1) of langRecordAsList
exit repeat
end if
end repeat
return loc
This my script is equivalent to the following your code. And you need it twice… Imagine that a programmer needs to sort out 250 languages or more, and not 40 as here …:
if lang2 = "ar" then
set loc to "مخصص..."
else if lang2 = "ca" then
set loc to "Personalitzar…"
else if lang2 = "cs" then
set loc to "Vlastní…"
else if lang2 = "da" then
set loc to "Speciel…"
else if lang2 = "de" then
set loc to "Eigene …"
else if lang2 = "el" then
set loc to "Προσαρμογή…"
else if lang2 = "en_AU" then
set loc to "Custom..."
else if lang2 = "en_GB" then
set loc to "Custom..."
else if lang2 = "en" then
set loc to "Custom..."
else if lang2 = "es_419" then
set loc to "Personalizar…"
else if lang2 = "es" then
set loc to "Personalizar…"
else if lang2 = "fi" then
set loc to "Muokattu…"
else if lang2 = "fr_CA" then
set loc to "Personnaliser…"
else if lang2 = "fr" then
set loc to "Personnaliser…"
else if lang2 = "he" then
set loc to "מותאם אישית…"
else if lang2 = "hi" then
set loc to "कस्टम..."
else if lang2 = "hr" then
set loc to "Po izboru..."
else if lang2 = "hu" then
set loc to "Egyéni..."
else if lang2 = "id" then
set loc to "Khusus..."
else if lang2 = "it" then
set loc to "Personalizzata…"
else if lang2 = "ja" then
set loc to "カスタム…"
else if lang2 = "ko" then
set loc to "사용자화..."
else if lang2 = "ms" then
set loc to "Tersuai…"
else if lang2 = "nl" then
set loc to "Aangepast..."
else if lang2 = "no" then
set loc to "Tilpasset…"
else if lang2 = "pl" then
set loc to "Własna…"
else if lang2 = "pt_PT" then
set loc to "Personalizar…"
else if lang2 = "pt" then
set loc to "Personalizar…"
else if lang2 = "ro" then
set loc to "Personalizat…"
else if lang2 = "ru" then
set loc to "Настроить…"
else if lang2 = "sk" then
set loc to "Vlastné…"
else if lang2 = "sv" then
set loc to "Anpassat..."
else if lang2 = "th" then
set loc to "กำหนดเอง…"
else if lang2 = "tr" then
set loc to "Özel..."
else if lang2 = "uk" then
set loc to "власний варіант…"
else if lang2 = "vi" then
set loc to "Tùy chỉnh..."
else if lang2 = "zh_CN" then
set loc to "自定…"
else if lang2 = "zh_HK" then
set loc to "自訂⋯"
else if lang2 = "zh_TW" then
set loc to "自訂⋯"
else
set loc to "Custom…"
end if
else -- Mojave or higher
set loc to "Custom..."
end if
You can create 1 text file LocalStrings.txt as database, and in it - records, for 10 basic (or more) locals. To each English TEXT should correspond 1 record. There are not so many English texts of UI elements, so this is quite real.
Putting English local in each record as 1st entry, you can determine always what English TEXT is this record for. Then you can simply copy the record and paste in the new created script when you need. This way you create step by step wonderful database, to reuse it multiply times.
Because searching some English text in the text file is not problem. Then, you can sell this database to other programmers as well. :lol: Or, to make a wide gesture - to give as I do. Take it, it’s not a pity.
NOTE: the most appropriate approach would be to create a separate LocalStrings.txt file for each specific application. Because the translation of the same English text can potentially differ from application to application. I think, it can even be automated.
The real problem is to be able to identify the language which is used.
How may we know if it’s “pt.lproj” or “pt_PT.lproj” which is used ?
According to that, some strings aren’t localized the same way.
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) vendredi 27 mars 2020 09:39:46
Yvan, I just haven’t done this yet, but the logic tells me that the application somehow determines which project to use. Most likely from some kind of plist file.
I know that you have been doing script localization for a long time. I need time to read your previous posts about this problem and think about it more seriously. If I find a solution, I will post it HERE.