diff --git a/lambda/py/lambda_function.py b/lambda/py/lambda_function.py index c992b06..b764619 100644 --- a/lambda/py/lambda_function.py +++ b/lambda/py/lambda_function.py @@ -12,7 +12,6 @@ import requests import calendar import gettext -import prompts from datetime import datetime from pytz import timezone from ask_sdk_s3.adapter import S3Adapter @@ -46,16 +45,14 @@ def can_handle(self, handler_input): def handle(self, handler_input): data = handler_input.attributes_manager.request_attributes["_"] - speech = data[prompts.WELCOME_MSG] - reprompt = data[prompts.WELCOME_REPROMPT_MSG] + speech = data["WELCOME_MSG"] + reprompt = data["WELCOME_REPROMPT_MSG"] handler_input.response_builder.speak(speech).ask(reprompt) return handler_input.response_builder.response class HasBirthdayLaunchRequestHandler(AbstractRequestHandler): - """ - Handler for launch after they have set their birthday - """ + """Handler for launch after they have set their birthday""" def can_handle(self, handler_input): # extract persistent attributes and check if they are all present @@ -72,7 +69,7 @@ def handle(self, handler_input): day = int(attr['day']) data = handler_input.attributes_manager.request_attributes["_"] - error_timezone_speech = data[prompts.ERROR_TIMEZONE_MSG] + error_timezone_speech = data["ERROR_TIMEZONE_MSG"] # get skill locale from request skill_locale = handler_input.request_envelope.request.locale @@ -127,35 +124,35 @@ def handle(self, handler_input): # if it is not the user birthday if now_date != next_birthday: if diff_days > 1: - speak_output = data[prompts.WELCOME_BACK_MSG_plural].format(diff_days, current_year-year) + speak_output = data["WELCOME_BACK_MSG_plural"].format(diff_days, current_year-year) if diff_days < 2: - speak_output = data[prompts.WELCOME_BACK_MSG].format(diff_days, current_year - year) + speak_output = data["WELCOME_BACK_MSG"].format(diff_days, current_year - year) # if it is the user birthday else: if (current_year - year > 1): - speak_output = data[prompts.HAPPY_BIRTHDAY_MSG_plural].format(current_year - year) + speak_output = data["HAPPY_BIRTHDAY_MSG_plural"].format(current_year - year) if current_year - year < 2: - speak_output = data[prompts.HAPPY_BIRTHDAY_MSG].format(current_year - year) + speak_output = data["HAPPY_BIRTHDAY_MSG"].format(current_year - year) # all other locales else: - speak_output = data[prompts.HAPPY_BIRTHDAY_MSG].format(current_year - year) + speak_output = data["HAPPY_BIRTHDAY_MSG"].format(current_year - year) # if it is not the user birthday if now_date != next_birthday: if diff_days > 1: # for ja and hi, the order of the slots is inverted, i.e. year before day if ('ja' in skill_locale or 'hi' in skill_locale): - speak_output = data[prompts.WELCOME_BACK_MSG_plural].format(current_year-year, diff_days) + speak_output = data["WELCOME_BACK_MSG_plural"].format(current_year-year, diff_days) else: - speak_output = data[prompts.WELCOME_BACK_MSG_plural].format(diff_days, current_year-year) + speak_output = data["WELCOME_BACK_MSG_plural"].format(diff_days, current_year-year) elif diff_days < 2: # for ja and hi, the order of the slots is inverted, i.e. year before day if ('ja' in skill_locale or 'hi' in skill_locale): - speak_output = data[prompts.WELCOME_BACK_MSG].format(current_year - year, diff_days) + speak_output = data["WELCOME_BACK_MSG"].format(current_year - year, diff_days) else: - speak_output = data[prompts.WELCOME_BACK_MSG].format(diff_days, current_year - year) + speak_output = data["WELCOME_BACK_MSG"].format(diff_days, current_year - year) return ( handler_input.response_builder @@ -164,7 +161,6 @@ def handle(self, handler_input): .response ) - class BirthdayIntentHandler(AbstractRequestHandler): """ Handler for Capturing the Birthday @@ -206,8 +202,9 @@ def handle(self, handler_input): # ensure that the order the arguments is correct (MM/DD/YYYY or DD/MM/YYYY) according to locale date = self.formatDate(year, month, day, skill_locale) - speech = data[prompts.REGISTER_BIRTHDAY_MSG].format(date[0], date[1], date[2]) + speech = data["REGISTER_BIRTHDAY_MSG"].format(date[0], date[1], date[2]) handler_input.response_builder.speak(speech) + handler_input.response_builder.set_should_end_session(True) return handler_input.response_builder.response # function to ensure that the date format corresponds with the locale that is triggering thee skill @@ -242,7 +239,7 @@ def handle(self, handler_input): # type: (HandlerInput) -> Response data = handler_input.attributes_manager.request_attributes["_"] - speak_output = data[prompts.HELP_MSG] + speak_output = data["HELP_MSG"] return ( handler_input.response_builder @@ -262,7 +259,7 @@ def can_handle(self, handler_input): def handle(self, handler_input): # type: (HandlerInput) -> Response data = handler_input.attributes_manager.request_attributes["_"] - speak_output = data[prompts.GOODBYE_MSG] + speak_output = data["GOODBYE_MSG"] return ( handler_input.response_builder @@ -299,7 +296,7 @@ def handle(self, handler_input): # type: (HandlerInput) -> Response data = handler_input.attributes_manager.request_attributes["_"] intent_name = ask_utils.get_intent_name(handler_input) - speak_output = data[prompts.REFLECTOR_MSG].format(intent_name) + speak_output = data["REFLECTOR_MSG"].format(intent_name) return ( handler_input.response_builder @@ -322,7 +319,7 @@ def handle(self, handler_input, exception): # type: (HandlerInput, Exception) -> Response logger.error(exception, exc_info=True) data = handler_input.attributes_manager.request_attributes["_"] - speak_output = data[prompts.ERROR_MSG] + speak_output = data["ERROR_MSG"] return ( handler_input.response_builder diff --git a/lambda/py/requirements.txt~HEAD b/lambda/py/requirements.txt~HEAD new file mode 100644 index 0000000..1b5d6a9 --- /dev/null +++ b/lambda/py/requirements.txt~HEAD @@ -0,0 +1,4 @@ +ask-sdk-core +ask-sdk-s3-persistence-adapter +boto3 +pytz diff --git a/lambda/py/requirements.txt~Simplifying Localization b/lambda/py/requirements.txt~Simplifying Localization new file mode 100644 index 0000000..1b5d6a9 --- /dev/null +++ b/lambda/py/requirements.txt~Simplifying Localization @@ -0,0 +1,4 @@ +ask-sdk-core +ask-sdk-s3-persistence-adapter +boto3 +pytz diff --git a/skill.json b/skill.json index 9f26c60..6cbc6be 100644 --- a/skill.json +++ b/skill.json @@ -2,52 +2,52 @@ "manifest": { "publishingInformation": { "locales": { - "en-US": { - "name": "cake walk" + "de-DE": { + "name": "Herzlichen Glückwunsch" }, "en-AU": { - "name": "cake walk" + "name": "Cake Walk" }, "en-CA": { - "name": "cake walk" + "name": "Cake Walk" }, "en-GB": { - "name": "cake walk" + "name": "Cake Walk" }, "en-IN": { - "name": "cake walk" + "name": "Cake Walk" }, - "pt-BR": { - "name": "feliz aniversário" + "en-US": { + "name": "Cake Walk" }, - "it-IT": { - "name": "buon compleanno" + "es-ES": { + "name": "Feliz Cumpleaños" + }, + "es-MX": { + "name": "Feliz Cumpleaños" + }, + "es-US": { + "name": "Feliz Cumpleaños" }, - "fr-FR": { - "name": "Joyeux Anniversaire" - }, "fr-CA": { "name": "Bonne Fête" }, + "fr-FR": { + "name": "Joyeux Anniversaire" + }, "hi-IN": { - "name": "cake walk" + "name": "Cake Walk" + }, + "it-IT": { + "name": "Buon Compleanno" }, "ja-JP": { "name": "ケークウォーク" }, - "de-DE": { - "name": "Herzlichen Glückwunsch" - }, - "es-ES": { - "name": "feliz cumpleaños" - }, - "es-MX": { - "name": "feliz cumpleaños" - }, - "es-US": { - "name": "feliz cumpleaños" + "pt-BR": { + "name": "Feliz Aniversário" } - }, + }, "isAvailableWorldwide": true, "testingInstructions": "Sample Testing Instructions.", "category": "EDUCATION_AND_REFERENCE",