Monday, October 27, 2008

Digging into Spotlights localization

On Mac OS X 10.5 Spotlights localization seems somewhat flawed. I never managed to get the german Metadata Predicates working. If you wanted to search for dates like "Datum:Heute" spotlight simply did not return any results.

The documentation on Apples website is surprisingly poor. Helpful where the following:

and a russian site

In the russian version of Mac OS localized search predicates seem to be partially disfunctional too. In my german localization it was especially the Date predicate that did not work.

Spotlight/Finder Search Localization information is stored in three different places.

1. Metadata Framework
2. Spotlight Application
3. Finder Application

1. /System/Library/Frameworks/CoreServices.framework/

Relevant files: MDPredicate.plist (maps predicate variable names like "DOCUMENTS" or "TODAY" to metadata queries formulated in the query language which is documented on the apple developer site

Inside the localization directories (here: German.lproj): MDPredicateKeywords.plist: maps the localized predicate descriptions to the predicate variables described before e.g. TODAY -> Datum:Heute. I replaced this file with the english version, in order to get the predicates working again. This implies that a localization issue is the cause of the malfunction.

The file schema.strings in the same directory has relevant information about all possible file attributes that can be used in the spotlight queries. Look for "ShortName".

2. /System/Library/Frameworks/CoreServices/ contains localization information for the spotlight menu and the drop-down result list

3. /System/Library/Frameworks/CoreServices/
The file MDSliceAttributeNameOverrides.strings overrides as its name implies attribute names defined in the schema.strings file in the metadata framework. A comment explains that this is done to correct certain attributes that look "awkward" in the Finder

MDSliceStrings.strings defines the strings for the advanced search in finder. A comment implies that special care has to be taken here in order to avoid conflicts with attributes overridden in MDSliceAttributeNameOverrides.strings

MDDateFormatter.strings contains Date information.