Fix/bobbor/i18n texts#6968
Open
bobbor wants to merge 4 commits into
Open
Conversation
Add optional values parameter to translate() for {placeholder} replacement.
Uses replaceAll() for safe literal string substitution — no regex injection
risk. Fully backward compatible with existing callers.
🦋 Changeset detectedLatest commit: 32ab739 The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
4 tasks
…Texts - Move hardcoded periods from template literals into translated strings, fixing #6966 (wrong punctuation in Japanese and other non-Latin locales) - Add composite delivery message keys with {destination} and {arrivalMessage} placeholders — all punctuation now controlled by translators - Promote CONFIGURATION_ERROR (was hardcoded with en-dash U+2013), COPIED, SETUP_TOTP_INSTRUCTIONS, INVALID_EMAIL, FIELD_REQUIRED to DefaultTexts constants - Rewrite getDeliveryMessageText to use translate() interpolation instead of template literal concatenation
…tions
- Add period-inclusive translation keys for delivery messages across all
19 locale dictionaries with locale-appropriate punctuation (。for
Japanese/Chinese, no periods for Thai)
- Add composite delivery message translations with {destination} and
{arrivalMessage} placeholders
- Add both period variants of Cognito error keys as aliases (additive
only, no keys removed) to prevent silent translation failures
- Existing keys preserved for backward compatibility
a727612 to
32ab739
Compare
jiw-mh
reviewed
Apr 24, 2026
| */ | ||
| export function translate<T extends string>(phrase: T): string { | ||
| return I18n.get(phrase); | ||
| export function translate<T extends string>( |
There was a problem hiding this comment.
It feels like this should maybe be part of: https://github.com/aws-amplify/amplify-js/blob/93487ff0967b8b4f752aca4aacd341052b343177/packages/core/src/I18n/I18n.ts#L61-L82
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of changes
This change introduces a more fine-grained control over translation texts in the Authenticator.
1.) strings do accept placeholders and values now.
translations with different positions of values is allowed. no more fragile construction in the source code.
2.) punctuation is part of translation
Since the japanese language uses different period signs for delimiting sentences and in thai it is common to not use any at all. the translation controls punctuation.
This allows for a more natural way of communcation.
3.) backwards compatibility
a small number of keys has been introduced to the translation files for backwards compatibility and to even out cognito inconsistencies.
Issue #, if available
#6966
Description of how you validated changes
Checklist
yarn testpasses and tests are updated/addeddocs,e2e,examples, or other private packages.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.