Saturday, July 4, 2020

#26 2020-04-30 04:40:54 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4533

Re: Catalina Reminders, make new list with color? emblem?

Applescript:


----------------------------------------------------------------
use AppleScript version "2.5"
use framework "Foundation"
use scripting additions

-- Build an array of the English names of colors used by Reminders starting from the localized names
-- Build an array of the English names of emblems used by Reminders starting from the localized names

-- Yvan KOENIG (VALLAURIS, France) jeudi 30 avril 2020 12:35:02
----------------------------------------------------------------

property |⌘| : a reference to current application

set localizedColors to {"Rouge", "Orange", "Jaune", "Vert", "Bleu clair", "Bleu", "Indigo", "Rose", "Violet", "Marron", "Gris", "Rose"}
set localizedEmblems to {"Sélectionnée, Liste", "Signet", "Repère", "Cadeau", "Gâteau d’anniversaire", "Chapeau de diplômé", "Sac à dos", "Règle et crayon", "Portefeuille", "Carte bancaire", "Billets et pièces", "Haltères", "Personne qui court", "Fourchette et couteau", "Verre à vin", "Pilules et cachets", "Stéthoscope", "Fauteuil", "Maison", "Téléviseur", "Musique", "Ordinateur", "Manette de jeu", "Feuille", "Carotte", "Personne", "Couple", "Famille", "Patte", "Ours en peluche", "Poisson", "Panier de courses", "Caddie", "Cabas", "Ballon de foot", "Baseball", "Basketball", "Football américain", "Raquette de tennis", "Train", "Avion", "Bateau", "Voiture", "Parasol", "Lune", "Soleil", "Goutte d’eau", "Flocon de neige", "Feu", "Valise", "Clé et tournevis", "Ciseaux", "Compas à dessin", "Crochet", "Carré", "Cercle", "Triangle", "Forme de losange", "Cœur", "Étoile"}

set thisLocale to current application's NSLocale's currentLocale()
set myCountryCode to thisLocale's countryCode as text --> "FR"
set myLocaleIdentifier to thisLocale's localeIdentifier as text --> "fr_FR"
set myLanguageCode to thisLocale's languageCode as text --> "fr"

tell application "System Events"
   set forYK to exists folder "resources YK:"
end tell
if not forYK then
   set root to (path to application "Reminders" as text) & "Contents:Resources:"
else
   set root to "resources YK:resources trois:Catalina:Applications:Reminders.app:Contents:Resources:"
end if
set fullTable to "Localizable.strings"

set anURL to (|⌘|'s NSURL's fileURLWithPath:(POSIX path of (root & myLanguageCode & ".lproj:" & fullTable)))
set theDict to (|⌘|'s NSDictionary's dictionaryWithContentsOfURL:anURL)
set theColors to {}
set theEmblems to {}
if theDict is not missing value then
   set theKeys to theDict's allKeys()
   repeat with akey in theKeys
       set aValue to (theDict's valueForKey:akey) as text
       if aValue is in localizedColors then
           set end of theColors to (akey as text) & tab & aValue
       else if aValue is in localizedEmblems then
           set end of theEmblems to (akey as text) & tab & aValue
       end if
   end repeat
end if

my saveList(theColors, "colors for Reminders.txt")
my saveList(theEmblems, "emblems for Reminders.txt")

#=====

on saveList(aList, reportName)
   set theData to my concatlist:aList usingString:linefeed
   -- save data to new file
   set hfsPath to (path to documents folder as text) & reportName
   set targetFile to hfsPath as «class furl»
   (theData's writeToURL:targetFile atomically:true encoding:(|⌘|'s NSUTF8StringEncoding) |error|:(missing value))
   
   tell application "TextEdit"
       activate
       if exists window reportName then close window reportName
       open targetFile
   end tell
end saveList

#=====

on concatlist:theList usingString:d1
   set anArray to current application's NSArray's arrayWithArray:theList
   return (anArray's componentsJoinedByString:d1) -- as text
end concatlist:usingString:

#=====

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) jeudi 30 avril 2020 12:40:46

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)