IDE Script to export localizable values

Is it possible to automate exporting localizable values with an IDE Script ?

When recording a new script I see the command

DoCommand "ExportLocalizableValues"

But I don’t seem to find a way to automatically select a language and save the file with a different name for each language.
Has anyone succeeded in this ?

My app is localized in 13 languages. If I could export all lingua files at once it would save me a lot of time to check if there are no non localized strings.

There isn’t. This command will just invoke the same dialog you would get by selecting Export Localizable values in the File Menu.

It should be possible from 2018r1:
feedback://showreport?report_id=51447

The following Applescript should allow you to do this without IDE scripting:

[code]tell application “System Events” to tell list 1 of application process “Dock”
click UI element “Xojo 2014r2.1”
end tell

set folderName to “MyApp Localisations”
set filenamePrefix to "MyApp "

– export the localisations
doSave(“Czech”, filenamePrefix & “Czech”, folderName, true)
doSave(“Danish”, filenamePrefix & “Danish”, folderName, false)
doSave(“Dutch”, filenamePrefix & “Dutch”, folderName, false)
doSave(“Finnish”, filenamePrefix & “Finnish”, folderName, false)
doSave(“French”, filenamePrefix & “French”, folderName, false)
doSave(“German”, filenamePrefix & “German”, folderName, false)
doSave(“Italian”, filenamePrefix & “Italian”, folderName, false)
doSave(“Japanese”, filenamePrefix & “Japanese”, folderName, false)
doSave(“Korean”, filenamePrefix & “Korean”, folderName, false)
doSave(“Macedonian”, filenamePrefix & “Macedonian”, folderName, false)
doSave(“Norwegian”, filenamePrefix & “Norwegian”, folderName, false)
doSave(“Polish”, filenamePrefix & “Polish”, folderName, false)
doSave(“Russian”, filenamePrefix & “Russian”, folderName, false)
doSave(“Simp. Chinese”, filenamePrefix & “Simplified Chinese”, folderName, false)
doSave(“Swedish”, filenamePrefix & “Swedish”, folderName, false)
doSave(“Thai”, filenamePrefix & “Thai”, folderName, false)
doSave(“Trad. Chinese”, filenamePrefix & “Traditional Chinese”, folderName, false)

– show an alert as we are finished
tell application “Finder”
activate
display alert “Export Xojo Localisations…” message “Finished.”
end tell

on doSave(pLangName, pFileName, pFolderName, pCreateFolder)
– choose the export menu item
tell application “System Events” to tell process “Xojo”
click (menu item 1 where its name starts with “Export Localizable Values”) of menu 1 of menu bar item “File” of menu bar 1
end tell

-- choose the language
delay 0.5
tell application "System Events" to tell pop up button 1 of sheet 1 of window 1 of process "Xojo"
	click
	
	keystroke pLangName
	key code 36
end tell


-- click export
tell application "System Events" to tell button 1 of sheet 1 of window 1 of process "Xojo"
	click
end tell


-- goto desktop
delay 0.5
tell application "System Events"
	keystroke "D" using command down
	delay 0.5
	keystroke "D" using command down
	delay 0.5
	keystroke "D" using command down
	delay 0.5
	keystroke "D" using command down
end tell


-- create output folder or navigate to it
if pCreateFolder = true then
	delay 0.1
	tell application "System Events" to tell button "New Folder" of sheet 1 of window 1 of process "Xojo"
		click
	end tell
	
	tell application "System Events" to tell text field 1 of sheet 1 of window 1 of process "Xojo"
		keystroke pFolderName
	end tell
	
	delay 0.1
	tell application "System Events" to tell button "Create" of window 1 of process "Xojo"
		click
	end tell
else
	delay 0.1
	tell application "System Events" to tell pop up button 1 of group 1 of sheet 1 of window 1 of process "Xojo"
		click
		
		keystroke pFolderName
		key code 36
	end tell
end if


-- set filename
delay 0.1
tell application "System Events" to tell text field 1 of sheet 1 of window 1 of process "Xojo"
	click
	
	keystroke pFileName
end tell


-- export
tell application "System Events" to tell button "save" of sheet 1 of window 1 of process "Xojo"
	click
end tell


-- rename
delay 0.5
tell application "Finder"
	set the name of file (((path to desktop folder) as string) & pFolderName & ":" & pFileName & ".xojo_locale") to (pFileName & ".rbl")
end tell

end doSave[/code]

Sorry - my mistake. There is a way to do this but not using DoCommand.

If ExportLocalizableValues("english", "/Users/npalardy/Desktop/untitled folder/english.xojo_locale") Then
Print "success"
Else
Print "fail"
end if

The names of the languages are as presented in the popup menus in the IDE for exporting. The path to the destination is a NATIVE path and so is necessarily platform specific. The destination file will be created or overwritten if it already exists.
This can fail if the path to the destination does not exist or the language is not in the list of known languages the IDE supports.

Thank you both!

Your solution seems easier Jason, and “native” to Xojo.

If anyone finds this topic, here is a complete script that might help

[code]
//Languages to Export
Dim lang() As String = array(“English”, _
“French”, _
“Spanish”, _
“German”, _
“Dutch”, _
“Simp. Chinese”, _
“English (UK)”, _
“Italian”, _
“Japanese”, _
“Turkish”, _
“Swedish”, _
“Russian”, _
“Trad. Chinese”, _
“Korean”, _
“Portuguese”, _
“Portuguese Brazil”, _
“Norwegian Bokml”)

//Name of the project
Dim ProjectName as String = “packr_v046”
SelectWindow(“packr_v046”)

//Extract version
Dim version As String = ProjectName.right(5)

//Export path
Dim path As String = “/Users/jleroy/Xojo/Translations/” + ProjectName

//Creating a folder
Dim res as String = DoShellCommand(“mkdir '” + path + “’”)
if res.trim <> “” then
print(res)
end if

Dim failCount As Integer

For each loc as String in lang

If ExportLocalizableValues(loc, path + “/” + loc + version + “.xojo_locale”) Then
'Print “success”
Else
failcount = failcount + 1
if failcount > 2 then
exit
End If
Print “fail-” + loc

end if

Next

//Finally open window with all files
call DoShellCommand(“open '” + path + “’”)[/code]