Replaces the greeting (typically "Hi") in an email template with a local greeting (e.g. "Hallo" in German) based on the email domain's TLD.
Accomodates changing the greeting based on the email sequence number (e.g. for Australia, "Hi" in the first email, "G'day" in the second email).
def generate_local_greeting(email, input_string, email_seq=1):
if email.endswith('ae'):
input_string = input_string.replace('{hi}', "As-salamu alaykum ")
elif email.endswith('at'):
input_string = input_string.replace('{hi}', "Hallo ")
elif email.endswith('au'):
if email_seq == 1:
input_string = input_string.replace('{hi}', "Hi ")
else:
input_string = input_string.replace('{hi}', "G'day ")
elif email.endswith('bg'):
input_string = input_string.replace('{hi}', "Zdravey ")
elif email.endswith('cz'):
if email_seq == 1:
input_string = input_string.replace('{hi}', "Dobrý den ")
else:
input_string = input_string.replace('{hi}', "Ahoj ")
elif email.endswith('de'):
input_string = input_string.replace('{hi}', "Hallo ")
elif email.endswith('dk'):
input_string = input_string.replace('{hi}', "Hej ")
elif email.endswith('dz'):
input_string = input_string.replace('{hi}', "As-salāmu ʿalaykum ")
elif email.endswith('ee'):
input_string = input_string.replace('{hi}', "Tere ")
elif email.endswith('es'):
input_string = input_string.replace('{hi}', "¡Hola! ")
elif email.endswith('fi'):
input_string = input_string.replace('{hi}', "Hei ")
elif email.endswith('fr'):
input_string = input_string.replace('{hi}', "Bonjour ")
elif email.endswith('hr'):
if email_seq == 1:
input_string = input_string.replace('{hi}', "Dobar dan ")
else:
input_string = input_string.replace('{hi}', "Zdravo ")
elif email.endswith('hu'):
input_string = input_string.replace('{hi}', "Szia ")
elif email.endswith('is'):
input_string = input_string.replace('{hi}', "Halló ")
elif email.endswith('it'):
if email_seq == 1:
input_string = input_string.replace('{hi}', "Buongiorno ")
else:
input_string = input_string.replace('{hi}', "Ciao ")
elif email.endswith('lu'):
input_string = input_string.replace('{hi}', "Moien ")
elif email.endswith('nl'):
if email_seq == 1:
input_string = input_string.replace('{hi}', "Goedendag ")
else:
input_string = input_string.replace('{hi}', "Hallo ")
elif email.endswith('no'):
if email_seq == 1:
input_string = input_string.replace('{hi}', "Hallo ")
else:
input_string = input_string.replace('{hi}', "Hei ")
elif email.endswith('pl'):
input_string = input_string.replace('{hi}', "Cześć ")
elif email.endswith('pt'):
input_string = input_string.replace('{hi}', "Oi ")
elif email.endswith('ro'):
if email_seq == 1:
input_string = input_string.replace('{hi}', "Bună ziua ")
else:
input_string = input_string.replace('{hi}', "Salut ")
elif email.endswith('se'):
input_string = input_string.replace('{hi}', "Hej ")
elif email.endswith('si'):
input_string = input_string.replace('{hi}', "Pozdravljeni ")
elif email.endswith('sk'):
input_string = input_string.replace('{hi}', "Dobrý den ")
elif email.endswith('tr'):
input_string = input_string.replace('{hi}', "Merhaba ")
elif email.endswith('tz'):
input_string = input_string.replace('{hi}', "Jambo ")
else:
if email_seq == 1:
input_string = input_string.replace('{hi}', "Hello ")
else:
input_string = input_string.replace('{hi}', "Hi ")
return input_string
Or simplified, based on country code:
def get_local_greeting(country_code):
try:
if country_code.lower() == 'ae':
return "As-salamu alaykum"
elif country_code.lower() == 'at':
return "Hallo"
elif country_code.lower() == 'au':
return "G'day"
elif country_code.lower() == 'bg':
return "Zdravey"
elif country_code.lower() == 'cz':
return "Ahoj"
elif country_code.lower() == 'de':
return "Hallo"
elif country_code.lower() == 'dk':
return "Hej"
elif country_code.lower() == 'dz':
return "As-salāmu ʿalaykum"
elif country_code.lower() == 'ee':
return "Tere"
elif country_code.lower() == 'es':
return "¡Hola!"
elif country_code.lower() == 'fi':
return "Hei"
elif country_code.lower() == 'fr':
return "Bonjour"
elif country_code.lower() == 'hr':
return "Dobar dan"
elif country_code.lower() == 'hu':
return "Szia"
elif country_code.lower() == 'is':
return "Halló"
elif country_code.lower() == 'it':
return "Buongiorno"
elif country_code.lower() == 'lu':
return "Moien"
elif country_code.lower() == 'nl':
return "Goedendag"
elif country_code.lower() == 'no':
return "Hei"
elif country_code.lower() == 'pl':
return "Cześć"
elif country_code.lower() == 'pt':
return "Oi"
elif country_code.lower() == 'ro':
return "Salut"
elif country_code.lower() == 'se':
return "Hej"
elif country_code.lower() == 'si':
return "Pozdravljeni"
elif country_code.lower() == 'sk':
return "Dobrý den"
elif country_code.lower() == 'tr':
return "Merhaba"
elif country_code.lower() == 'tz':
return "Jambo"
else:
return "Hi"
except:
return "Hi"