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
let deLocale = Locale(identifier: "de")
do {
try style.localizeLabels(into: deLocale)
results in all name_* of every layer to be overridden with name_de
Expected behavior
Only the primary localized language should be overridden.
Notes / preliminary analysis
Style+Localization::updateExpression applies to all occurrences in range
Fix
Add
/// Updates string once using the first occurrence of a regex
/// - Parameters:
/// - replacement: New string to replace the matched pattern
/// - regex: The regex pattern that will be matched for replacement
internal mutating func updateOnceExpression(replacement: String, regex: NSRegularExpression) {
var range = NSRange(location: 0, length: self.count)
range = regex.rangeOfFirstMatch(in: self, options: [], range: range)
if (range.lowerBound == NSNotFound) {
return
}
self = regex.stringByReplacingMatches(in: self,
options: [],
range: range,
withTemplate: replacement)
}
and replace stringExpression.updateExpression(replacement: replacement, regex: expressionCoalesce)
with stringExpression.updateOnceExpression(replacement: replacement, regex: expressionCoalesce)
The text was updated successfully, but these errors were encountered:
Environment
Observed behavior and steps to reproduce
Setting
results in all name_* of every layer to be overridden with name_de
Expected behavior
Only the primary localized language should be overridden.
Notes / preliminary analysis
Style+Localization::updateExpression applies to all occurrences in range
Fix
Add
and replace
stringExpression.updateExpression(replacement: replacement, regex: expressionCoalesce)
with
stringExpression.updateOnceExpression(replacement: replacement, regex: expressionCoalesce)
The text was updated successfully, but these errors were encountered: