Skip to content

Add Text localization support - #885

Merged
Kyle-Ye merged 20 commits into
mainfrom
feature/localized_text
May 31, 2026
Merged

Add Text localization support#885
Kyle-Ye merged 20 commits into
mainfrom
feature/localized_text

Conversation

@Kyle-Ye

@Kyle-Ye Kyle-Ye commented May 30, 2026

Copy link
Copy Markdown
Member

Agent Summary

  • Add localized Text storage backed by LocalizedStringKey.
  • Support bundle, table, and locale-aware lookup for localized strings and attributed strings.
  • Resolve localized string interpolation for primitive values, Foundation formatters, format styles, Text, AttributedString, and localized string resources.
  • Preserve sentence-boundary capitalization behavior for interpolated text.
  • Add SPI coverage for sentence-boundary localization behavior.
  • Document the public localized text APIs.

@github-actions github-actions Bot added area: text Text, labels, line style, and text rendering APIs. type: feature New API, behavior, platform support, or user-facing capability. labels May 30, 2026
@Kyle-Ye
Kyle-Ye marked this pull request as ready for review May 30, 2026 18:41
@github-actions github-actions Bot added area: example Example apps, previews, sample projects, screenshots, or demo assets. type: tests Test coverage, test infrastructure, snapshots, or test-only changes. labels May 30, 2026
@augmentcode

augmentcode Bot commented May 30, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: This PR introduces localized Text storage backed by LocalizedStringKey, enabling locale-aware string lookup and interpolation.

Changes:

  • Implements LocalizedStringKey resolution into resolved text containers, with support for bundle/table lookup and optional Markdown-attributed localization on Darwin.
  • Adds interpolation plumbing for primitive values, Foundation formatters, format styles, Text, AttributedString, and (Darwin-only) LocalizedStringResource.
  • Introduces sentence-boundary capitalization context tracking via a new environment value (Darwin-only) and an SPI helper to detect sentence starts.
  • Adds SPI overlays for localized string / attributed string lookup and sentence-boundary detection (_LocalizeString, _LocalizeAttributedString, _isBeginningOfSentence).
  • Updates resolved text attachment markers to use a shared String.nsAttachment constant.
  • Exposes Text._localizationInfo based on underlying storage for introspection.
  • Adds an SPI test covering sentence-boundary detection behavior.

Technical Notes: The implementation includes Darwin-only code paths for attributed localization and capitalization context, with non-Darwin fallbacks using Bundle.localizedString(forKey:...).

🤖 Was this summary useful? React with 👍 or 👎

@augmentcode augmentcode Bot 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.

Review completed. 3 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

Comment thread Sources/OpenSwiftUICore/View/Text/Util/String+Extension.swift
Comment thread Sources/OpenSwiftUICore/View/Text/Text/Text+Localized.swift
Comment thread Sources/OpenSwiftUICore/View/Text/Text/Text+Localized.swift
@codecov

codecov Bot commented May 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 387 lines in your changes missing coverage. Please review.
✅ Project coverage is 26.75%. Comparing base (e3b18c6) to head (cba9a9c).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...penSwiftUICore/View/Text/Text/Text+Localized.swift 0.00% 354 Missing ⚠️
...enSwiftUICore/View/Text/Resolve/ResolvedText.swift 0.00% 8 Missing ⚠️
...xt/CapitalizationContextDependentFormatStyle.swift 0.00% 8 Missing ⚠️
Sources/OpenSwiftUICore/View/Text/Text/Text.swift 0.00% 5 Missing ⚠️
...Core/View/Text/Text/Text+DiscreteFormatStyle.swift 0.00% 4 Missing ⚠️
...penSwiftUICore/View/Text/Text/Text+Formatter.swift 0.00% 4 Missing ⚠️
...nSwiftUICore/View/Text/Util/String+Extension.swift 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #885      +/-   ##
==========================================
- Coverage   26.93%   26.75%   -0.18%     
==========================================
  Files         679      682       +3     
  Lines       47281    47612     +331     
==========================================
+ Hits        12735    12739       +4     
- Misses      34546    34873     +327     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Kyle-Ye
Kyle-Ye force-pushed the feature/localized_text branch from 0b982d7 to cba9a9c Compare May 31, 2026 05:01
@Kyle-Ye
Kyle-Ye merged commit 299ad06 into main May 31, 2026
6 of 7 checks passed
@Kyle-Ye
Kyle-Ye deleted the feature/localized_text branch May 31, 2026 05:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: example Example apps, previews, sample projects, screenshots, or demo assets. area: text Text, labels, line style, and text rendering APIs. type: feature New API, behavior, platform support, or user-facing capability. type: tests Test coverage, test infrastructure, snapshots, or test-only changes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant