• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Adding user dictionary in InDesing preference-dictionary

Community Beginner ,
Jul 15, 2016 Jul 15, 2016

Copy link to clipboard

Copied

Screen Shot 2016-07-15 at 1.17.01 PM-SANTHOSH.pngHi,

Below are the code i can able to load the user dictionary in PC(windows). For mac its not working.

with(app.dictionaryPreferences){

  //PC////  var fo ="C:/lib/GHM_07_July2016.udc"

  var fo="/Applications/GHM-Dictionary/GHM_07_July2016.udc"

  alert(fo)

app.languagesWithVendors.itemByName('English: USA').addDictionaryPath(File(fo));

}

please guide me.

Thanks in advance...

Regards

AshokInDesign ScriptingScreen Shot 2016-07-15.png

TOPICS
Scripting

Views

2.5K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jul 26, 2016 Jul 26, 2016

Hi together,

I can add an udc file to languagesWithVendors on my German InDesign.

( The used string "Deutsch: Rechtschreibreform 1996" is "German: Reformed" with an English version of InDesign )

Since the following is not working—I assume it's a bug with my German versions of InDesign:

try{

app.languagesWithVendors.itemByName("Deutsch: Rechtschreibreform 1996").name;

}catch(e){$.writeln("ERROR:"+"\t"+e.message)};

//Result:

// ERROR:    Objekt ist ungültig

// ERROR:    Object is not valid

I have to loop th

...

Votes

Translate

Translate
Guide ,
Jul 15, 2016 Jul 15, 2016

Copy link to clipboard

Copied

Give the screenshot for path of the item GHM_07_July2016.udc in your mac

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 15, 2016 Jul 15, 2016

Copy link to clipboard

Copied

Here i attached the screenshot .udc path and error message i receivedScreen Shot 2016-07-15 at 5.07.48 PM-SANTHOSH.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jul 15, 2016 Jul 15, 2016

Copy link to clipboard

Copied

Hi ashok,

I think path name called wrong

@Wrong path: var fo="/Applications/GHM-Dictionary/GHM_07_July2016.udc"

Select your last folder, than track and drop one .txt file. You are get actual path:

After that you copy and paste your code (run script). 

Thanks

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 15, 2016 Jul 15, 2016

Copy link to clipboard

Copied

Hi karthiks94217840​,

still iam facing same problem. Here i attached screenshot for your reference.

Screen Shot 2016-07-15 at 5.56.38 PM-SANTHOSH.png

Regards

ashok

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jul 15, 2016 Jul 15, 2016

Copy link to clipboard

Copied

i am using the following method:

open apple script editor, drag and drop your .udc file and you will get the file path

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jul 15, 2016 Jul 15, 2016

Copy link to clipboard

Copied

like this

Screen Shot 2016-07-15 at 6.03.04 PM.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 15, 2016 Jul 15, 2016

Copy link to clipboard

Copied

Hi tpk1982 

thanks for reply.

iam using extend toolkit, jsx

iam using same logic of take the path of .udc. below screen shot for iam taking the path and place the .udc path in the jsx. it showing error.

Screen Shot 2016-07-15 at 6.20.16 PM-SANTHOSH.png

After place the .udc path. its showing error= "cannot add dictionary path". the path or highlighted.

Screen Shot 2016-07-15 at 5.07.48 PM-SANTHOSH.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jul 15, 2016 Jul 15, 2016

Copy link to clipboard

Copied

try this

"../Applications/GHM-Dictionary/GHM_07_July2016.udc"

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jul 15, 2016 Jul 15, 2016

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 15, 2016 Jul 15, 2016

Copy link to clipboard

Copied

i try this path.see above highlighted screen shot shows the path....

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jul 15, 2016 Jul 15, 2016

Copy link to clipboard

Copied

did you noticed i have put two dots before /Applications?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 15, 2016 Jul 15, 2016

Copy link to clipboard

Copied

Thank for the reply.

Still iam facing same problem.

Screen Shot 2016-07-16 at 12.17.34 PM.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jul 15, 2016 Jul 15, 2016

Copy link to clipboard

Copied

try this

"~/Applications/GHM-Dictionary/GHM_07_July2016.udc"

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 16, 2016 Jul 16, 2016

Copy link to clipboard

Copied

after adding this "~/Applications/GHM-Dictionary/GHM_07_July2016.udc" still got same error

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jul 16, 2016 Jul 16, 2016

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jul 16, 2016 Jul 16, 2016

Copy link to clipboard

Copied

Hi

See below example path:

1 Example - PC path:

"C:/automation/"

2 Example - MAC path:

"/Users/stype/Library/Preferences/Adobe InDesign/Version 8.0/en_US/Scripts/Scripts Panel/automation/"

I think your path missing front of "/Users/stype/Library/". I mention "stype" replace your system login name.  check one more. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 16, 2016 Jul 16, 2016

Copy link to clipboard

Copied

Hi Karthik,

Thanks for your reply.
still i am facing same problem. here i attached screenshot of file path & errorScreen Shot 2016-07-16 at 1.28.56 PM.pngScreen Shot 2016-07-16 at 1.29.10 PM.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jul 17, 2016 Jul 17, 2016

Copy link to clipboard

Copied

can you try to put dictionary to the desktop, and use this path:
var myDictionaryPath = File("~/Desktop/GHM_07_July2016.udc");


also, you can check if the file exists:
alert("This path is correct! " + myDictionaryPath.exists)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 25, 2016 Jul 25, 2016

Copy link to clipboard

Copied

Hi oleh.melnyk ,

Still same problem!!

Screen Shot 2016-07-25 at 5.06.00 PM-SANTHOSH.png

oleh.melnyk wrote:

can you try to put dictionary to the desktop, and use this path:
var myDictionaryPath = File("~/Desktop/GHM_07_July2016.udc");


also, you can check if the file exists:
alert("This path is correct! " + myDictionaryPath.exists)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jul 25, 2016 Jul 25, 2016

Copy link to clipboard

Copied

This is weird, I just checked, and code works perfectly fine in Windows, but fails with "Cannot add dictionary path." error on Mac

here's my code:

#target indesign

var myDict = File("~/Desktop/MyDict.udc");

app.languagesWithVendors.itemByName('English: USA').addDictionaryPath(myDict);

Windows 10 x64

macOS 10.12 Sierra

UPD: this seams to be a Mac-version bug, where .addDictionaryPath is read only or something

UPD2: .addDictionaryPath expects file path as a string, not a file object, but this didn't help - it's not working on Mac, at least for me

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 26, 2016 Jul 26, 2016

Copy link to clipboard

Copied

Hi together,

I can add an udc file to languagesWithVendors on my German InDesign.

( The used string "Deutsch: Rechtschreibreform 1996" is "German: Reformed" with an English version of InDesign )

Since the following is not working—I assume it's a bug with my German versions of InDesign:

try{

app.languagesWithVendors.itemByName("Deutsch: Rechtschreibreform 1996").name;

}catch(e){$.writeln("ERROR:"+"\t"+e.message)};

//Result:

// ERROR:    Objekt ist ungültig

// ERROR:    Object is not valid

I have to loop through the languagesWithVendors until the one I am looking for is found.

For the Mac I found, that you need the name of the Disk in the path to make it work.
Tested successfully with InDesign CS5, CS5.5, CS6, CC on Mac OSX 10.6.8.

main();

function main()

{

    var localeIndependentLanguageString = "$ID/German: Reformed";

    // Do not use this:

    var fullPathOfUDC = "/KNOWHOW/160726-UserDict.udc";

    // Instead use this:

    var fullPathOfUDC = "Macintosh HD:KNOWHOW:160726-UserDict.udc";

   

   

    // ** WARNING **

    // Both notations will pass this test, if the file exists.

    // But the first one will crash InDesign, if the user tries to remove it in the UI => CC v9.3.0 on Mac OSX 10.6.8

   

    if( ! File(fullPathOfUDC).exists){return};

   

    var languages = app.languagesWithVendors.everyItem().getElements();

    for(var n=0;n<languages.length;n++)

    {

        if( languages.name == app.translateKeyString(localeIndependentLanguageString) )

        {

            var result = languages.addDictionaryPath

            (

                fullPathOfUDC

            );

           

            $.writeln(n+"\t"+result+"\r"+languages.dictionaryPaths.join("\r"));

           

            break

           

        }

    }

}

/*

    Example results with InDesign CS6

   

    17    Added

    /Users/myUserNameHere/Library/Application Support/Adobe/Linguistics/UserDictionaries/Adobe Custom Dictionary/de_DE

    Macintosh HD:KNOWHOW:160726-UserDict.udc

    Ergebnis: undefined

   

    17    Already in path

    /Users/myUserNameHere/Library/Application Support/Adobe/Linguistics/UserDictionaries/Adobe Custom Dictionary/de_DE

    Macintosh HD:KNOWHOW:160726-UserDict.udc

*/

Since I'm using the locale independent version of the language name and translate it at runtime to the locale one, this snippet should work on every localized version of InDesign. Please test and report back.

If you run the script successfully the first time and you did not add the udc file in the UI, the result of addDictonaryPath will be the string "Added".

If you run the script successfully a second time or if you have added the udc file already in the UI, the result will be the string: "Already in path".

I also tested successfully (to an extend) with:

var fullPathOfUDC = "/KNOWHOW/160726-UserDict.udc";

At least the udc file was added again with result "Added", even if I ran the the script successfully with the different path notation before.

This resulted in the following screenshot of my preferences which looks a bit weird:

DictionaryPreferences-InDesignCC.png

The same file is listed two times with different notations.

And when I tried to remove the second or the third item fom top in the UI, InDesign CC v9.3.0 crashed.

I tried to remove the "strange" udc file path notation:

var fullPathOfUDC = "/KNOWHOW/160726-UserDict.udc";

using removeDictionaryPath instead of addDictionaryPath with the snippet above.

The result was:

/*

    Example results with InDesign CC

   

    17    Removed

    /Users/myUserNameHere/Library/Application Support/Adobe/Linguistics/UserDictionaries/Adobe Custom Dictionary/de_DE

    Macintosh HD:KNOWHOW:160726-UserDict.udc

*/

That means, the entry was successfully removed.
I wanted to check in the UI by opening the Preferences/Dictionaries, but InDesign CC crashed instantly.

Tried again after restarting InDesign. Closed and ran InDesign again. Then I could inspect the Preferences in the UI without a crash.

The third item in the list above was gone. The second one is still existed. I could remove that without problems within the UI.

Note:
So I think with Mac OSX one has absolutely use the string like that:

var fullPathOfUDC = "Macintosh HD:KNOWHOW:160726-UserDict.udc";

Since I never really worked with custom dictionaries in InDesign, at least never added udc files, I have to ask:

1. How would I ceate udc files? ( It seems that older versions of InDesign are perhaps required. For testing purposes I used an empty text file with suffix *.udc )

2. How would I test, that the added udc file is working successfully?

( Sorry, that I am a noob on this )

On a scond preliminary test the contents of my udc file was one simple word:

~laubender

A word that should not break, if "German: Reformed" is used with text.
But in my tests after adding the udc file, the word still broke lke that: lau-bender

Regards,
Uwe

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 26, 2016 Jul 26, 2016

Copy link to clipboard

Copied

Sorry, I mistook udc files for hyphenation exceptions.
But my two questions above still stand:

1. How would I create udc files?

2. How would I test, that the added udc file is working successfully?

Thank you,
Uwe

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jul 26, 2016 Jul 26, 2016

Copy link to clipboard

Copied

I never worked with user dictionaries before as well, and they seem to be working in a bit weird way!

How I created my custom dictionary file:

1. created new blank document and wrote list of Apple devices and OS, like that:

iMac, iPhone, iPad, iPod, iOS, macOS, tvOS, watchOS

Those words become highlighted (when Dynamic Spelling option is turned on).

2. I created new user dictionary at the preferences tab (at your screenshots).

3. Select a word and right-click with the mouse, choose "User Dictionary..." - select your dictionary file from the target dropdown, and language - then add words one-by-one...

4. .udc file - is just a regular text file with one word per line separated by \r

5. In order to make new dictionary work you need to select text and reapply language, which is a bit weird - and by reapplying I mean apply another language, then apply original lang

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 26, 2016 Jul 26, 2016

Copy link to clipboard

Copied

Thank you Oleh.
I'll try that out. Especially item 5 in your list is a bit strange. But I let you know how it works for me.

Could you try my suggested script on your Mac?
Of course you have to change the string for the path to your needs.
How does it work with you after adding the name of your harddisk and using ":" to separate the sub-paths?

Thank you,
Uwe

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines