From: Noor Haddad Date: Tue, 06 Oct 2026 10:05:01 +0300 Subject: [PATCH hello-hut 1/3] greetings: add a translation table To: ~reviewer/hello-hut-devel@lists.hut.md Message-ID: <20261006070500.48213-1-noor@example.org> In-Reply-To: <20261006070500.48213-0-noor@example.org> References: <20261006070500.48213-0-noor@example.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hello_hut/greetings.py | 6 ++++-- src/hello_hut/translations.py | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 src/hello_hut/translations.py diff --git a/src/hello_hut/greetings.py b/src/hello_hut/greetings.py index 3b776fc..dc3fda6 100644 --- a/src/hello_hut/greetings.py +++ b/src/hello_hut/greetings.py @@ -2,6 +2,8 @@ import datetime +from .translations import TRANSLATIONS + DEFAULT_NAME = "friend" @@ -15,9 +17,9 @@ def time_of_day_greeting(now=None): return "Good evening" -def greet(name=DEFAULT_NAME, shout=False, salutation=None): +def greet(name=DEFAULT_NAME, shout=False, salutation=None, lang="en"): """Build a greeting such as "Hello, Ada!".""" if salutation is None: - salutation = "Hello" + salutation = TRANSLATIONS.get(lang, TRANSLATIONS["en"]) message = f"{salutation}, {name}!" return message.upper() if shout else message diff --git a/src/hello_hut/translations.py b/src/hello_hut/translations.py new file mode 100644 index 0000000..b44b115 --- /dev/null +++ b/src/hello_hut/translations.py @@ -0,0 +1,17 @@ +"""Salutations by language code. + +Keep the table sorted by code. Corrections from native speakers are very +welcome; please send them to the devel list. +""" + +TRANSLATIONS = { + "ar": "مرحبا", + "de": "Hallo", + "en": "Hello", + "es": "Hola", + "fr": "Bonjour", + "ja": "こんにちは", + "pt": "Olá", + "sv": "Hej", + "tr": "Merhaba", +} -- 2.51.0