Saturday, July 4, 2020

#1 2020-04-28 01:55:25 pm

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

How to get localized strings

Hello

Here is the main tool which I use to get localized strings.

The script is designed to search where are stored strings used in the Graphical Interface.
We aren't supposed to know the keys like "N224" but we are supposed to know that a window contains an item whose name is "Kind"
So, launch the script,
type "Kind" in the field named "Text to Search"
if you want to get the German translation, select "de.lproj,German.lproj" in the menu "Other lproj".
lproj are the folders in which are stored the resources matching the language defined in the item selected.
Don't ask why, but Apple name some of them as de.lproj and others as German.lproj
In the menu "Search in" select an "area". Here, Finder is a good choice.
As we entered an English string we must click upon the button "English"

If you enter the German version for Kind, select "de.lproj,German.lproj" then click the button "Other"

You will get two proposals:

Kind    N224    Type    SSD 1000:System:Library:CoreServices:Finder.app:Contents:Resources:English.lproj:Localizable.strings
Kind    N169.35    Type    SSD 1000:System:Library:CoreServices:Finder.app:Contents:Resources:English.lproj:Localizable.strings

Here, as I search in a disk image storing resources for three systems I would get:
On my machine, as I grabbed the resources from High Sierra, Mojave and Catalina, I would get:

Kind    N224    Type    resources YK:resources trois:Catalina:System:Library:CoreServices:Finder.app:Contents:Resources:en.lproj:Localizable.strings
Kind    N169.35    Type    resources YK:resources trois:Catalina:System:Library:CoreServices:Finder.app:Contents:Resources:en.lproj:Localizable.strings
Kind    119.title    Type    resources YK:resources trois:Catalina:System:Library:CoreServices:Finder.app:Contents:Resources:en_AU.lproj:ArrangeByMenu.strings
Kind    338.title    Type    resources YK:resources trois:Catalina:System:Library:CoreServices:Finder.app:Contents:Resources:en_AU.lproj:ArrangeByMenu.strings
Kind    97.headerCell.title    Type    resources YK:resources trois:Catalina:System:Library:CoreServices:Finder.app:Contents:Resources:en_AU.lproj:ListView.strings
Kind    N224    Type    resources YK:resources trois:Catalina:System:Library:CoreServices:Finder.app:Contents:Resources:en_AU.lproj:Localizable.strings
Kind    N169.35    Type    resources YK:resources trois:Catalina:System:Library:CoreServices:Finder.app:Contents:Resources:en_AU.lproj:Localizable.strings
Kind    300892.title    Type    resources YK:resources trois:Catalina:System:Library:CoreServices:Finder.app:Contents:Resources:en_AU.lproj:MenuBar.strings
Kind    44.title    Type    resources YK:resources trois:Catalina:System:Library:CoreServices:Finder.app:Contents:Resources:en_AU.lproj:ViewOptionsWindow.strings
Kind    119.title    Type    resources YK:resources trois:Catalina:System:Library:CoreServices:Finder.app:Contents:Resources:en_GB.lproj:ArrangeByMenu.strings
Kind    338.title    Type    resources YK:resources trois:Catalina:System:Library:CoreServices:Finder.app:Contents:Resources:en_GB.lproj:ArrangeByMenu.strings
Kind    97.headerCell.title    Type    resources YK:resources trois:Catalina:System:Library:CoreServices:Finder.app:Contents:Resources:en_GB.lproj:ListView.strings
Kind    N224    Type    resources YK:resources trois:Catalina:System:Library:CoreServices:Finder.app:Contents:Resources:en_GB.lproj:Localizable.strings
Kind    N169.35    Type    resources YK:resources trois:Catalina:System:Library:CoreServices:Finder.app:Contents:Resources:en_GB.lproj:Localizable.strings
Kind    300892.title    Type    resources YK:resources trois:Catalina:System:Library:CoreServices:Finder.app:Contents:Resources:en_GB.lproj:MenuBar.strings
Kind    44.title    Type    resources YK:resources trois:Catalina:System:Library:CoreServices:Finder.app:Contents:Resources:en_GB.lproj:ViewOptionsWindow.strings
Kind    N224    Type    resources YK:resources trois:High Sierra:System:Library:CoreServices:Finder.app:Contents:Resources:English.lproj:Localizable.strings
Kind    N169.35    Type    resources YK:resources trois:High Sierra:System:Library:CoreServices:Finder.app:Contents:Resources:English.lproj:Localizable.strings
Kind    119.title    Type    resources YK:resources trois:Mojave:System:Library:CoreServices:Finder.app:Contents:Resources:en_AU.lproj:ArrangeByMenu.strings
Kind    338.title    Type    resources YK:resources trois:Mojave:System:Library:CoreServices:Finder.app:Contents:Resources:en_AU.lproj:ArrangeByMenu.strings
Kind    97.headerCell.title    Type    resources YK:resources trois:Mojave:System:Library:CoreServices:Finder.app:Contents:Resources:en_AU.lproj:ListView.strings
Kind    N224    Type    resources YK:resources trois:Mojave:System:Library:CoreServices:Finder.app:Contents:Resources:en_AU.lproj:Localizable.strings
Kind    N169.35    Type    resources YK:resources trois:Mojave:System:Library:CoreServices:Finder.app:Contents:Resources:en_AU.lproj:Localizable.strings
Kind    300892.title    Type    resources YK:resources trois:Mojave:System:Library:CoreServices:Finder.app:Contents:Resources:en_AU.lproj:MenuBar.strings
Kind    44.title    Type    resources YK:resources trois:Mojave:System:Library:CoreServices:Finder.app:Contents:Resources:en_AU.lproj:ViewOptionsWindow.strings
Kind    Wfk-Hq-wyr.title    Type    resources YK:resources trois:Mojave:System:Library:CoreServices:Finder.app:Contents:Resources:en_AU.lproj:ViewOptionsWindow.strings
Kind    119.title    Type    resources YK:resources trois:Mojave:System:Library:CoreServices:Finder.app:Contents:Resources:en_GB.lproj:ArrangeByMenu.strings
Kind    338.title    Type    resources YK:resources trois:Mojave:System:Library:CoreServices:Finder.app:Contents:Resources:en_GB.lproj:ArrangeByMenu.strings
Kind    97.headerCell.title    Type    resources YK:resources trois:Mojave:System:Library:CoreServices:Finder.app:Contents:Resources:en_GB.lproj:ListView.strings
Kind    N224    Type    resources YK:resources trois:Mojave:System:Library:CoreServices:Finder.app:Contents:Resources:en_GB.lproj:Localizable.strings
Kind    N169.35    Type    resources YK:resources trois:Mojave:System:Library:CoreServices:Finder.app:Contents:Resources:en_GB.lproj:Localizable.strings
Kind    300892.title    Type    resources YK:resources trois:Mojave:System:Library:CoreServices:Finder.app:Contents:Resources:en_GB.lproj:MenuBar.strings
Kind    44.title    Type    resources YK:resources trois:Mojave:System:Library:CoreServices:Finder.app:Contents:Resources:en_GB.lproj:ViewOptionsWindow.strings
Kind    Wfk-Hq-wyr.title    Type    resources YK:resources trois:Mojave:System:Library:CoreServices:Finder.app:Contents:Resources:en_GB.lproj:ViewOptionsWindow.strings
Kind    N224    Type    resources YK:resources trois:Mojave:System:Library:CoreServices:Finder.app:Contents:Resources:English.lproj:Localizable.strings
Kind    N169.35    Type    resources YK:resources trois:Mojave:System:Library:CoreServices:Finder.app:Contents:Resources:English.lproj:Localizable.strings

Applescript:

-- Dialog Toolkit Plus.scptd should be in" ~/Library/Script Libraries" or in "/Library/Script Libraries"
use AppleScript version "2.5"
use framework "Foundation"
use framework "AppKit" -- for NSEvent
use scripting additions
use script "Dialog Toolkit Plus" version "1.1.2"

property |⌘| : a reference to current application
property NSEvent : a reference to current application's NSEvent

-- According to a warning sent by an expert, I replaced ":Versions:A:Resources:" by ":Versions:Current:Resources:"
-- in several pathnames because Mojave or Catalina were supposed to use ":C:" as an other spelling fo ":A:"
-- Alas, I discovered that High Sierra, Mojave and Catalina are using the two spellings in the same locations.
-- We may find : "System:Library:Frameworks:AppKit.framework:Versions:C:Resources:Crayons.clr:fr.lproj:Crayons.strings"
-- as well as "System:Library:PrivateFrameworks:PhotoVision.framework:Versions:A:Resources:fr.lproj:scenetaxonomy.strings"
-- in the three systems. So, maybe temporarily, I disabled, the code replacing these names of subfolders

property adjustPaths : false
-- true --> replace subfolders ":A:" by ":current:"
-- false --> doesn't replace subfolders ":A:" by ":current:"

my germaine()

on germaine()
   -- Most of the time I use my set of datas containing resources for High Sierra, Mojave and Catalina
   -- But sometimes I wish to search only in the running system.
   -- If shift is depressed when starting, the script don't use my set of resources but scan the running OS
   set MFlags to NSEvent's modifierFlags() as integer
   set shiftDepressed to not ((MFlags div 131072) mod 2) = 0
   
   # == == == == == == == == == == == == == == == == == == == == == ==
   
   set buildUniqueNameReportOnTheFly to true -- edit to fit your preferences
   
   if buildUniqueNameReportOnTheFly then
       set reportName to ((|⌘|'s NSUUID's UUID()'s UUIDString()) as string) & ".txt"
   else
       set reportName to "matches_sehctam.txt"
   end if
   
   # == == == == == == == == == == == == == == == == == == == == == ==
   
   set accViewWidth to 428
   set {btnOther, btnEnglish, btnCancel} to {"Other", "English", "Cancel"}
   set {theButtons, minWidth} to create buttons {btnCancel, btnEnglish, btnOther} default button btnOther cancel button btnCancel with equal widths
   if minWidth > accViewWidth then set accViewWidth to minWidth -- make sure buttons fit
   
   -- to make it look better, we can get the length of the longest label we will use, and use that to align the controls
   set theLabelStrings to {"Search in:", "Other lproj:", "Text to search:"}
   set maxLabelWidth to max width for labels theLabelStrings
   
   set controlLeft to maxLabelWidth + 8
   set theTop to -8
   -- start from the bottom with a matrix of radio buttons
   set {jobMatrix, theTop} to create matrix {"Exact match", "Begin with", "Contain", "End with"} left inset 0 bottom (theTop + 8) max width (accViewWidth + 36) initial choice "Exact match" without arranged vertically
   
   -- then a labeled popup to define the location where we will search
   -- In system folder
   set inSystemLibrary to "Library from system domain"
   set inSystemPrefPanes to "PreferencePanes from system domain"
   set inFrameworks to "Frameworks from system domain"
   set inFinder to "Finder"
   -- In local folder
   set inLocalApplications to "Applications from local domain"
   set inLocalLibrary to "Library from local domain"
   set inLocalPrefPanes to "PreferencePanes from local domain"
   -- In user folder
   set inUserApplications to "Applications from user domain"
   set inUserLibrary to "Library from user domain"
   set inUserPrefPanes to "PreferencePanes from user domain"
   
   set theLocations to {inSystemLibrary, inSystemPrefPanes, inFrameworks, inFinder, inLocalApplications, inLocalLibrary, inLocalPrefPanes, inUserApplications, inUserLibrary, inUserPrefPanes}
   
   # == == == == == == == == == == == == == == == == == == == == == == ==
   
   set aliasYK to "resources YK"
   set p2alias to (path to documents folder as string) & aliasYK -- an alias pointing upon a sparseimage
   set aliasURL to (|⌘|'s NSArray's arrayWithObject:(p2alias as «class furl»))'s firstObject()
   set forYK to (aliasURL's checkResourceIsReachableAndReturnError:(missing value)) as boolean
   
   if shiftDepressed then set forYK to false
   
   set p2d to path to desktop as string
   if forYK then
       set diskYK to aliasYK & ":"
       set diskURL to (|⌘|'s |NSURL|'s URLByResolvingAliasFileAtURL:aliasURL options:0 |error|:(missing value)) -- mount the disk image
       
       set inResourcesYK to "Folder “Resources YK” in disk image"
       set end of theLocations to inResourcesYK
       set inAllOfThem to "Folder “resources trois” in disk image"
       set end of theLocations to inAllOfThem
       
       set defaultLocation to inFinder -- inResourcesYK
       set defaultLproj to "fr.lproj,French.lproj"
       set defaultString to "" -- "Préférences Système" -- Edit to fit your needs
   else
       set inResourcesYK to missing value -- not used in the menu but must be defined for a test below
       set inAllOfThem to missing value -- not used in the menu but must be defined for a test below
       
       set defaultLocation to inLocalApplications -- inSystemLibrary -- Edit to fit your needs
       set defaultLproj to "fr.lproj,French.lproj" -- "de.lproj,German.lproj" -- Edit to fit your needs
       set defaultString to "" -- Edit to fit your needs
   end if
   
   # == == == == == == == == == == == == == == == == == == == == == == ==
   
   set maxPopupWidth to 329
   set {locationPopup, locationLabel, theTop} to create labeled popup theLocations left inset 0 bottom (theTop + 8) popup width maxPopupWidth max width accViewWidth label text (theLabelStrings's item 1) popup left controlLeft initial choice defaultLocation
   
   -- then a labeled popup to define the Other lprojs to scan
   set availableLprojs to {"ar.lproj", "ca.lproj", "cs.lproj", "da.lproj", "nl.lproj,Dutch.lproj", "el.lproj", "es.lproj,Spanish.lproj", "fi.lproj", "fr.lproj,French.lproj", "de.lproj,German.lproj", "he.lproj", "hi.lproj", "hr.lproj", "hu.lproj", "id.lproj", "it.lproj,Italian.lproj", "ja.lproj,Japanese.lproj", "ko.lproj", "ms.lproj", "nb.lproj", "no.lproj", "pl.lproj,Polish.lproj", "pt-PT.lproj,pt.lproj", "ro.lproj", "ru.lproj", "sk.lproj", "sv.lproj", "th.lproj", "tr.lproj", "uk.lproj", "vi.lproj", "zh_CN.lproj,zh-Hans.lproj", "zh_TW.lproj,zh-Hant.lproj"}
   -- I'm not sure that searching in these other ones is useful
   --set availableLprojs to availableLprojs & {"yue_CN.lproj", "zh_HK.lproj"}
   set {lprojsPopup, lprojsLabel, theTop} to create labeled popup availableLprojs left inset 0 bottom (theTop + 8) popup width maxPopupWidth max width accViewWidth label text (theLabelStrings's item 2) popup left controlLeft initial choice defaultLproj
   
   -- Define the string to search
   set {searchField, searchLabel, theTop, fieldLeft} to create side labeled field defaultString placeholder text "Searched text" left inset 0 bottom (theTop + 12) total width accViewWidth label text (theLabelStrings's item 3) field left controlLeft
   
   -- Define the warning
   set {warningLabel, theTop, warningWidth} to create label "CAUTION: in several french strings, the space before a colon must be NO-BREAK SPACE (alt + space)" left inset controlLeft bottom (theTop + 12) max width accViewWidth - controlLeft aligns left aligned -- with bold type
   
   -- make list of controls and pass to display command
   set allControls to {jobMatrix, locationPopup, locationLabel, lprojsPopup, lprojsLabel, searchField, searchLabel, warningLabel}
   -- controlResults will be in the same order as allControls
   set {buttonName, controlsResults} to display enhanced window "Search in resources" acc view width accViewWidth acc view height theTop acc view controls allControls buttons theButtons initial position {80, 30} with align cancel button
   
   set {exactMatch, searchWhere, unused, choosedLprojs, unused, aValue, unused, unused} to controlsResults
   
   if choosedLprojs is "fr.lproj,French.lproj" then
       set choosedLprojs to choosedLprojs & ",fr_CA.lproj,fr-CA.lproj"
   else if choosedLprojs is "pt-PT.lproj,pt.lproj" then
       set choosedLprojs to choosedLprojs & ",pt_PT.lproj"
   else if choosedLprojs is "es.lproj,Spanish.lproj" then
       set choosedLprojs to choosedLprojs & ",es_419.lproj"
   end if
   
   if choosedLprojs contains "," then -- split it
       set sourceString to |⌘|'s NSString's stringWithString:choosedLprojs
       set otherLprojs to (sourceString's componentsSeparatedByString:",") as list
   else
       set otherLprojs to {choosedLprojs}
   end if
   -- Don't edit this instruction, sometimes, English strings are borrowed from one of these five sets !
   set englishLprojs to {"en.lproj", "English.lproj", "en_AU.lproj", "en_GB.lproj", "en-GB.lproj"}
   
   if buttonName is btnEnglish then -- search in en/English lprojs
       set mainLprojs to englishLprojs
       set auxLprojs to otherLprojs
   else -- search in others language lprojs
       set mainLprojs to otherLprojs
       set auxLprojs to englishLprojs
   end if
   
   set p2LS to path to library folder from system domain as string
   set p2LL to path to library folder from local domain as string
   set p2LU to path to library folder from user domain as string
   
   if searchWhere is inSystemLibrary then
       if forYK then
           set targetDir to diskYK & "vers Systèmes:" --> "resources YK:vers Systèmes:
       else
           set targetDir to p2LS --> "SSD 1000:System:Library:"
       end if
   else if searchWhere is inSystemPrefPanes then
       if forYK then
           set targetDir to diskYK & "vers PreferencePanes:" --> "resources YK:vers PreferencePanes:
       else
           set targetDir to p2LS & "PreferencePanes:" --> "SSD 1000:System:Library:PreferencePanes:"
       end if
   else if searchWhere is inFrameworks then
       if forYK then
           set targetDir to diskYK & "vers Frameworks:"
       else
           set targetDir to p2LS & "Frameworks:" --> "SSD 1000:System:Library: Frameworks:"
       end if
   else if searchWhere is inFinder then
       if forYK then
           set targetDir to diskYK & "vers Finders:"
       else
           set targetDir to path to application id "com.apple.finder" --> alias "SSD 1000:System:Library:CoreServices:Finder.app:"
       end if
   else if searchWhere is inLocalApplications then
       if forYK then
           set targetDir to diskYK & "vers Applications:"
       else
           set targetDir to path to applications folder from local domain --> alias "SSD 1000:Applications:"
       end if
   else if searchWhere is inLocalLibrary then
       if forYK then
           set targetDir to diskYK & "libraries locales:"
       else
           set targetDir to p2LL --> "SSD 1000:Library:"
       end if
   else if searchWhere is inLocalPrefPanes then
       set targetDir to p2LL & "PreferencePanes:" --> "SSD 1000:Library:PreferencePanes:"
   else if searchWhere is inUserLibrary then
       set targetDir to p2LU --> "SSD 1000:Users:**********:Library:"
   else if searchWhere is inUserPrefPanes then
       set targetDir to p2LU & "PreferencePanes:" --> "SSD 1000:Users:**********:Library:PreferencePanes:"
   else if searchWhere is inUserApplications then
       set targetDir to path to applications folder from user domain --> alias "SSD 1000:Users:**********:Applications:"
   else if searchWhere is inResourcesYK then -- this is why the variable inResourcesYK must be defined
       set targetDir to diskYK & "Resources YK:" --> "resources YK:Resources YK:
   else if searchWhere is inAllOfThem then -- this is why the variable inAllOfThem must be defined
       set targetDir to diskYK & "resources trois:" --> "resources YK:resources trois:
   else --if searchWhere is inCatalinaApplications then
       error "wrong choice"
   end if
   
   -- Now, everything is defined we may begin to search
   
   set theManager to |⌘|'s NSFileManager's defaultManager()
   set skipSubdirectoryDescendants to |⌘|'s NSDirectoryEnumerationSkipsSubdirectoryDescendants as integer --> 1
   set skipHidden to |⌘|'s NSDirectoryEnumerationSkipsHiddenFiles as integer --> 4
   
   -- Get every items at first level of the folder. May be symlinks which would be resolved.
   set theURLs to (theManager's enumeratorAtURL:(targetDir as «class furl») includingPropertiesForKeys:{|⌘|'s NSURLVolumeSupportsSymbolicLinksKey} options:(skipSubdirectoryDescendants + skipHidden) errorHandler:(missing value))'s allObjects()
   
   set resolvedURLs to |⌘|'s NSMutableArray's new()
   repeat with aURL in theURLs -- theURLs is an array
       -- check it can resolve a link
       set {theResult, theValue, theError} to (aURL's getResourceValue:(reference) forKey:(|⌘|'s NSURLVolumeSupportsSymbolicLinksKey) |error|:(reference))
       if not (theResult as boolean) then
           -- error (theError's |localizedDescription|() as string) number (theError's code() as integer)
       else if not (theValue as boolean) then
           -- error "This volume does not support symbolic links"
       else
           -- store the resolved URL
           -- may be the original one
           -- may be the one pointed by a Symlink
           (resolvedURLs's addObject:(aURL's |URLByResolvingSymlinksInPath|()))
       end if
   end repeat
   
   set allURLs to |⌘|'s NSMutableArray's new()
   repeat with anURL in resolvedURLs -- resolvedURLs is an array
       set anEnumerator to (theManager's enumeratorAtURL:anURL includingPropertiesForKeys:{} options:skipHidden errorHandler:(missing value))
       -- store the URLs of items embedded in the resolved URLs
       (allURLs's addObjectsFromArray:(anEnumerator's allObjects())) -- add nothing if anURL is a flat file. Not a problem for us.
   end repeat
   if (count allURLs) = 0 then error "No resources files available !"
   
   if adjustPaths then
       set {begOf, endOf} to {"Versions:", ":"}
       set d1 to begOf & "A" & endOf --> ":Versions:A:", string with resolved alias
       set d2 to begOf & "Current" & endOf --> ":Versions:Current:", string with true alias
   end if
   
   set theDescriptors to |⌘|'s NSMutableArray's arrayWithArray:{"theValue" & tab & "theKey" & tab & "auxValue" & tab & "HfsPath"}
   repeat with aURL in allURLs -- allURLs is an NSArray
       -- Get the name of the URL
       set lprojName to (aURL's lastPathComponent()) as string
       -- Is it one of the main lprojs
       if lprojName is in mainLprojs then
           -- Here we have the name of one of the searched lprojs, grab its contents
           set someURLs to (theManager's enumeratorAtURL:aURL includingPropertiesForKeys:{} options:skipHidden errorHandler:(missing value))'s allObjects()
           if someURLs is equal to missing value then exit repeat
           set auxLprojAvailable to false -- initialize the flag
           repeat with anURL in someURLs -- someURLs is an NSArray
               if anURL's pathExtension() as string is "strings" then
                   -- set tableName to (anURL's lastPathComponent()) as string
                   set theDict to (|⌘|'s class "NSDictionary"'s dictionaryWithContentsOfURL:anURL)
                   if theDict is not missing value then
                       set theKeys to theDict's allKeys()
                       repeat with akey in theKeys
                           try
                               set theValue to (theDict's valueForKey:akey) as string
                               
                               if exactMatch is "Exact match" then
                                   considering case
                                       set matching to theValue = aValue
                                   end considering
                               else if exactMatch is "Begin with" then
                                   ignoring case
                                       set matching to theValue starts with aValue
                                   end ignoring
                               else if exactMatch is "Contain" then
                                   ignoring case
                                       set matching to theValue contains aValue
                                   end ignoring
                               else if exactMatch is "End with" then
                                   ignoring case
                                       set matching to theValue ends with aValue
                                   end ignoring
                               end if
                               
                               if matching then
                                   repeat with aLproj in auxLprojs
                                       set tURL to (|⌘|'s NSString's stringWithString:(anURL as «class furl» as string))
                                       set hfsPath to (tURL's stringByReplacingOccurrencesOfString:lprojName withString:aLproj) as string
                                       set auxURL to (|⌘|'s NSArray's arrayWithObject:(hfsPath as «class furl»))'s firstObject()
                                       set auxLprojAvailable to (auxURL's checkResourceIsReachableAndReturnError:(missing value)) as boolean
                                       if auxLprojAvailable then exit repeat
                                   end repeat
                                   if auxLprojAvailable then
                                       set auxDict to (|⌘|'s class "NSDictionary"'s dictionaryWithContentsOfURL:auxURL)
                                       set auxValue to (auxDict's valueForKey:(akey as string))
                                       if auxValue is missing value then
                                           set auxValue to "ENGLISH KEY UNAVAILABLE"
                                       end if
                                   else
                                       set auxValue to "ENGLISH lproj UNAVAILABLE"
                                   end if -- auxLprojAvailable
                                   -- reset the “correct” syntax if the hierachy include alias
                                   set tURL to (|⌘|'s NSString's stringWithString:(anURL as «class furl» as string))
                                   if adjustPaths then
                                       set tURL to (tURL's stringByReplacingOccurrencesOfString:d1 withString:d2)
                                   end if
                                   -- if forYK then set tURL to (tURL's stringByReplacingOccurrencesOfString:p2d withString:"•:")
                                   (theDescriptors's addObject:(theValue & tab & akey & tab & auxValue & tab & (tURL as string)))
                               end if -- matching
                               (*
on error
-- we met a key like "@1 isn't scriptable."
set theData to ">>>>>>>>>>>>>>" & tab & akey & tab & anURL & linefeed
my writeto(targetFile, theData, «class utf8», true) -- create a report
*)

                           end try
                       end repeat
                       -- Scanned a .strings file
                   end if -- theDict is not missing value
               end if -- anURL's pathExtension() as string is "strings"
           end repeat
           -- Scanned every .strings files
       end if -- lprojName is in mainLprojs
   end repeat
   
   set targetFile to p2d & reportName --> "SSD 1000:Users:**********:Desktop:matches_sehctam.txt"
   my writeArray:theDescriptors inFile:targetFile
   
   -- Scanned every lproj files
   tell application "TextEdit"
       activate
       if exists window reportName then close window reportName
       open file targetFile
   end tell
   (*
if forYK then
-- Unmount the disk image
set theNSWorkspace to |⌘|'s NSWorkspace's sharedWorkspace()
theNSWorkspace's unmountAndEjectDeviceAtURL:diskURL |error|:(missing value) -- unmount the sparseimage
end if
*)

end germaine

#=====

on writeArray:anArray inFile:hfsPath
   set theData to (anArray's componentsJoinedByString:linefeed)
   -- save data to new file
   (theData's writeToURL:(hfsPath as «class furl») atomically:true encoding:(|⌘|'s NSUTF8StringEncoding) |error|:(missing value))
end writeArray:inFile:

#=====

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mardi 28 avril 2020 21:49:44

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)