PageSourceSearch

https://stelliverse.fr/experience/english.mjs

js stelliverse.fr collected 2026-10-03 20:08:56 UTC 2,445 bytes, 44 lines download raw bytes

1// Local preview translation of site chrome only. Never translate legal bodies,
2// captured product Shadow DOM, game terminology, or the isolated application.
3export function translateValue(value,dictionary){
4 const key=value.trim();
5 let translated=dictionary[key];
6 if(translated===undefined){
7  const percentage=key.match(/^([\d.]+) % de la traduction affichée$/);
8  const enlarge=key.match(/^Voir (.+) en grand$/);
9  if(percentage)translated=`${percentage[1]}% of the translation visible`;
10  else if(enlarge)translated=`View ${dictionary[enlarge[1]]||enlarge[1]} full size`;
11  else if(key.endsWith(' ↓')&&dictionary[key.slice(0,-2)])translated=dictionary[key.slice(0,-2)]+' ↓';
12 }
13 return translated===undefined?value:value.replace(key,()=>translated);
14}
15
16export function mountEnglish(doc,dictionary){
17 if(doc.documentElement.lang!=='en'||!doc.getElementById('journey'))return;
18 const attributes=['alt','aria-label','aria-valuetext','title'];
19 function translate(node){
20  if(node.nodeType===3){
21   if(node.parentElement?.closest('script,style,iframe'))return;
22   const value=translateValue(node.data,dictionary);if(value!==node.data)node.data=value;
23  }else if(node.nodeType===1){
24   if(node.matches('script,style'))return;
25   for(const attr of attributes){const original=node.getAttribute(attr);if(original!==null){const value=translateValue(original,dictionary);if(value!==original)node.setAttribute(attr,value);}}
26   for(const child of node.childNodes)translate(child);
27  }
28 }
29 translate(doc.body);
30 const observer=new MutationObserver(records=>{
31  for(const record of records){
32   if(record.type==='childList')record.addedNodes.forEach(translate);
33   else if(record.type==='attributes'){
34    const original=record.target.getAttribute(record.attributeName);
35    if(original!==null){const value=translateValue(original,dictionary);if(value!==original)record.target.setAttribute(record.attributeName,value);}
36   }else translate(record.target);
37  }
38 });
39 observer.observe(doc.body,{subtree:true,childList:true,characterData:true,attributes:true,attributeFilter:attributes});
40 addEventListener('pagehide',()=>observer.disconnect(),{once:true});
41}
42if(typeof document!=='undefined'&&document.documentElement.lang==='en'){
43 try{const response=await fetch('/experience/site-en.json');if(response.ok)mountEnglish(document,await response.json());}catch{/* Server-rendered English stays readable when the extra dictionary is unavailable. */}
44}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.