Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding es-US model and language localization #34

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions lambda/py/lambda_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,18 +120,21 @@ class LocalizationInterceptor(AbstractRequestInterceptor):

def process(self, handler_input):
locale = handler_input.request_envelope.request.locale
logger.info("Locale is {}".format(locale[:2]))
logger.info("Locale is {}".format(locale))

# localized strings stored in language_strings.json
with open("language_strings.json") as language_prompts:
language_data = json.load(language_prompts)
# set default translation data to broader translation
data = language_data[locale[:2]]
# if a more specialized translation exists, then select it instead
# example: "fr-CA" will pick "fr" translations first, but if "fr-CA" translation exists,
# then pick that instead
if locale in language_data:
data.update(language_data[locale])
if locale[:2] in language_data:
data = language_data[locale[:2]]
# if a more specialized translation exists, then select it instead
# example: "fr-CA" will pick "fr" translations first, but if "fr-CA" translation exists,
# then pick that instead
if locale in language_data:
data.update(language_data[locale])
else:
data = language_data[locale]
handler_input.attributes_manager.request_attributes["_"] = data


Expand Down
21 changes: 19 additions & 2 deletions lambda/py/language_strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
"it-IT": {
"SKILL_NAME": "Aneddoti dallo spazio"
},
"jp": {
"ja": {
"SKILL_NAME": "日本語版豆知識",
"GET_FACT_MESSAGE": "知ってましたか? {}",
"HELP_MESSAGE": "豆知識を聞きたい時は「豆知識」と、終わりたい時は「おしまい」と言ってください。どうしますか?",
Expand All @@ -131,7 +131,7 @@
"天の川銀河は約50億年後にアンドロメダ星雲と衝突します。"
]
},
"jp-JP": {
"ja-JP": {
"SKILL_NAME": "日本語版豆知識"
},
"pt": {
Expand All @@ -153,5 +153,22 @@
},
"pt-BR": {
"SKILL_NAME": "Fatos Espaciais"
},
"de-DE": {
"SKILL_NAME": "Weltraumwissen",
"GET_FACT_MESSAGE": "Hier sind deine Fakten: {}",
"HELP_MESSAGE": "Du kannst sagen, „Nenne mir einen Fakt über den Weltraum“, oder du kannst „Beenden“ sagen... Wie kann ich dir helfen?",
"HELP_REPROMPT": "Wie kann ich dir helfen?",
"FALLBACK_MESSAGE": "Die Weltraumfakten Skill kann dir dabei nicht helfen. Sie kann dir Fakten über den Raum erzählen, wenn du dannach fragst.",
"FALLBACK_REPROMPT": "Wie kann ich dir helfen?",
"ERROR_MESSAGE": "Es ist ein Fehler aufgetreten.",
"STOP_MESSAGE": "Auf Wiedersehen!",
"FACTS": [
"Ein Jahr dauert auf dem Merkur nur 88 Tage.",
"Die Venus ist zwar weiter von der Sonne entfernt, hat aber höhere Temperaturen als Merkur.",
"Venus dreht sich entgegen dem Uhrzeigersinn, möglicherweise aufgrund eines früheren Zusammenstoßes mit einem Asteroiden.",
"Auf dem Mars erscheint die Sonne nur halb so groß wie auf der Erde.",
"Jupiter hat den kürzesten Tag aller Planeten."
]
}
}
308 changes: 0 additions & 308 deletions lambda/py/local_debugger.py

This file was deleted.

Loading