Skip to content

Make phone number validation and UI translatable (#344) - #363

Open
nonprofittechy wants to merge 1 commit into
mainfrom
fix/344-phone-number-translations
Open

Make phone number validation and UI translatable (#344)#363
nonprofittechy wants to merge 1 commit into
mainfrom
fix/344-phone-number-translations

Conversation

@nonprofittechy

Copy link
Copy Markdown
Member

Description

This PR resolves #344 by adding internationalization and translation support to the PhoneNumber custom data type and phone-number-validation.js (intl-tel-input widget).

Changes

  1. PhoneNumberDataType.py: The default validation message is now routed through window.alTranslate() when available (with fallback to the English string and preserving data-alInvalidInputMessage override).
  2. phone-number-validation.js:
    • Localizes intl-tel-input UI strings (search placeholder, results text, aria-labels) via alTranslate.
    • Uses browser Intl.DisplayNames to populate localized country names dynamically based on the active language.
    • Listens for alTranslationsLoaded to re-initialize and translate existing inputs once translations finish loading.
  3. translation_strings.py & altoolbox_words.yml:
    • Added phone validation strings to ALTOOLBOX_JS_STRINGS.
    • Added translations in altoolbox_words.yml for ar, es, fr, ht, km, pt, vi, zh-Hans, zh-CN, zh-Hant, zh-TW, and ne.
  4. Tests & Questions:
    • Added translation test assertions in test_translation_strings.py.
    • Updated phone-number-validation.yml example question to load translation modules.

Closes #344.

Testing

  • Unit tests run and pass (pytest: 78 passed).
  • Type checking passes (mypy: 0 issues).
  • Code formatting checked (black).

 #344)

- Make PhoneNumber custom data type validation message translatable via window.alTranslate
- Provide localized country names and UI labels for intl-tel-input via Intl.DisplayNames and al_translate.js
- Re-initialize phone inputs upon receiving the alTranslationsLoaded event
- Add phone validation strings to ALTOOLBOX_JS_STRINGS and provide translations in altoolbox_words.yml
- Update test_translation_strings.py to assert phone validation string coverage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make the Phone Number Data Type translatable

1 participant