Skip to content

Add tests for language-tag matching: exact generic beats specifics#147

Open
imnasnainaec wants to merge 2 commits into
masterfrom
fix/109-tests
Open

Add tests for language-tag matching: exact generic beats specifics#147
imnasnainaec wants to merge 2 commits into
masterfrom
fix/109-tests

Conversation

@imnasnainaec

@imnasnainaec imnasnainaec commented Jun 5, 2026

Copy link
Copy Markdown
Collaborator

Closes #109

PR #110 fixed the language-tag matching logic in XliffLocalizedStringCache.LoadXliffAndUpdateExistingLanguageMap but left one rule untested: when an exact generic tag (e.g. zh) is available alongside specific variants (zh-CN, zh-TW), the exact match should be used without prompting the user.

Adds TestMappingLanguageCodesToAvailable_ExactGenericMatchUsedWhenSpecificsAlsoExist to both:

  • src/L10NSharp.Tests/LocalizationManagerTestsBase.cs
  • src/L10NSharp.Windows.Forms.Tests/XliffLocalizationManagerTests.cs

Each test sets up all three variants, initialises with "zh", and asserts: no prompt fires, UILanguageId == "zh", and GetString returns the generic-zh translation (not CN or TW).

Devin review: https://app.devin.ai/review/sillsdev/l10nsharp/pull/147


This change is Reviewable

@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown

Test Results

    7 files  ±0  107 suites  +3   32s ⏱️ +9s
167 tests +1  162 ✔️ +1    5 💤 ±0  0 ±0 
637 runs  +7  622 ✔️ +7  15 💤 ±0  0 ±0 

Results for commit 5422adb. ± Comparison against base commit 7c4190e.

♻️ This comment has been updated with latest results.

@imnasnainaec imnasnainaec self-assigned this Jun 5, 2026
imnasnainaec and others added 2 commits June 8, 2026 10:06
…fics)

PR #110 fixed the language-tag matching logic but left one rule untested:
when an exact generic tag (zh) is available alongside specific variants
(zh-CN, zh-TW), the exact match should be used without prompting.

Adds TestMappingLanguageCodesToAvailable_ExactGenericMatchUsedWhenSpecificsAlsoExist
to both LocalizationManagerTestsBase and XliffLocalizationManagerTests.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@imnasnainaec imnasnainaec marked this pull request as ready for review June 8, 2026 14:06
@imnasnainaec imnasnainaec requested a review from tombogle June 8, 2026 14:07
@imnasnainaec imnasnainaec changed the title Add tests for language-tag matching rule 3 (exact generic beats specifics) Add tests for language-tag matching: exact generic beats specifics Jun 8, 2026
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.

Initializing without a country code should find l10ns with a country code

1 participant