Skip to content

Commit

Permalink
Fix mismatched token handling in localization script
Browse files Browse the repository at this point in the history
  • Loading branch information
joewalsh committed Dec 12, 2019
1 parent 0ba844d commit 0822f53
Show file tree
Hide file tree
Showing 27 changed files with 10 additions and 2 deletions.
Binary file modified Wikipedia/iOS Native Localizations/ar.lproj/Localizable.strings
Binary file not shown.
Binary file modified Wikipedia/iOS Native Localizations/ast.lproj/Localizable.strings
Binary file not shown.
Binary file modified Wikipedia/iOS Native Localizations/ca.lproj/Localizable.strings
Binary file not shown.
Binary file modified Wikipedia/iOS Native Localizations/da.lproj/Localizable.strings
Binary file not shown.
Binary file modified Wikipedia/iOS Native Localizations/es.lproj/Localizable.strings
Binary file not shown.
Binary file modified Wikipedia/iOS Native Localizations/fr.lproj/Localizable.strings
Binary file not shown.
Binary file modified Wikipedia/iOS Native Localizations/he.lproj/Localizable.strings
Binary file not shown.
Binary file modified Wikipedia/iOS Native Localizations/it.lproj/Localizable.strings
Binary file not shown.
Binary file modified Wikipedia/iOS Native Localizations/ko.lproj/Localizable.strings
Binary file not shown.
Binary file modified Wikipedia/iOS Native Localizations/lb.lproj/Localizable.strings
Binary file not shown.
Binary file modified Wikipedia/iOS Native Localizations/lv.lproj/Localizable.strings
Binary file not shown.
Binary file modified Wikipedia/iOS Native Localizations/mk.lproj/Localizable.strings
Binary file not shown.
Binary file modified Wikipedia/iOS Native Localizations/nl.lproj/Localizable.strings
Binary file not shown.
Binary file modified Wikipedia/iOS Native Localizations/pl.lproj/Localizable.strings
Binary file not shown.
Binary file modified Wikipedia/iOS Native Localizations/pt-br.lproj/Localizable.strings
Binary file not shown.
Binary file modified Wikipedia/iOS Native Localizations/pt.lproj/Localizable.strings
Binary file not shown.
Binary file modified Wikipedia/iOS Native Localizations/ru.lproj/Localizable.strings
Binary file not shown.
Binary file modified Wikipedia/iOS Native Localizations/sd.lproj/Localizable.strings
Binary file not shown.
Binary file modified Wikipedia/iOS Native Localizations/sk.lproj/Localizable.strings
Binary file not shown.
Binary file not shown.
Binary file modified Wikipedia/iOS Native Localizations/sr-el.lproj/Localizable.strings
Binary file not shown.
Binary file modified Wikipedia/iOS Native Localizations/sv.lproj/Localizable.strings
Binary file not shown.
Binary file modified Wikipedia/iOS Native Localizations/tr.lproj/Localizable.strings
Binary file not shown.
Binary file modified Wikipedia/iOS Native Localizations/uk.lproj/Localizable.strings
Binary file not shown.
Binary file not shown.
Binary file modified scripts/localization
Binary file not shown.
12 changes: 10 additions & 2 deletions scripts/localization.swift
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@ extension String {
})
actualComponent = String(component.suffix(from: component.index(component.startIndex, offsetBy: match.range.length)))
} else {
#if DEBUG
print("Translatewiki prefix \(numberString) not supported on iOS for this language. Ignoring \(String(describing: component))")
#endif
}

guard let keyToInsert = keyForComponent, let componentToInsert = actualComponent else {
Expand Down Expand Up @@ -264,7 +266,11 @@ extension String {
guard let result = result else {
return
}
let number = iOSTokenRegex.replacementString(for: result, in: self as String, offset: 0, template: "$1")
var number = iOSTokenRegex.replacementString(for: result, in: self as String, offset: 0, template: "$1")
// treat an un-numbered token as 1
if number == "" {
number = "1"
}
let token = iOSTokenRegex.replacementString(for: result, in: self as String, offset: 0, template: "$2")
if tokenDictionary[number] == nil {
tokenDictionary[number] = token
Expand Down Expand Up @@ -482,7 +488,9 @@ func importLocalizationsFromTWN(_ path: String) {
let nativeLocalization = twnString.iOSNativeLocalization(tokens: enTokens)
let nativeLocalizationTokens = nativeLocalization.iOSTokenDictionary
guard nativeLocalizationTokens == enTokens else {
//print("Mismatched tokens in \(locale) for \(key):\n\(enDictionary[key] ?? "")\n\(nativeLocalization)")
#if DEBUG
print("Mismatched tokens in \(locale) for \(key):\n\(enDictionary[key] ?? "")\n\(nativeLocalization)")
#endif
continue
}
if twnString.contains("{{PLURAL:") {
Expand Down

0 comments on commit 0822f53

Please sign in to comment.