“, additional_buyer_script + “\n“, 1) # Patch totalIncome / totalDebts to use independent engines if possible. # replace their function bodies text = re.sub( r’function totalIncome\(\)\{\s*return .*?\n\}’, ”’function totalIncome(){ return n(incEmployment.value)+n(incBusiness.value)+n(incRental.value)+n(incInvestment.value)+n(incOther.value)+n(incCo.value) +(typeof window.getAdditionalBuyerIncome===”function”?window.getAdditionalBuyerIncome():0) }”’, text, count=1, flags=re.S ) text = re.sub( r’function totalDebts\(\)\{\s*return .*?\n\}’, ”’function totalDebts(){ return […document.querySelectorAll(“.monthlyDebt”)].reduce((a,e)=>a+n(e.value),0) +(typeof window.getAdditionalBuyerDebt===”function”?window.getAdditionalBuyerDebt():0) }”’, text, count=1, flags=re.S ) # —————————– # 4) Language auto-translation # —————————– language_script = r”’ ”’ text = text.replace(““, language_script + “\n“, 1) # —————————– # 5) Top currency wording and converter results order # —————————– text = text.replace( ‘Client Currency Result‘, ‘Client Currency Result — shown in green‘ ) text = text.replace( ‘United States Currency‘, ‘United States Currency — primary amount‘ ) # Currency converter results: USD should be black, client green. # CSS already overrides classes. # Save out = Path(“/mnt/data/Home_Buyer_360_USD_First_Language_AdditionalBuyerFixed.html”) out.write_text(text, encoding=”utf-8″) # Basic diagnostics print(“Created:”, out) print(“Size:”, f”{out.stat().st_size:,} bytes”) print(“Language selector:”, ‘id=”languageSelector”‘ in text) print(“Add buyer button:”, ‘id=”addBuyerButton”‘ in text) print(“Independent buyer engine:”, ‘additional-buyer-engine-v4’ in text) print(“USD-first CSS:”, “USD FIRST / CLIENT CURRENCY SECOND” in text)