<commit_before>// We store messages as code instead of as JSON because JSON sucks.
// - We can use comments, they are useful for translations.
// - Multiline strings ftw.
// - Translations are eslinted.
export function messagesToCode(messages) {
  messages.sort((a, b) => a.id.localeCompare(b.id));
  return `/* eslint-disable max-len, quote-props, quotes */
export default ${JSON.stringify(messages, null, 2)};<commit_msg>Generate messages with trailing commas<commit_after>// We store messages as code instead of as JSON because JSON sucks.
// - We can use comments, they are useful for translations.
// - Multiline strings ftw.
// - Translations are eslinted.
export function messagesToCode(messages) {
  messages.sort((a, b) => a.id.localeCompare(b.id));
  const messagesString = JSON
    .stringify(messages, null, 2)
    // Add trailing commas.
    .replace(/\n {2}\}/g, ',\n  }')
    .replace(/\}\n\]/g, '},\n]');

  return `/* eslint-disable max-len, quote-props, quotes */
export default ${messagesString};
{'fraction_non_alphanumeric': 0.1458128078817734, 'fraction_numerical': 0.002955665024630542, 'mean_word_length': 3.618181818181818, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '5361632', 'n_tokens_mistral': 311, 'n_tokens_neox': 300, 'n_words': 103}