You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+5-2Lines changed: 5 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,11 +14,14 @@ _None_
14
14
15
15
### Bug Fixes
16
16
17
-
_None_
17
+
-`StringsFileValidationHelper.find_duplicated_keys` now parses unquoted keys/values and inter-token comments, matching the grammar `plutil` accepts, instead of raising `Invalid character`. This lets `ios_lint_localizations`' `check_duplicate_keys` work on `InfoPlist.strings`-style files. [#741]
18
+
-`ios_lint_localizations`' `check_duplicate_keys` now warns and skips, rather than crashing, on a file that parses as a property list but isn't a tokenizable flat `.strings`. [#741]
19
+
-`L10nHelper.merge_strings` now prefixes keys via a comment-aware tokenizer, so unquoted keys, unquoted values, and keys behind an inter-token comment are prefixed in the output consistently with the reported keys. [#741]
18
20
19
21
### Internal Changes
20
22
21
-
_None_
23
+
- Centralized `.strings` duplicate-key detection behind `StringsFileValidationHelper.scan_for_duplicate_keys`, returning a `[:scanned | :unsupported_format | :unscannable, payload]` tri-state that callers can map to their own warn-and-skip vs fail-closed policy. [#741]
24
+
-`L10nHelper.strings_file_type` and `StringsFileValidationHelper.scan_for_duplicate_keys` accept `assume_valid:` to skip a redundant `plutil -lint` when the caller has already parsed the file. [#741]
Copy file name to clipboardExpand all lines: lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_l10n_helper.rb
+43-15Lines changed: 43 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -15,18 +15,24 @@ class L10nHelper
15
15
# Returns the type of a `.strings` file (XML, binary or ASCII)
16
16
#
17
17
# @param [String] path The path to the `.strings` file to check
18
+
# @param [Boolean] assume_valid Skip the `plutil -lint` validity check when the caller has already
19
+
# confirmed the file parses (e.g. via `read_strings_file_as_hash`), avoiding a redundant
20
+
# `plutil` invocation. Only the format detection (`file`) then runs.
18
21
# @return [Symbol] The file format used by the `.strings` file. Can be one of:
19
22
# - `:text` for the ASCII-plist file format (containing typical `"key" = "value";` lines)
20
23
# - `:xml` for XML plist file format (can be used if machine-generated, especially since there's no official way/tool to generate the ASCII-plist file format as output)
21
24
# - `:binary` for binary plist file format (usually only true for `.strings` files converted by Xcode at compile time and included in the final `.app`/`.ipa`)
22
25
# - `nil` if the file does not exist or is neither of those format (e.g. not a `.strings` file at all)
# Read line-by-line to reduce memory footprint during content copy
97
-
read_utf8_lines(input_file).eachdo |line|
98
-
unlessprefix.nil? || prefix.empty?
99
-
# The `/u` modifier on the RegExps is to make them UTF-8
100
-
line.gsub!(/^(\s*")/u,"\\1#{prefix}")# Lines starting with a quote are considered to be start of a key; add prefix right after the quote
101
-
line.gsub!(/^(\s*)([A-Z0-9_]+)(\s*=\s*")/ui,"\\1\"#{prefix}\\2\"\\3")# Lines starting with an identifier followed by a '=' are considered to be an unquoted key (typical in InfoPlist.strings files for example)
102
-
end
103
-
tmp_file.write(line)
105
+
# Add the prefix to every key. We tokenize via `StringsFileValidationHelper.prefix_keys` rather than
106
+
# matching keys with a line-based regex, so that keys are found regardless of where `.strings` comments
107
+
# sit (e.g. `CFBundleName /* note */ = WordPress;`) and `key = value`-looking text inside a comment is
108
+
# left alone. It also handles dictionary/array values (`"k" = { … };`) — prefixing the outer key and
0 commit comments