* @param {string} content * @returns {Map }
(content)
| 106 | * @returns {Map<string, string>} |
| 107 | */ |
| 108 | function parseLocale(content) { |
| 109 | /** @type {Map<string, string>} */ |
| 110 | const messages = new Map(); |
| 111 | const lines = content.split('\n'); |
| 112 | let id = ''; |
| 113 | for (let i = 0; i < lines.length; i++) { |
| 114 | const line = lines[i]; |
| 115 | if (line.startsWith('@')) { |
| 116 | id = line.substring(1); |
| 117 | } else if (line.startsWith('#')) { |
| 118 | // Ignore |
| 119 | } else if (messages.has(id)) { |
| 120 | const message = messages.get(id); |
| 121 | messages.set(id, `${message}\n${line}`); |
| 122 | } else { |
| 123 | messages.set(id, line); |
| 124 | } |
| 125 | } |
| 126 | messages.forEach((value, id) => { |
| 127 | messages.set(id, value.trim()); |
| 128 | }); |
| 129 | return messages; |
| 130 | } |
| 131 | |
| 132 | /** |
| 133 | * @param {Map<string, string>} messages |
no test coverage detected