Problem in KConfig with language_territory locale strings

Dr. Juergen Pfennig info at j-pfennig.de
Fri Feb 6 15:47:01 GMT 2004


On Friday 06 February 2004 13:26, Luciano Montanaro wrote:
> Can't that be done anyway by the user?
> A German-speaking Swiss could add languages "de_CH" and "de" to the
> languages control panel, and the application can pick the "de" catalog if
> there is no "de_CH" catalog present.

Not in this case. I'm talking about the .desktop files and how they are 
handled in kdecore/KConfig here - not about I18N. In the I18N stuff the 
algorithm you mentioned should be used.

Parts of the logic for handling config files in KDE seem to be quite old and 
could profit from a "refresh". It is exactly the algorithm that you mentioned 
that is missing. The current KDE "low level" parser requires an exact match 
for a "country_territory" string. Initially this was added to the speed up 
parsing, e.g. ignore unneeded data as early as possible (approximately 80%).

So I propose the following to update the "low level" algorithm (and I 
currently implement it in a new parser):

 // This is symbolic and simplified! Not a real implementation!
 // This is symbolic and simplified! Not a real implementation!
 // This is symbolic and simplified! Not a real implementation!
   bool filterLocale(char* sFilter)
   {	int iFilter = strlen(sFilter);
        if(iFilter != 2 && iFilter != 5) return false;   // something wrong
        int iCurrent = strlen(sCurrentLocale);
        if(iCurrent != 2 && iCurrent != 5) return false;   // something wrong
 
        // try an exact match
        if(iCurrent == iFilter &&
           memcmp(sFilter, sCurrentLocale, iFilter) == 0) return true;
        // compare language only
       if(iCurrent > 2) return false;
       return memcmp((sFilter, sCurrentLocale, 2) == 0;
  }

In the layers above the parser some "higher level" algorithm will handle the 
ambiguities introduced by the fact that a filter "de_CH" would now match "de" 
and "de_CH" and it could now implement a fallback from "de_CH" to "de". On 
the application level nothing would change - the whole thing is internal to 
KConfig.

Yours Jürgen




More information about the kde-core-devel mailing list