Skip to content

feat: add an xcode-xcstrings-v2 bucket that supports CLDR pluralization rules#1230

Merged
vrcprl merged 6 commits intomainfrom
feat/pluralization-xcstrings
Oct 20, 2025
Merged

feat: add an xcode-xcstrings-v2 bucket that supports CLDR pluralization rules#1230
vrcprl merged 6 commits intomainfrom
feat/pluralization-xcstrings

Conversation

@vrcprl
Copy link
Copy Markdown
Contributor

@vrcprl vrcprl commented Oct 20, 2025

Add xcode-xcstrings-v2 bucket type that preserves CLDR plural forms.

vrcprl and others added 3 commits October 19, 2025 20:33
Add opt-in xcode-xcstrings-v2 bucket type that converts CLDR plural forms
to ICU MessageFormat for better translation quality and variable handling.

## Key Features

- **ICU MessageFormat conversion**: Converts xcstrings plural forms to ICU
  format with metadata preservation
- **Backward compatible**: Original xcode-xcstrings (v1) completely unchanged
- **Opt-in migration**: Users explicitly choose v2 in their config
- **Format preservation**: Maintains Objective-C format specifiers (%d, %.1f, %lld, %@)
- **Variable handling**: Supports multiple variables with proper metadata
- **CLDR support**: Handles all plural categories (zero, one, two, few, many, other)

## Implementation

### New Files
- xcode-xcstrings-icu.ts - Core ICU conversion utilities (567 lines)
- xcode-xcstrings-v2-loader.ts - V2 bucket loader (79 lines)
- xcode-xcstrings-icu.spec.ts - 23 ICU conversion tests
- xcode-xcstrings-lock-compatibility.spec.ts - 5 lock format tests
- icu-safety.spec.ts - 22 safety tests for other bucket types

### Modified Files
- loaders/index.ts - Register xcode-xcstrings-v2 bucket type
- loaders/flat.ts - Add shouldPreserveObject option for ICU objects
- loaders/variable/index.ts - ICU-aware metadata stripping
- spec/formats.ts - Register xcode-xcstrings-v2 format

### Demo
- demo/xcode-xcstrings-v2/ - Example files with ICU pluralization

## Lock File Format

V1 (flattened):
```
item_count/one: <checksum>
item_count/other: <checksum>
```

V2 (ICU object):
```
item_count: <checksum of ICU object>
```

## Test Coverage

- 72 total tests (50 new + 22 existing)
- All 430 tests passing
- Safety verified against 25+ bucket types

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@vrcprl vrcprl changed the title feat: add xcode-xcstrings-v2 bucket with ICU MessageFormat support feat: add xcode-xcstrings-v2 bucket that supports CLDR pluralization rules Oct 20, 2025
@vrcprl vrcprl changed the title feat: add xcode-xcstrings-v2 bucket that supports CLDR pluralization rules feat: add an xcode-xcstrings-v2 bucket that supports CLDR pluralization rules Oct 20, 2025
@vrcprl vrcprl merged commit b45347c into main Oct 20, 2025
2 checks passed
@vrcprl vrcprl deleted the feat/pluralization-xcstrings branch October 20, 2025 22:30
17prateek12 pushed a commit to 17prateek12/lingo.dev that referenced this pull request Jan 23, 2026
…on rules (lingodotdev#1230)

* feat: add xcode-xcstrings-v2 bucket with ICU MessageFormat support

Add opt-in xcode-xcstrings-v2 bucket type that converts CLDR plural forms
to ICU MessageFormat for better translation quality and variable handling.

## Key Features

- **ICU MessageFormat conversion**: Converts xcstrings plural forms to ICU
  format with metadata preservation
- **Backward compatible**: Original xcode-xcstrings (v1) completely unchanged
- **Opt-in migration**: Users explicitly choose v2 in their config
- **Format preservation**: Maintains Objective-C format specifiers (%d, %.1f, %lld, %@)
- **Variable handling**: Supports multiple variables with proper metadata
- **CLDR support**: Handles all plural categories (zero, one, two, few, many, other)

## Implementation

### New Files
- xcode-xcstrings-icu.ts - Core ICU conversion utilities (567 lines)
- xcode-xcstrings-v2-loader.ts - V2 bucket loader (79 lines)
- xcode-xcstrings-icu.spec.ts - 23 ICU conversion tests
- xcode-xcstrings-lock-compatibility.spec.ts - 5 lock format tests
- icu-safety.spec.ts - 22 safety tests for other bucket types

### Modified Files
- loaders/index.ts - Register xcode-xcstrings-v2 bucket type
- loaders/flat.ts - Add shouldPreserveObject option for ICU objects
- loaders/variable/index.ts - ICU-aware metadata stripping
- spec/formats.ts - Register xcode-xcstrings-v2 format

### Demo
- demo/xcode-xcstrings-v2/ - Example files with ICU pluralization

## Lock File Format

V1 (flattened):
```
item_count/one: <checksum>
item_count/other: <checksum>
```

V2 (ICU object):
```
item_count: <checksum of ICU object>
```

## Test Coverage

- 72 total tests (50 new + 22 existing)
- All 430 tests passing
- Safety verified against 25+ bucket types

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* chore: fix formatting

* chore: cleaning

* chore: add changeset

* chore: fix formatting

---------

Co-authored-by: Claude <noreply@anthropic.com>
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.

1 participant