+ /** get the locale part */
+ StrBufExtract_token(SBuf, Buf, 0, ';');
+
+ /** get the lang part, which should be allways there */
+ extract_token(&ls->lang[0],
+ ChrPtr(SBuf),
+ 0, '-',
+ sizeof(ls->lang));
+
+ /** get the area code if any. */
+ if (StrBufNum_tokens(SBuf, '-') > 1) {
+ extract_token(&ls->region[0],
+ ChrPtr(SBuf),
+ 1, '-',
+ sizeof(ls->region));
+ }
+ else { /** no ara code? use lang code */
+ blen=strlen(&ls->lang[0]);
+ memcpy(&ls->region[0], ls->lang, blen);
+ ls->region[blen] = '\0';
+ }
+
+ /* area codes are uppercase */
+ blen = strlen(&ls->region[0]);
+ for (j = 0; j < blen; j++)
+ {
+ int chars;
+ chars = toupper(ls->region[j]);
+ ls->region[j] = (char)chars;/** \todo ?! */
+ }
+ snprintf(&lbuf[0],
+ sizeof(lbuf),
+ "%s_%s",
+ &ls->lang[0],
+ &ls->region[0]);
+
+ /** check if we have this lang */
+ ls->availability = 1;
+ ls->selectedlang = -1;
+ for (j = 0; j < nLocalesLoaded; j++) {
+ int result;
+ /** match against the LANG part */
+ result = strcasecmp(&ls->lang[0], AvailLangLoaded[j]);
+ if ((result < 0) && (result < ls->availability)){
+ ls->availability = result;
+ ls->selectedlang = j;
+ }
+ /** match against lang and locale */
+ if (0 == strcasecmp(&lbuf[0], AvailLangLoaded[j])){
+ ls->availability = 0;
+ ls->selectedlang = j;
+ j = nLocalesLoaded;