Skip to content

Conversation

@KatherineInCode
Copy link
Contributor

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-27098

📔 Objective

This migrates several entries containing the words "item" into a stringsdict so we can do proper pluralization.

This uses some parts of #1999, but not all of it, to provide a more-focused PR for item-related plurals.

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

<key>BitwardenCouldNotDecryptXVaultItemsDescriptionLong</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>%#@vaultitems@. Copy and share this error report with customer success to avoid additional data loss.</string>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ℹ️ I pulled the entire "Bitwarden could not decrypt X vault items" sentence into a plural-rule string because some languages inflect verbs based on the number of the object.

@github-actions
Copy link
Contributor

Logo
Checkmarx One – Scan Summary & Detailsc14123aa-da77-4fcb-85f5-a08f90ab72d6

Great job! No new security vulnerabilities introduced in this pull request

@codecov
Copy link

codecov bot commented Oct 31, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.92%. Comparing base (0c36106) to head (36bbcea).
⚠️ Report is 14 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2089      +/-   ##
==========================================
- Coverage   85.28%   82.92%   -2.37%     
==========================================
  Files        1695     1975     +280     
  Lines      144592   160845   +16253     
==========================================
+ Hits       123319   133375   +10056     
- Misses      21273    27470    +6197     

☔ 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.

@KatherineInCode KatherineInCode marked this pull request as ready for review October 31, 2025 21:55
@claude
Copy link

claude bot commented Oct 31, 2025

Claude finished @KatherineInCode's task —— View job


Code Review Complete

Tasks

  • Analyze PR changes and context
  • Review localization changes (strings/stringsdict)
  • Review Swift code changes
  • Review test updates
  • Verify architecture and style compliance
  • Provide comprehensive feedback

Summary of Changes

This PR migrates three item-related localization strings from Localizable.strings to Localizable.stringsdict to enable proper pluralization support across languages:

  1. XItems - Used for VoiceOver header counts
  2. XItemsSuccessfullyImported - Credential Exchange import success message
  3. BitwardenCouldNotDecryptXVaultItemsDescriptionLong - Vault decryption error message (entire sentence moved for verb inflection)

The changes update corresponding Swift code and tests to use the new pluralized string keys.


Critical Issues

None found. The implementation is solid and follows best practices.


Suggested Improvements

1. Consistency in Localization Key Naming

The PR uses xItemsSuccessfullyImported (camelCase) but the stringsdict key is XItemsSuccessfullyImported (PascalCase). While this works due to Swift's localization lookup being case-insensitive, it would be better to be consistent with the existing codebase pattern.

Current:

// ImportCXFState.swift:68
Localizations.xItemsSuccessfullyImported(total)

Observation: Looking at the existing code, both camelCase and PascalCase patterns exist in the codebase (e.g., Localizations.continue vs Localizations.XDays). This appears to be an existing inconsistency rather than something introduced by this PR.

2. Enhanced Test Coverage for Pluralization

Expand for details

While the existing tests verify the string usage, they don't explicitly test the pluralization behavior (singular vs plural forms). Consider adding tests that verify:

// AlertVaultTests.swift - potential enhancement
func test_cipherDecryptionFailure_pluralization() {
    // Test singular form (1 item)
    let singular = Alert.cipherDecryptionFailure(cipherIds: ["id1"], isFromCipherTap: false) { _ in }
    XCTAssertTrue(singular.message.contains("1 vault item")) // singular form
    
    // Test plural form (2+ items)
    let plural = Alert.cipherDecryptionFailure(cipherIds: ["id1", "id2"], isFromCipherTap: false) { _ in }
    XCTAssertTrue(plural.message.contains("2 vault items")) // plural form
}

However, this may be considered over-testing since iOS handles stringsdict pluralization automatically. The current test coverage is adequate for verifying correct key usage.

3. Documentation Comment Accuracy

File: BitwardenResources/Localizations/en.lproj/Localizable.stringsdict:56-57

The comment states:

This could be more precise about the format:

However, the existing comment is clear enough and follows the same pattern as other comments in the file.


Good Practices Observed

  • Proper stringsdict XML structure with NSStringPluralRuleType
  • Complete removal of obsolete string keys from Localizable.strings
  • Tests updated to match new localization keys
  • Entire sentence moved to stringsdict for BitwardenCouldNotDecryptXVaultItemsDescriptionLong to support verb inflection in other languages
  • Consistent use of %d format specifier and NSStringFormatValueTypeKey of type d
  • Clean commit history with focused changes

Action Items for Author

None required. The PR is ready to merge as-is. The suggested improvements above are minor enhancements that are not blockers.

Optional Considerations

  • ✅ If desired, add explicit pluralization tests (though current coverage is adequate)
  • ✅ Consider documenting stringsdict usage patterns in a contributing guide for future localization work (out of scope for this PR)

Security & Architecture Compliance

  • ✅ No security concerns
  • ✅ Follows established localization patterns
  • ✅ Maintains zero-knowledge architecture
  • ✅ No architectural changes required
  • ✅ Tests verify functionality
  • ✅ CI checks passed (Checkmarx, Codecov)

Verdict:Approved - This is a well-executed localization improvement that enables proper pluralization for item-related strings across multiple languages.

@KatherineInCode KatherineInCode changed the title [PM-27098] And plurals for items [PM-27098] Add plurals for items Nov 3, 2025
@KatherineInCode KatherineInCode merged commit 4d53d05 into main Nov 5, 2025
20 of 22 checks passed
@KatherineInCode KatherineInCode deleted the pm-27098/item-plurals branch November 5, 2025 16:06
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