Skip to main content

language of applescript instructions

Comments

9 comments

  • www.shootmachine.co

    Tokens are just text and have no id properties, you have to get the Dutch translation from the C1 UI, and replace between the [ ].

    0
  • GJM Mayenburg

    Hi,
    so i need to figure out in which language Capture One is running (can differ from Operating System)
    Is there a property in the environment of Capture One to read the language of Capture One by Applescript?

    0
  • www.shootmachine.co

    Nope. Nothing native.

    You can get system language (and any app specific language settings the user may have added) from shell though. Then it's just a case of writing the supporting IF statement... 

     

     

    0
  • ericnepean

    There is a native method

    Executing the following applescript will give you the name of "Tuesday" in the local language. From there you can determine the language. (e.g. Tuesday in Dutch is Dinsdag, in German it is Dienstag )

    Note that it is essential to capture the date in a string variable first, otherwise the Applescript compiler on your Mac will localise the argument of date to your localisation.

    set datestr to "3/4/2008"
    get weekday of (date datestr)

    Alternatively the shell command below can be used to give the two letter language code

    do shell script "defaults read .GlobalPreferences AppleLanguages | tr -d [:punct:]| tr -d \" \" | tr -d \"\\n\" | cut -c1-2"
    0
  • GJM Mayenburg

    thanks, with "defaults read etc" i can indeed get the os language, and i assume that every user has Capture One in the same language adapted as operating system.

    For now t is now covered in four languages.

    set SystemLanguage to (do shell script "defaults read .GlobalPreferences AppleLanguages | tr -d [:punct:]| tr -d \" \" | tr -d \"\\n\" | cut -c1-2")
    --default English:
    set
    targetfolder to "[Destination Folder Name]#[Camera Counter]"

    if SystemLanguage is equal to "nl" then
    set targetfolder to "[Naam Doelmap]#[Teller camera]"
    end if

    if SystemLanguage is equal to "es" then
    set targetfolder to "[Nombre de la Carpeta de Destino]#[Contador de cámara]"
    end if

    if SystemLanguage is equal to "de" then
    set targetfolder to "[Zielordner Name]#[Kamerazähler]"
    end if

    tell application "Capture One 21"
    tell current document
    set capture name format to targetfolder
    end tell
    end tell

     

    0
  • www.shootmachine.co

    Newer versions of MacOS have the ability for the user to bypass the system language on an app by app basis in sys prefs - and the above will fail if you don't handle it. To check:

    defaults read com.captureone.captureone14 AppleLanguages

    returns error if not set (does not exist) for the app, else returns a list of languages.

    0
  • GJM Mayenburg

    that brings me to the question what version of Capture One is the actual version on that particular machine
    maybe in a few weeks i have to change to code to:

    defaults read com.captureone.captureone15 AppleLanguages

    Maybe there is a system event call to figure this out.

    and:

    tell application "Capture One 21"

    should be changed to 

    tell application "Capture One 22"
    0
  • www.shootmachine.co

    In most cases

    tell application "capture one 21" 

    will run against any version of Capture One even if specifically saved/compiled as such. Capture One doesn't have the same strict application versioning as other apps. 

    If you want to limit the script to a version, use application ID instead

    tell application id "com.captureone.captureone.14"

    There are properties if you want the app version:

    tell application "capture one"

    return app version -- includes run mode (Pro, DB etc)
    -- or
    return version -- just build no.

    end tell

     

    0
  • GJM Mayenburg

    Finally found some time to complete this item, and share the code.

    use AppleScript version "2.4" -- Yosemite (10.10) or later

    use scripting additions
    tell application "Capture One 22"
    set versieno to version
    end tell
    set splitarray to thesplit(versieno, ".")
    set coversie to item 1 of splitarray

    set SystemLanguage to (do shell script "defaults read .GlobalPreferences AppleLanguages | tr -d  [:punct:]| tr -d \" \" | tr -d \"\\n\" | cut -c1-2")

    set CoLanguage to (do shell script "defaults read com.captureone.captureone" & coversie & " AppleLanguages" & "| tr -d  [:punct:]| tr -d \" \" | tr -d \"\\n\" | cut -c1-2")




    if CoLanguage is equal to "" then

    set CoLanguage to SystemLanguage

    end if




    --default English: 

    set targetfolder to "[Destination Folder Name]#[Camera Counter]"




    if CoLanguage is equal to "nl" then

    set targetfolder to "[Naam Doelmap]#[Teller camera]"

    end if

    if CoLanguage is equal to "es" then

    set targetfolder to "[Nombre de la Carpeta de Destino]#[Contador de cámara]"

    end if

    if CoLanguage is equal to "de" then

    set targetfolder to "[Zielordner Name]#[Kamerazähler]"

    end if

    tell application "Capture One 22"

    activate

    tell current document

    set capture name format to targetfolder

    end tell

    end tell







    on thesplit(theString, theDelimiter)

    -- save delimiters to restore old settings

    set oldDelimiters to AppleScript's text item delimiters

    -- set delimiters to delimiter to be used

    set AppleScript's text item delimiters to theDelimiter

    -- create the array

    set theArray to every text item of theString

    -- restore the old setting

    set AppleScript's text item delimiters to oldDelimiters

    -- return the result

    return theArray

    end thesplit
    0

Please sign in to leave a comment.