Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
With the introduction of the String Catalogs file format in Xcode 15, developers have now the option to create localizations that vary by device and/or by plural. On top of that, multiple tokens can be added in a localized phrase (also known as substitutions) that can also support the aforementioned variations. In order to support all those new formats as well as the old substitution rules found in the Strings Dictionary format (`.stringsdict`), the advanced rules from the CLI tool are formatted as an intermediate XML structure and pushed to CDS. Once those XML structures are pulled from CDS by the application, they need to be properly parsed and formatted in a way so that they are ready for presentation when needed by the application. During the phase when the SDK populates its cache, the XML structures are either evaluated based on the device that they currently run (in case of device variations) or they are converted to intermediate ICU rules (if they contain plural variations) so that they are ready to be evaluated when arguments are passed to them during runtime. For that to happen, the logic that devices the plural rule extraction has been heavily refactored to account for all possible cases (simple plural rules, multiple plural rules, plural rules with extra arguments, and so on), while making sure that the right argument is used on the right rule by respecting the positional specifiers on each substitution phrase. More unit tests have been added to test those cases as well as edge-case scenarios and existing unit tests have been improved.
- Loading branch information