Mercurial Hosting > lang
comparison src/chat.js @ 74:64e35a92d163
add translation
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 28 Aug 2025 13:31:46 -0600 |
parents | 60ebb333b40c |
children |
comparison
equal
deleted
inserted
replaced
73:60ebb333b40c | 74:64e35a92d163 |
---|---|
157 startRecording(); | 157 startRecording(); |
158 } else { | 158 } else { |
159 recorder.stop(); | 159 recorder.stop(); |
160 } | 160 } |
161 } | 161 } |
162 | |
163 function showSelected(select) { | |
164 if( select.value !== 'show_trans' ) | |
165 return; | |
166 let top = select.parentNode.parentNode; | |
167 let trans = top.querySelector('div[trans=needed]'); | |
168 if( !trans ) | |
169 return; | |
170 let msg = top.getAttribute('msg'); | |
171 let message = top.querySelector('div[message]'); | |
172 let text = textContent(message); | |
173 let url = `translate.js?msg=${msg}&text=${encodeURIComponent(text)}&language=${chat.language}`; | |
174 ajax(url); | |
175 showWaitingAiIcon(); | |
176 } | |
177 | |
178 function translated(msg,text) { | |
179 hideWaitingAiIcon(); | |
180 let top = document.querySelector(`div[msg="${msg}"]`); | |
181 let trans = top.querySelector('div[trans]'); | |
182 trans.setAttribute('trans',''); | |
183 trans.innerHTML = text; | |
184 } |