Repository navigation
LocalizeKit runtime hardening: SafeFormat crash-safety, plural/locale fixes, and cleanup - #28
Merged
ImaginativeShohag merged 9 commits intoSep 26, 2026
Conversation
Clarify that the property holds a language code (e.g. "en", "fr_FR"), not a display name. Update all call sites and docs accordingly.
…cases Guard the plural-category resolution against Int.min (abs() would trap) and collapse the duplicated CLDR branches into shared cases.
Streamline the clear-all and cache-state logic in the storage layer.
…ecifiers Reject genuine NSNumber (incl. NSDecimalNumber) for non-%@ specifiers: it satisfies `is Int`/`is Double` but is encoded as an object pointer, so %d/%f would read pointer bits and print garbage. Surface malformed percent sequences as ambiguous so SafeFormat degrades to the verbatim string instead of silently mangling output: trailing bare `%` at end-of-string, positional index too large to fit in Int, and specifiers truncated before their conversion character. Add coverage and performance cases for the new fallback paths.
…ce locale The default-plural fallback resolved the CLDR category from the device locale, so a French device running the app in English would pick French plural forms for the English default strings. Resolve the category from the app's selected language (currentLanguageCode) instead.
Resolve a language by code within a specific country's list. The same code can appear under multiple countries with different versions, so resolving against the flattened allLanguages would pick a nondeterministic entry.
Adopt the test_when_should naming convention across the localization test suites. Correct the misleading SafeFormat mismatch test (it falls back to the verbatim format rather than partially interpolating), add the French default-plural regression test backing the app-language fallback fix, and reset the shared LocalizationManager language in setUp to keep plural resolution deterministic across tests.
Extract the inline LocalizationAPI stub data into bundled mock JSON resources for cleaner, more maintainable fixtures.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ImaginativeShohag
self-requested a review
September 21, 2026 15:13
ImaginativeShohag
merged commit Sep 26, 2026
9366292
into
over-the-air-translation-update
1 of 2 checks passed
ImaginativeShohag
deleted the
localizekit-safeformat-and-plural-fixes
branch
September 26, 2026 00:23
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Hardens the LocalizeKit runtime with crash-safety fixes, correct locale-aware
plural resolution, and supporting refactors/test cleanup.
Fixes
NSNumber(incl.NSDecimalNumber) for non-%@specifiers — it satisfiesis Int/is Doublebut is encoded as an object pointer, so%d/%fwouldprint garbage.
%, positional index too large forInt, and specifierstruncated before their conversion char.
currentLanguageCode), not the device locale (a French device on an English app no longer picksFrench plural forms).
Int.min(abs()would trap).Features
language(code:in:)lookup to avoid nondeterministic matches across countries sharing a code.Refactors
currentLanguage→currentLanguageCodefor clarity across call sites and docs.LocalizationAPIstubs into bundled mock JSON fixtures.Tests / chore
test_when_should, correct the misleading SafeFormat mismatch test, and reset the sharedLocalizationManagerlanguage insetUpfor determinism.