@@ -386,10 +386,10 @@ <h2 data-aos="fade" data-aos-duration="700" data-aos-delay="250">The Blood Pact
386
386
// Setting up the animated counter effect
387
387
let displayAge = 0 ;
388
388
resultElement . innerHTML = `
389
- <div style="font-size: 1rem; color: #2c3e50; text-align: center;">Your biological age is:</div>
390
- <div style="font-size: 2.5rem; color: #4CAF50; font-weight: bold; text-align: center;"><span id="animatedAge">0</span></div>
391
- <div id="yearsText" style="font-size: 1rem; color: #2c3e50; text-align: center;">years</div>
392
- ` ;
389
+ <div style="font-size: 1rem; color: #2c3e50; text-align: center;">Your biological age is:</div>
390
+ <div style="font-size: 2.5rem; color: #4CAF50; font-weight: bold; text-align: center;"><span id="animatedAge">0</span></div>
391
+ <div id="yearsText" style="font-size: 1rem; color: #2c3e50; text-align: center;">years</div>
392
+ ` ;
393
393
394
394
if ( isFirstTimeAnimation ) {
395
395
// Set the flag to false after the first run
@@ -443,7 +443,7 @@ <h2 data-aos="fade" data-aos-duration="700" data-aos-delay="250">The Blood Pact
443
443
apUnit : '1' , // U/L
444
444
wbcUnit : '1' // 1000 cells/μL
445
445
} ,
446
- en_GB : {
446
+ GB : {
447
447
albuminUnit : '1' , // g/L (SI unit, common in the UK)
448
448
creatinineUnit : '1' , // µmol/L
449
449
glucoseUnit : '1' , // mmol/L
@@ -514,9 +514,11 @@ <h2 data-aos="fade" data-aos-duration="700" data-aos-delay="250">The Blood Pact
514
514
515
515
// Detect and apply preferences based on language
516
516
function applyLanguagePreferences ( ) {
517
- const language = navigator . language || 'default' ; // Get browser language
518
- const languageKey = language . replace ( '-' , '_' ) ; // Replace dash with underscore
519
- const preferences = unitPreferences [ languageKey ] || unitPreferences . default ;
517
+ const language = navigator . language || 'default' ; // e.g., 'en-US'
518
+ const countryMatch = language . match ( / [ - _ ] ( \w { 2 } ) $ / ) ; // Extract country code)
519
+ const countryCode = countryMatch ? countryMatch [ 1 ] . toUpperCase ( ) : '' ;
520
+
521
+ const preferences = unitPreferences [ countryCode ] || unitPreferences . default ;
520
522
521
523
// Apply preferences to unit select elements
522
524
for ( const [ unitId , unitValue ] of Object . entries ( preferences ) ) {
0 commit comments