# Based on Mojolicious::Plugin::Number::Commify
my $THOUSAND_SEP_RE = qr/(
  ^[-+]?           # beginning of number.
  \d+?             # first digits before first comma
  (?=              # followed by, (but not included in the match) :
    (?>(?:\d{3})+) # some positive multiple of three digits.
    (?!\d)         # an *exact* multiple, not x * 3 + 1 or whatever.
  )|               # or:
  \G\d{3}          # after the last group, get three digits
  (?=\d)           # but they have to have more digits after them.
)/x;

{
  _ => sub { $_->locale },
  de => {
    numf => sub {
      shift;
      my %val = @_;
      my $num = $val{number} or return 0;
      $num =~ s/$THOUSAND_SEP_RE/$1\./g;
      return $num;
    },
    about => 'Über KorAP',
    login => 'Anmelden',
    logout => 'Abmelden',
    register => 'Registrieren',
    pwdforgotten => 'Password vergessen?',
    # TODO: use document.write() refering to vc.getName()!
    searchjob => '»<%== $q %>« <% if (param("collection")) { %>im definierten Korpus <% } %>mit <%== loc("QL_" . $ql, "unbekannter Anfragesprache") %>',
    searchtitle => 'KorAP: Finde <%== loc("searchjob") %>',
    searchplaceholder => 'Finde ...',
    go => 'Los!',
    news => 'Neuigkeiten & Ankündigungen',
    in => 'in',
    by => 'von',
    pwd => 'Passwort',
    email => 'Email',
    username => 'Benutzername',
    with => 'mit',
    glimpse => {
      desc => 'Zeige nur die ersten Treffer in beliebiger Reihenfolge'
    },
    activateJS => 'Für den vollen Funktionsumfang aktivieren Sie bitte JavaScript!',
    faq => 'Häufige Fragen',
    tutorial => 'Einführung',
    notAvailInCorpus => 'Im vorliegenden Korpus nicht verfügbar',
    pubOn => 'veröffentlicht am',
    matchCount => 'Treffer',
    noMatches => 'Es wurden keine Treffer für <%== loc("searchjob") %> gefunden.',
    notFound => '404 - Seite nicht gefunden',
    notIssued => 'Die Aktion konnte nicht durchgeführt werden.',
    backendNotAvailable => 'Das Backend ist nicht verfügbar unter <code><%= app->korap->api =></code>!',
    jsFile => 'kalamar-<%= $Kalamar::VERSION %>-de.js',
    underConstruction => 'In Vorbereitung!',
    korap => {
      -short => 'KorAP',
      desc => 'KorAP - Korpusanalyseplattform der nächsten Generation',
      overview => 'KorAP - Übersicht',
      keywords => 'KorAP, DeReKo, Korpussuche, IDS Mannheim, Leibniz-Institut für Deutsche Sprache',
    },
    privacy => 'Datenschutz',
    imprint => 'Impressum',
    settings => 'Einstellungen',
    Template => {
      intro => 'de/intro',
      doc => {
        ql => {
          'poliqarp-plus' => 'de/doc/ql/poliqarp-plus'
        },
        api => {
          'koralquery' => 'de/doc/api/koralquery'
        },
        data => {
          'annotation' => 'de/doc/data/annotation'
        },
        korap => {
          'kalamar' => 'de/doc/korap/kalamar',
          'karang' => 'de/doc/korap/karang',
          'koral' => 'de/doc/korap/koral',
          'krill' => 'de/doc/korap/krill',
          'kustvakt' => 'de/doc/korap/kustvakt'
        }
      }
    },
    Nav => {
      'ql' => 'Anfragesprachen',
      '#segments' => 'Einfache Segmente',
      '#complex' => 'Komplexe Segmente',
      '#spans' => 'Span-Segmente',
      '#paradigmatic-operators' => 'Paradigmatische Operatoren',
      '#syntagmatic-operators' => 'Syntagmatische Operatoren',
      '#class-operators' => 'Klassen-Operatoren',
      'regexp' => 'Reguläre Ausdrücke',
      'data' => 'Daten',
      'corpus' => 'Korpora',
      'annotation' => 'Annotationen',
      '#default-foundries' => 'Standard Foundries',
      'faq' => 'Häufig gestellte Fragen'
    }
  },
  -en => {
    jsFile => 'kalamar-<%= $Kalamar::VERSION %>-en.js',
    numf => sub {
      shift;
      my %val = @_;
      my $num = $val{number} or return 0;
      $num =~ s/$THOUSAND_SEP_RE/$1\,/g;
      return $num;
    },
    about => 'About KorAP',
    login => 'Login',
    logout => 'Logout',
    register => 'Register',
    pwdforgotten => 'Password forgotten?',
    go => 'Go!',
    news => 'News & Announcements',
    # TODO: use document.write() refering to vc.getName()!
    searchjob => '»<%== $q %>« <% if (param("collection")) { %>in the defined corpus <% } %>with <%== loc("QL_". $ql, "unknown query language") %>',
    searchtitle => 'KorAP: Find <%== loc("searchjob") %>',
    searchplaceholder => 'Find ...',
    in => 'in',
    by => 'by',
    pwd => 'Password',
    email => 'Email',
    username => 'Username',
    with => 'with',
    notAvailInCorpus => 'Not available in the current corpus',
    pubOn => 'published on',
    matchCount => '<%= quant($found, "match", "matches") %>',
    noMatches => 'There were no matches found for <%== loc("searchjob") %>.',
    notFound => '404 - Page not found',
    notIssued => 'Unable to perform the action.',
    backendNotAvailable => 'The backend is not available at <code><%= app->korap->api %></code>!',
    glimpse => {
      -short => 'Glimpse',
      desc => 'Just show the first matches in arbitrary order'
    },
    activateJS => 'To make use of all features, please activate JavaScript!',
    faq => 'F.A.Q.',
    underConstruction => 'Under Construction!',
    tutorial => 'Tutorial',
    korap => {
      -short => 'KorAP',
      desc => 'KorAP - Corpus Analysis Platform',
      overview => 'KorAP - Overview',
      region => 'DE-BW',
      placename => 'Mannheim',
      keywords => 'KorAP, DeReKo, Corpus Query Platform, IDS Mannheim, Leibniz Institute for the German Language'
    },
    QL => {
      poliqarp => 'Poliqarp',
      cosmas2 => 'Cosmas II',
      annis => 'Annis QL',
      cql => 'CQL v1.2',
      fcsql => 'FCSQL'
    },
    privacy => 'Privacy',
    imprint => 'Imprint',
    settings => 'Settings',
    Template => {
      intro => 'intro',
      doc => {
        ql => {
          'poliqarp-plus' => 'doc/ql/poliqarp-plus'
        },
        api => {
          'koralquery' => 'doc/api/koralquery'
        },
        data => {
          'annotation' => 'doc/data/annotation'
        },
        korap => {
          'kalamar' => 'doc/korap/kalamar',
          'karang' => 'doc/korap/karang',
          'koral' => 'doc/korap/koral',
          'krill' => 'doc/korap/krill',
          'kustvakt' => 'doc/korap/kustvakt'
        }
      }
    },
    Nav => {
      'ql' => 'Query Languages',
      '#segments' => 'Simple Segments',
      '#complex' => 'Complex Segments',
      '#spans' => 'Span Segments',
      '#paradigmatic-operators' => 'Paradigmatic Operators',
      '#syntagmatic-operators' => 'Syntagmatic Operators',
      '#class-operators' => 'Class Operators',
      'regexp' => 'Regular Expressions',
      'data' => 'Data',
      'corpus' => 'Corpora',
      'annotation' => 'Annotations',
      '#default-foundries' => 'Default Foundries',
      'faq' => 'F.A.Q.'
    }
  },
  Piwik => {
    en => {
      'HowToOptOut' => 'How to opt-out from Piwik/Matomo tracking?'
    },
    de => {
      'HowToOptOut' => 'Wie kann ich die Weitergabe meiner Daten per Matomo/Piwik unterbinden?'
    }
  }
};
