Skip to content

fix(seed): remap seed LanguageId to real SDK ids for AreaRuleTranslations#985

Merged
renemadsen merged 1 commit into
stablefrom
fix/area-rule-translation-language-remap
Jun 8, 2026
Merged

fix(seed): remap seed LanguageId to real SDK ids for AreaRuleTranslations#985
renemadsen merged 1 commit into
stablefrom
fix/area-rule-translation-language-remap

Conversation

@renemadsen

Copy link
Copy Markdown
Member

Problem

Calendar event titles (taskText) come from AreaRuleTranslations (copied verbatim into PlanningNameTranslation). Those rows are seeded from BackendConfigurationSeedAreas.AreaRules / AreaRulesForType7/8 (and a Type10 "Morgenrundtur" path), which hardcode LanguageId = 1/2/3. But each tenant's SDK Languages table uses environment-specific auto-increment ids (e.g. da=2, en-US=5, de-DE=8 — id 1 may not exist).

Commit #983 made the gRPC title lookup strict by the worker's real Site language id, so placeholder-keyed rows stop matching → empty event titles in the mobile app (observed on tenant 1124).

PR #982 fixed this exact pattern for AreaTranslations in SeedEForms, but left AreaRuleTranslations un-remapped — this PR closes that gap.

Fix

New AreaRuleLanguageHelper.RemapSeedLanguageIdsAsync(...) resolves the real SDK id by LanguageCode (map {1→da, 2→en-US, 3→de-DE}) and in-place re-keys translations before persist. Applied at every area-rule creation site that used raw seed ids:

  • BackendConfigurationPropertyAreasServiceHelper (×2 seeded-default loops)
  • BackendConfigurationAreaRulesService (area-1 re-seed + Type10 Morgenrundtur)
  • BackendConfigurationAreaRulesServiceHelper (Type7/Type8 translation lists)

Frontend-sourced paths (already real SDK ids) are left untouched. PlanningNameTranslation inherits the fix automatically (it copies AreaRuleTranslation.LanguageId verbatim).

Safe for all tenants: the map keys are seed ids; values resolve by language code, so even tenants whose real ids happen to be 1/2/3 (e.g. 1116) get an identity write — no corruption. Existing broken data is repaired separately (data fix, out of scope here).

🤖 Generated with Claude Code

…ions

New tenants stored placeholder-keyed (1/2/3) area-rule name translations
that don't match the SDK Languages auto-increment ids, breaking calendar
event titles. Mirror the #982 AreaTranslation fix: resolve the real SDK
language id by LanguageCode before each areaRule.Create at all seed write
paths (default rules x2, area-1 re-seed, Type7/Type8 build).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 8, 2026 09:45

Copilot AI left a comment

Copy link
Copy Markdown

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 fixes seeded AreaRuleTranslation.LanguageId values by remapping the seed’s hardcoded IDs (1/2/3) to the tenant’s real SDK Languages.Id resolved by LanguageCode, ensuring area-rule name translations match the worker/site language selection introduced in #983 and preventing empty calendar event titles.

Changes:

  • Added AreaRuleLanguageHelper to remap seed language IDs to real SDK language IDs by code.
  • Applied remapping to seeded area-rule creation paths (property-area seed loops, area-1 reseed, and Type7/Type8 translation builds).
  • Updated the Type10 “Morgenrundtur” rule translation seeding to build a translation list and remap IDs prior to persisting.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
eFormAPI/Plugins/BackendConfiguration.Pn/BackendConfiguration.Pn/Services/BackendConfigurationAreaRulesService/BackendConfigurationAreaRulesService.cs Remaps seed language IDs when creating seeded area rules/translations (incl. Type10 “Morgenrundtur” translations and area-1 reseed).
eFormAPI/Plugins/BackendConfiguration.Pn/BackendConfiguration.Pn/Infrastructure/Helpers/BackendConfigurationPropertyAreasServiceHelper.cs Remaps seed language IDs for area rules created during property-area activation seeding.
eFormAPI/Plugins/BackendConfiguration.Pn/BackendConfiguration.Pn/Infrastructure/Helpers/BackendConfigurationAreaRulesServiceHelper.cs Remaps seed language IDs for Type7/Type8 translation lists generated from seed data.
eFormAPI/Plugins/BackendConfiguration.Pn/BackendConfiguration.Pn/Infrastructure/Helpers/AreaRuleLanguageHelper.cs New helper that resolves SDK language IDs by code and mutates translations in-place.

Comment on lines +21 to +31
var sdkLanguages = await sdkDbContext.Languages.ToListAsync().ConfigureAwait(false);
var seedLanguageIdToCode = new Dictionary<int, string> { { 1, "da" }, { 2, "en-US" }, { 3, "de-DE" } };
var seedLanguageIdToSdkId = new Dictionary<int, int>();
foreach (var (seedLanguageId, code) in seedLanguageIdToCode)
{
var lang = sdkLanguages.FirstOrDefault(x => x.LanguageCode == code);
if (lang != null)
{
seedLanguageIdToSdkId[seedLanguageId] = lang.Id;
}
}
@renemadsen renemadsen merged commit 728acbe into stable Jun 8, 2026
27 checks passed
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.

2 participants