fix(sdk): normalize Android and underscore locales to BCP 47 before API calls#2103
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe PR normalizes non-canonical locale codes (Android-format ChangesLocale Normalization
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Summary
Normalize Android-format (
pt-rPT) and underscore (pt_PT) locale codes to canonical BCP 47 before sending them to the API, so locales that pass config validation are no longer rejected with a 400.Changes
normalizedLocaleCodeSchema(localeCodeSchema.transform(normalizeLocale)) in the SDK and apply it tosourceLocale,targetLocale, andreferencekeys, so every locale that crosses the wire is canonical BCP 47.finalParams.reference(instead of the rawparams.reference) in_localizeRaw, so reference keys are canonicalized along with the locales they pair with.values-pt-rPT/).Testing
Business logic tests added:
-rlocale (pt-rPT) is normalized topt-PTin the request bodyen_US,pt_PT) are normalized toen-US/pt-PTin the request bodyreferencekeys are normalized (pt-rPT→pt-PT)pt-PT) pass through unchangedVisuals
N/A
Checklist
@lingo.dev/_sdkpatch; the CLI (lingo.dev) is auto-bumped as a dependentCloses N/A
Summary by CodeRabbit
pt-rPT) and underscore-delimited locales (pt_PT) are now automatically normalized to canonical BCP 47 format (pt-PT) before being sent to the API, preventing rejection errors.