Skip to content

Conversation

@nattsw
Copy link
Contributor

@nattsw nattsw commented May 7, 2025

Localize locales that get returned by the translator provider before saving them into the Post.locale. This helps with direct mapping to a I18n value.

@nattsw nattsw force-pushed the locale-normalizer branch from 00e8e93 to fa65eb8 Compare May 7, 2025 04:46
@nattsw nattsw requested a review from Copilot May 7, 2025 04:46
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR ensures that locales returned by the translator provider are normalized before being saved to Post.locale for direct mapping to I18n values.

  • Updated tests in post_locale_detector_spec.rb to expect normalized locales.
  • Introduced the LocaleNormalizer module with corresponding tests.
  • Modified post_locale_detector to update Post.locale with the normalized locale.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
spec/services/post_locale_detector_spec.rb Adjusted tests to verify locale normalization outcomes.
spec/lib/locale_normalizer_spec.rb Added new tests to validate the LocaleNormalizer functionality.
lib/discourse_translator/locale_normalizer.rb Created the LocaleNormalizer module for mapping locales.
app/services/discourse_translator/post_locale_detector.rb Updated locale assignment to include normalization.

@nattsw nattsw merged commit 5796fa3 into main May 7, 2025
@nattsw nattsw deleted the locale-normalizer branch May 7, 2025 06:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants