Skip to content

Implement Text component localization support #82

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 2, 2025

Conversation

maclong9
Copy link
Owner

@maclong9 maclong9 commented Jul 2, 2025

Summary

• Add comprehensive localization infrastructure for the Text component following SwiftUI patterns
• Implement automatic localization key detection for snake_case and dot.notation patterns
• Add explicit localization support via LocalizationKey parameter with interpolation
• Provide Foundation and Bundle-based resolvers for NSLocalizedString integration
• Maintain backward compatibility with existing Text string initializers

Test plan

  • All 20 new localization tests pass
  • All existing tests continue to pass (367 total tests)
  • LocalizationKey supports string literals, interpolation, and table organization
  • LocalizationManager provides centralized locale and resolver management
  • Text component automatically detects and resolves localization keys
  • Explicit localization initializer works with LocalizationKey objects
  • Backward compatibility maintained for all existing Text usage

Resolves #76

maclong9 added 5 commits July 2, 2025 15:14
- Rename HTML protocol to Markup for Swift API Design Guidelines compliance
- Rename HTMLBuilder to MarkupBuilder with updated documentation
- Rename HTMLString to MarkupString for consistency
- Update AnyHTML to AnyMarkup with proper type erasure
- Rename HTMLClassContainer to MarkupClassContainer
- Rename HTMLContentBuilder to MarkupContentBuilder
- Update all documentation to use 'markup' terminology
- Rename AttributeBuilder.renderTag to buildMarkupTag for clarity
- Move files from HTML/ directory to Markup/ directory
- Update all 85+ Swift files to use Markup instead of HTML types
- Replace HTMLBuilder with MarkupBuilder throughout codebase
- Update all protocol conformances and type annotations
- Replace renderTag with buildMarkupTag method name
- Update documentation to use 'markup' and 'stylesheet' terminology
- Maintain backward compatibility for actual HTML tag output
- All tests passing after comprehensive refactor
…idelines

- CSS → StyleSheet: sanitizedForCSS() → sanitizedForStyleSheet()
- URL → WebAddress: baseURL → baseWebAddress throughout APIs
- XML → ExtensibleMarkupLanguageDocument: generateXML() → generateExtensibleMarkupLanguageDocument()
- Improve method clarity: getData() → retrieveStructuredDataDictionary()
- Improve method clarity: toJSON() → convertToJsonString()
- Boolean properties to assertions: generateSitemap → shouldGenerateSitemap
- Boolean properties to assertions: generateRobotsTxt → shouldGenerateRobotsTxt
- Add backward compatibility aliases with deprecation warnings
- Update all references across codebase and tests
- All 367 tests passing with new method names
- AttributeBuilder.buildAttributes: Add clear parameter labels (identifier, styleSheetClasses, ariaRole, etc.)
- StyleOperation: Add alternative methods with clearer labels (using, with configuration)
- Input component: Improve event handler parameter label clarity
- Add backward compatibility overloads to maintain existing API
- All 254 tests passing with improved parameter clarity
- Complete Swift API Design Guidelines compliance
Add comprehensive localization infrastructure for the Text component following SwiftUI patterns:

- LocalizationKey: Supports string literals, interpolation, and table-based organization
- LocalizationManager: Centralized singleton for managing locale and resolution
- Foundation & Bundle resolvers: NSLocalizedString integration with custom bundle support
- Text component enhancements:
  - Automatic localization key detection (snake_case, dot.notation patterns)
  - Explicit localization support via LocalizationKey parameter
  - Backward compatibility maintained for existing string initializers
- Comprehensive test coverage: 20 passing tests covering all functionality

Resolves #76: Text localization now works like SwiftUI with automatic key resolution
@maclong9 maclong9 merged commit cf4a37a into main Jul 2, 2025
1 check passed
@maclong9 maclong9 deleted the feature/text-localization-support branch July 2, 2025 23:04
maclong9 added a commit that referenced this pull request Jul 7, 2025
* Refactor core HTML protocols and builders to Markup

- Rename HTML protocol to Markup for Swift API Design Guidelines compliance
- Rename HTMLBuilder to MarkupBuilder with updated documentation
- Rename HTMLString to MarkupString for consistency
- Update AnyHTML to AnyMarkup with proper type erasure
- Rename HTMLClassContainer to MarkupClassContainer
- Rename HTMLContentBuilder to MarkupContentBuilder
- Update all documentation to use 'markup' terminology
- Rename AttributeBuilder.renderTag to buildMarkupTag for clarity
- Move files from HTML/ directory to Markup/ directory

* Complete HTML to Markup refactoring across entire codebase

- Update all 85+ Swift files to use Markup instead of HTML types
- Replace HTMLBuilder with MarkupBuilder throughout codebase
- Update all protocol conformances and type annotations
- Replace renderTag with buildMarkupTag method name
- Update documentation to use 'markup' and 'stylesheet' terminology
- Maintain backward compatibility for actual HTML tag output
- All tests passing after comprehensive refactor

* Expand abbreviations and improve method names per Swift API Design Guidelines

- CSS → StyleSheet: sanitizedForCSS() → sanitizedForStyleSheet()
- URL → WebAddress: baseURL → baseWebAddress throughout APIs
- XML → ExtensibleMarkupLanguageDocument: generateXML() → generateExtensibleMarkupLanguageDocument()
- Improve method clarity: getData() → retrieveStructuredDataDictionary()
- Improve method clarity: toJSON() → convertToJsonString()
- Boolean properties to assertions: generateSitemap → shouldGenerateSitemap
- Boolean properties to assertions: generateRobotsTxt → shouldGenerateRobotsTxt
- Add backward compatibility aliases with deprecation warnings
- Update all references across codebase and tests
- All 367 tests passing with new method names

* Improve parameter labels for better call-site clarity

- AttributeBuilder.buildAttributes: Add clear parameter labels (identifier, styleSheetClasses, ariaRole, etc.)
- StyleOperation: Add alternative methods with clearer labels (using, with configuration)
- Input component: Improve event handler parameter label clarity
- Add backward compatibility overloads to maintain existing API
- All 254 tests passing with improved parameter clarity
- Complete Swift API Design Guidelines compliance

* Implement Text component localization support

Add comprehensive localization infrastructure for the Text component following SwiftUI patterns:

- LocalizationKey: Supports string literals, interpolation, and table-based organization
- LocalizationManager: Centralized singleton for managing locale and resolution
- Foundation & Bundle resolvers: NSLocalizedString integration with custom bundle support
- Text component enhancements:
  - Automatic localization key detection (snake_case, dot.notation patterns)
  - Explicit localization support via LocalizationKey parameter
  - Backward compatibility maintained for existing string initializers
- Comprehensive test coverage: 20 passing tests covering all functionality

Resolves #76: Text localization now works like SwiftUI with automatic key resolution
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.

Text component does not support localization like SwiftUI's Text
1 participant