<commit_before>#include <proto/locale.h>

#include "NiKomStr.h"
#include "Logging.h"

#include "Languages.h"

extern struct System *Servermem;
extern int nodnr, inloggad;
struct Catalog *g_Catalog;

static char *localeLang[] = {
  "english",
  "svenska"
};

void LoadCatalogForUser(void) {
  int lang = Servermem->inne[nodnr].language;
  
  CloseCatalog(g_Catalog);
  g_Catalog = NULL;
  if(lang < 0 || lang > 1) {
    LogEvent(SYSTEM_LOG, WARN, "User %d has invalid language setting (%d).", inloggad, lang);
    return;
  }
  g_Catalog = OpenCatalog(NULL, "NiKom.catalog", OC_Language, localeLang[lang], TAG_DONE);
  if(g_Catalog == NULL) {
    LogEvent(SYSTEM_LOG, WARN, "Could not load catalog for language %s.", localeLang[lang]);
  }
}
<commit_msg>Fixing bogus log warning when changing language to english.<commit_after>#include <proto/locale.h>

#include "NiKomStr.h"
#include "Logging.h"

#include "Languages.h"

extern struct System *Servermem;
extern int nodnr, inloggad;
struct Catalog *g_Catalog;

static char *localeLang[] = {
  "english",
  "svenska"
};

void LoadCatalogForUser(void) {
  int lang = Servermem->inne[nodnr].language, err;
  
  CloseCatalog(g_Catalog);
  g_Catalog = NULL;
  if(lang < 0 || lang > 1) {
    LogEvent(SYSTEM_LOG, WARN, "User %d has invalid language setting (%d).", inloggad, lang);
    return;
  }
  if(lang == 0) {
    return;
  }
  g_Catalog = OpenCatalog(NULL, "NiKom.catalog", OC_Language, localeLang[lang], TAG_DONE);
  if(g_Catalog == NULL) {
    err = IoErr();
    if(err != 0) {
      LogEvent(SYSTEM_LOG, WARN, "Could not load catalog for language %s (err = %d).",
               localeLang[lang], err);
    }
  }
}

{'fraction_non_alphanumeric': 0.14388489208633093, 'fraction_numerical': 0.0035971223021582736, 'mean_word_length': 4.057575757575758, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2176446', 'n_tokens_mistral': 627, 'n_tokens_neox': 617, 'n_words': 151}