Skip to content

feat(CDA): Add asset localisation support#154

Open
OMpawar-21 wants to merge 2 commits intodevelopmentfrom
enhc/DX-4448
Open

feat(CDA): Add asset localisation support#154
OMpawar-21 wants to merge 2 commits intodevelopmentfrom
enhc/DX-4448

Conversation

@OMpawar-21
Copy link

PR: Asset localisation support

Summary

Adds asset localisation to the .NET CDA SDK: request assets by locale and read localised title from the response.

Code changes

File Change
Contentstack.Core/Models/Asset.cs Added Title property ([JsonProperty("title")]). Added SetLocale(string locale) for single-asset fetch by locale.
Contentstack.Core/Models/AssetLibrary.cs No change (existing SetLocale already supports list-by-locale).
CHANGELOG.md Documented under v2.26.0.

Test cases added

Unit (AssetLibraryUnitTests.cs)

  • SetLocale_ForAssetLocalisation_AddsLocaleQueryParameterSetLocale("ar") adds locale to query.
  • SetLocale_UpdatesLocaleWhenCalledAgain – second SetLocale overwrites the first.

Unit (AssetUnitTests.cs)

  • SetLocale_AddsQueryParameterAsset.SetLocale("en-us") adds locale.
  • AddParam_WithLocale_AddsLocaleQueryParameterAddParam("locale", "ar") adds locale.
  • AddParam_LocaleWithIncludeFallback_AddsBothQueryParameters – locale + IncludeFallback().

Integration (AssetTest.cs)

  • FetchAssetsWithLocale_ReturnsLocalisedAssets – list with SetLocale("en-us").
  • FetchSingleAssetWithLocale_ReturnsLocalisedAsset – single asset via AddParam("locale", ...).
  • FetchSingleAssetWithSetLocale_ReturnsLocalisedAsset – single asset via SetLocale(...).
  • FetchAssetsWithLocaleAr_ReturnsAssetsWithLocale – list with SetLocale("ar").
  • FetchAssetsWithLocaleAndFallback_ReturnsLocalisedOrFallback – locale + IncludeFallback().

Backward compatibility

Additive only; no breaking changes.

Add SetLocale on Asset for single-asset fetch, Title property for localised
title; AssetLibrary SetLocale unchanged. Add unit and integration tests; update CHANGELOG for 2.26.0.
@OMpawar-21 OMpawar-21 requested a review from a team as a code owner February 17, 2026 10:55
Copy link
Contributor

@cs-raj cs-raj left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@cs-raj cs-raj left a comment

Choose a reason for hiding this comment

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

Tests failing

sunil-lakshman
sunil-lakshman previously approved these changes Feb 20, 2026
Copy link

@sunil-lakshman sunil-lakshman left a comment

Choose a reason for hiding this comment

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

LGTM

Call SetLocale("en-us") first, then SetLocale("ar"), and assert "ar".
Previously the order was reversed so the test expected "ar" while the
implementation correctly kept the last value "en-us"; the assertion
was wrong. Now the test validates that the second call overwrites
the locale.
Copy link

@sunil-lakshman sunil-lakshman left a comment

Choose a reason for hiding this comment

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

LGTM

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.

3 participants

Comments