<commit_before>class @Locale

  constructor: ->

  # @param dialoguesFilename [String] path of the JSON file containing all the localized dialogue lines
  loadDialogueLines: (dialoguesFilename) =>
    $.getJSON(dialoguesFilename, @buildDialogueLines)
      .done(-> console.log "[LOAD] Loaded localized dialogue lines")
      .fail(-> console.log "[LOAD] Failed loading localized dialogues")


# Build dictionary of dialogue lines from JSON data
  #
  # @param data [dictionary] dictionary of dialogue lines with JSON data
  buildDialogueLines: (data) =>
#    console.log "[CALL] buildDialogueLines"
    @dialogueLines = data

  # Return localized string for a dialogue or text line
  #
  # @param lineID [String] line string identifier
  getLine: (lineID) =>
    # split lineID in format "mkX_dY_ZZ" into "mkX/dY/ZZ" the key path to access the dictionary value
    # (or _tY_ for a text file content)
    [missionID, textNo, lineNo] = lineID.split '_'
    @dialogueLines[missionID][textNo][lineNo]<commit_msg>[LOCALE] Throw error on line not found<commit_after>class @Locale

  constructor: ->

  # @param dialoguesFilename [String] path of the JSON file containing all the localized dialogue lines
  loadDialogueLines: (dialoguesFilename) =>
    $.getJSON(dialoguesFilename, @buildDialogueLines)
      .done(-> console.log "[LOAD] Loaded localized dialogue lines")
      .fail(-> console.log "[LOAD] Failed loading localized dialogues")


# Build dictionary of dialogue lines from JSON data
  #
  # @param data [dictionary] dictionary of dialogue lines with JSON data
  buildDialogueLines: (data) =>
#    console.log "[CALL] buildDialogueLines"
    @dialogueLines = data

  # Return localized string for a dialogue or text line
  #
  # @param lineID [String] line string identifier
  getLine: (lineID) =>
    # split lineID in format "mkX_dY_ZZ" into "mkX/dY/ZZ" the key path to access the dictionary value
    # (or _tY_ for a text file content)
    [missionID, textNo, lineNo] = lineID.split '_'
    line = @dialogueLines[missionID][textNo][lineNo]
    if not line?
      throw new Error "Locale for lineID #{lineID} not found"
    line

{'fraction_non_alphanumeric': 0.0948155067725362, 'fraction_numerical': 0.0, 'mean_word_length': 3.993006993006993, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '3067455', 'n_tokens_mistral': 636, 'n_tokens_neox': 614, 'n_words': 227}