MacOS – How to import text substitutions from Wikipedia “Lists of common misspellings for machines”

macossystem-prefstext inputtext;

Wikipedia has some nice lists of misspellings for machines:

How to import them as text replacement definitions in System Preferences > Language & Text > Text?

Best Answer

After having read How can I export text substitutions from Lion for import into Mountain Lion made clear to me that PlistBuddy was a good way to go.

  1. Create a folder for storing related files, for example using Terminal.app:

    $ mkdir ~/Documents/OS\ X

  2. Create a backup of the existing text replacements:

    $ /usr/libexec/PlistBuddy -x -c "Print NSUserReplacementItems" ~/Library/Preferences/.GlobalPreferences.plist > ~/Documents/OS\ X/UserReplacementItems-backup.plist

  3. Create a new document in TextWrangler.

  4. Change the encoding of the document (bottom of the window) to Western (Windows Latin 1). Otherwise Plist Converter.app replaces any accented characters with an incorrect value.

  5. Copy the text from Wikipedia and paste it into the newly created TextWrangler document.

  6. [Replace All] occurences of '->' with ',' using the menu command Search -> Find.

  7. Insert the Prefix '1,' on all lines using the menu command Text -> Prefix/Suffix Lines....

  8. Prepend the file with this line (as first line): on,replace,with

  9. Save the file to the ~/Documents/OS\ X folder and make sure that the file name ends with '.csv'.

  10. Drag the '.csv' file to Plist Converter.app and click the button [Convert Plist].

  11. Open the newly created '.plist' in TextWrangler.

  12. Replace all occurrences of '<string>1</string>' with '<integer>1</integer>'.

  13. Save the replace .plist file and quit TextWrangler.

  14. Now make sure you don't have System Preferences open while doing the import, or it may not work!

    /usr/libexec/PlistBuddy -c "Merge '$(ls ~/Documents/OS\ X/common-typos.plist)' NSUserReplacementItems" ~/Library/Preferences/.GlobalPreferences.plist

    Don't forget to replace common-typos.plist with the file name you created.