Is it possible to check language of any document. I am trying to get it, also I want to check any space before punctuation and any Shift+Enter sign in the document.
tell application "Adobe InDesign CS3"
tell document 1
get applied language
--set applied language to "English"
end tell
end tell
tell application "Adobe InDesign CS3"
tell document 1
set t to name of every language
if t is greater than 1 then
display dialog "It is more than one language"
else
display dialog "It is one language"
end if
end tell
end tell
t --{"English: UK"}
I got it. And moving forward seek inputs from any one.
See below code:
tell application "Adobe InDesign CS3"
tell document 1
set totLanguage to count of every language
if totLanguage is greater than 1 then
display dialog "More than One"
else
display dialog "Only one"
end if
set t to name of every language
end tell
end tell
t
Please check where I am doing any mistakes. getting errors of report_folder not defined.
set report_folder to (path to the desktop folder as string)
tell application "Adobe InDesign CS3"
set DocName to the name of document 1
tell document 1
set totLanguage to count of every language
set t to name of every language
my write_Report(DocName, totLanguage, t)
end tell
end tell
t
on write_Report(DocName, totLanguage, t)
set The_Report to report_folder & DocName & "“Report"
try
open for access file the The_Report with write permission
write totLanguage to file the The_Report starting at eof
write t to file the The_Report starting at eof
close access file the The_Report
on error
close access file the The_Report
end try
end write_Report
Does this do what you want.
Placed the line that wasn’t playing nice inside your handler!!
tell application "Adobe InDesign CS3"
set DocName to the name of document 1
tell document 1
set totLanguage to count of every language
set t to name of every language
my write_Report(DocName, totLanguage, t)
end tell
end tell
t
on write_Report(DocName, totLanguage, t)
set report_folder to (path to the desktop folder as string) -- moved to here
set The_Report to report_folder & DocName & "“Report"
try
open for access file the The_Report with write permission
write totLanguage to file the The_Report starting at eof
write t to file the The_Report starting at eof
close access file the The_Report
on error
close access file the The_Report
end try
end write_Report
I have modified a little bit, but still not achievable.
tell application "Adobe InDesign CS3"
set DocName to the name of document 1
tell document 1
set totLanguage to count of every language
set t to name of every language
set t to t as string
my write_Report(DocName, totLanguage, t)
end tell
end tell
t
on write_Report(DocName, totLanguage, t)
set report_folder to (path to the desktop folder as string)
set The_Report to report_folder & DocName & "“Report"
try
open for access file the The_Report with write permission
write totLanguage to file the The_Report starting at eof
write t to file the The_Report starting at eof
close access file the The_Report
on error
close access file the The_Report
end try
end write_Report
Not sure if this will work cause i only have one language set in my indesign.
But give it a go and let me know the outcome!!
set Tlist to {}
tell application "Adobe InDesign CS3"
set DocName to the name of document 1
tell document 1
set totLanguage to count of every language
set t to every language
repeat with i from 1 to totLanguage
copy name of item i of t as string to end of Tlist
end repeat
my write_Report(DocName, totLanguage, Tlist)
end tell
end tell
on write_Report(DocName, totLanguage, t)
set report_folder to (path to the desktop folder as string)
set The_Report to report_folder & DocName & "“Report"
try
open for access file the The_Report with write permission
write totLanguage to file the The_Report starting at eof
repeat with n in t
set n to n as string
write n & return to file the The_Report starting at eof
end repeat
close access file the The_Report
on error
close access file the The_Report
end try
end write_Report
The requirement get slightly changed so I have changed the code. See below it is showing only one language in the second language it gives error. See below code.
set TList to {}
tell application "Adobe InDesign CS3"
set DocName to the name of document 1
tell document 1
set totLanguage to count of every language
set t to every language
if totLanguage is greater than 1 then
display dialog "More than One Langauge Used."
repeat with i from 1 to totLanguage
copy name of item i of t as string to the end of TList
display dialog TList
end repeat
else
display dialog "Only One Langauge Used. That is: " & t
end if
end tell
end tell
t
set Tlist to {}
tell application "Adobe InDesign CS3"
set DocName to the name of document 1
tell document 1
set totLanguage to count of every language
set t to every language
if totLanguage is greater than 1 then
display dialog "More than One Langauge Used."
repeat with i from 1 to totLanguage
copy name of item i of t as string to the end of Tlist
display dialog Tlist
end repeat
else if totLanguage is equal to 1 then
repeat with i from 1 to totLanguage
copy name of item i of t as string to the end of Tlist
display dialog "Only One Langauge Used. That is: " & item i of Tlist
end repeat
end if
end tell
end tell
Now it is working fine, I got hint from your code, thanks.
set Tlist to {}
tell application "Adobe InDesign CS3"
set DocName to the name of document 1
tell document 1
set totLanguage to count of every language
set t to every language
if totLanguage is greater than 1 then
display dialog "More than One Langauge Used."
repeat with i from 1 to totLanguage
copy name of item i of t as string to the end of Tlist
display dialog item i of Tlist
end repeat
else if totLanguage is equal to 1 then
repeat with i from 1 to totLanguage
copy name of item i of t as string to the end of Tlist
display dialog "Only One Langauge Used. That is: " & item i of Tlist
end repeat
end if
end tell
end tell