Skip to content

Commit

Permalink
Merge branch 'main' into talk-page-archives-2
Browse files Browse the repository at this point in the history
  • Loading branch information
mazevedofs authored Jan 23, 2023
2 parents a169e08 + ddeae94 commit e3e43ec
Show file tree
Hide file tree
Showing 30 changed files with 130 additions and 56 deletions.
5 changes: 5 additions & 0 deletions WMF Framework/CharacterSet+LinkParsing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ extension CharacterSet {
return NSCharacterSet.wmf_relativePathAndFragmentAllowed()
}

// RFC 3986 reserved + unreserved characters + percent (%)
public static var rfc3986Allowed: CharacterSet {
return CharacterSet(charactersIn: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~:/?#[]@!$&'()*+,;=%")
}

static let urlQueryComponentAllowed: CharacterSet = {
var characterSet = CharacterSet.urlQueryAllowed
characterSet.remove(charactersIn: "+&=")
Expand Down
27 changes: 25 additions & 2 deletions WMF Framework/Localization/WMFLocalization.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,28 @@

@implementation NSBundle (WMFLocalization)

// A mapping of language variant content codes to available native `NSLocale` bundle identifiers. The values map to existing .lproj folders.
NSDictionary<NSString*, NSString*> *variantContentCodeToLocalizationBundleMapping = @{
// Chinese variants
@"zh-hk": @"zh-hant",
@"zh-mo": @"zh-hant",
@"zh-my": @"zh-hans",
@"zh-sg": @"zh-hans",
@"zh-tw": @"zh-hant",

// Serbian variants
// no-op - both variants are natively available iOS localizations

// Kurdish variants
@"ku-arab": @"ckb",

// Tajik variants
@"tg-latn": @"tg",

// Uzbek variants
@"uz-cyrl": @"uz",
};

+ (NSBundle *)wmf_localizationBundle {
return [NSBundle wmf];
}
Expand All @@ -18,7 +40,9 @@ + (nonnull NSMutableDictionary *)wmf_languageBundles {

- (nonnull NSString *)wmf_languageBundleNameForWikipediaLanguageCode:(nonnull NSString *)languageCode {
NSString *bundleName = languageCode;
if ([languageCode isEqualToString:@"zh"]) {
if ([variantContentCodeToLocalizationBundleMapping valueForKey:languageCode]) {
bundleName = [variantContentCodeToLocalizationBundleMapping valueForKey:languageCode];
} else if ([languageCode isEqualToString:@"zh"]) {
bundleName = @"zh-hans";
for (NSString *code in [NSLocale wmf_preferredLanguageCodes]) {
if (![code hasPrefix:@"zh"]) {
Expand All @@ -29,7 +53,6 @@ - (nonnull NSString *)wmf_languageBundleNameForWikipediaLanguageCode:(nonnull NS
bundleName = [code lowercaseString];
break;
}

}
} else if ([languageCode isEqualToString:@"sr"]) {
bundleName = @"sr-ec";
Expand Down
16 changes: 16 additions & 0 deletions Widgets/Utilities/View+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,20 @@ extension View {
return self.shadow(color: Color.black.opacity(intensity), radius: 5, x:0, y: 0)
}

/// Adds an iOS-version dependent `List` background `Color`
/// - Parameters:
/// - color: `Color` to use as background
/// - edges: safe area edges to ignore
/// - Returns: a modified `View` with the desired background `Color` applied
@ViewBuilder
func listBackgroundColor(_ color: Color, ignoringSafeAreaEdges edges: Edge.Set = .all) -> some View {
if #available(iOS 16, *) {
self
.scrollContentBackground(.hidden)
.background(color).edgesIgnoringSafeArea(edges)
} else {
self.background(color).edgesIgnoringSafeArea(edges)
}
}

}
8 changes: 8 additions & 0 deletions Wikipedia.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
00021DEA24D48EFE00476F97 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 00021DE924D48EFE00476F97 /* Assets.xcassets */; };
00021DEE24D48EFE00476F97 /* WidgetsExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 00021DE124D48EFD00476F97 /* WidgetsExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
00021E0424D4A42A00476F97 /* PictureOfTheDayWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 00021E0324D4A42A00476F97 /* PictureOfTheDayWidget.swift */; };
00097D5C29660FF2000B3514 /* View+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 006D273424D8BAFB00947551 /* View+Extensions.swift */; };
00097D5D29660FF3000B3514 /* View+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 006D273424D8BAFB00947551 /* View+Extensions.swift */; };
00097D5E29660FF3000B3514 /* View+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 006D273424D8BAFB00947551 /* View+Extensions.swift */; };
00097D5F29660FF4000B3514 /* View+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 006D273424D8BAFB00947551 /* View+Extensions.swift */; };
0010F93927A49C7700D77848 /* HorizontalSpacerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0010F93827A49C7700D77848 /* HorizontalSpacerView.swift */; };
0010F93A27A49C7700D77848 /* HorizontalSpacerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0010F93827A49C7700D77848 /* HorizontalSpacerView.swift */; };
0010F93B27A49C7700D77848 /* HorizontalSpacerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0010F93827A49C7700D77848 /* HorizontalSpacerView.swift */; };
Expand Down Expand Up @@ -11569,6 +11573,7 @@
D837CC37231FE9CC00BA6130 /* ThemeableViewController.swift in Sources */,
83C0688E292EEDAF00DF1403 /* TalkPageViewController+TalkPageFormattingToolbar.swift in Sources */,
7A73B48221E54B4200249E09 /* SectionEditorNavigationItemController.swift in Sources */,
00097D5C29660FF2000B3514 /* View+Extensions.swift in Sources */,
B0FFFB2A21C9BED1001E787E /* TextFormattingButton.swift in Sources */,
7AF6F76622395BEC00949393 /* EditingWelcomeViewController.swift in Sources */,
B0524B51214854E900D8FD8D /* DescriptionWelcomeContainerViewController.swift in Sources */,
Expand Down Expand Up @@ -12544,6 +12549,7 @@
67B64D5F2507E9FD00FA27F3 /* ArticleAsLivingDocSmallEventCollectionViewCell.swift in Sources */,
83C06891292EEDAF00DF1403 /* TalkPageViewController+TalkPageFormattingToolbar.swift in Sources */,
D818FEBE21E39EE2001A7A00 /* CodemirrorSetupUserScript.swift in Sources */,
00097D5F29660FF4000B3514 /* View+Extensions.swift in Sources */,
D8A42AA61E815A9C00D8E281 /* WMFArticleRevisionFetcher.m in Sources */,
7ABE17382239DCF6006BA309 /* WelcomeAnimationViewController.swift in Sources */,
7A73B48521E54B4200249E09 /* SectionEditorNavigationItemController.swift in Sources */,
Expand Down Expand Up @@ -13120,6 +13126,7 @@
00841DE524477805003CF74A /* AppTabBarDelegate.swift in Sources */,
D8CE25271E698E2400DAE2E0 /* WMFChangePasswordViewController.swift in Sources */,
D8B166861FD97A0500097D8B /* ViewController.swift in Sources */,
00097D5E29660FF3000B3514 /* View+Extensions.swift in Sources */,
B0421AA3206991F500C22630 /* SavedTabBarItemProgressBadgeManager.swift in Sources */,
7A6ED52220ADBF950001849F /* LoginFunnel.swift in Sources */,
83CA612B20D1675800EF0C4A /* ExploreCardViewController.swift in Sources */,
Expand Down Expand Up @@ -13721,6 +13728,7 @@
D8EC3E1A1E9BDA35006712EB /* UIVIewController+WMFCommonRotationSupport.swift in Sources */,
83E776A520FFA4D700E26A47 /* DetailTransition.swift in Sources */,
6771299524FF775E00E89CA5 /* ArticleAsLivingDocLargeEventCollectionViewCell.swift in Sources */,
00097D5D29660FF3000B3514 /* View+Extensions.swift in Sources */,
D8EC3E1B1E9BDA35006712EB /* (null) in Sources */,
B0C7A0851F710EB1008415E7 /* WMFWelcomeAnalyticsAnimationBackgroundView.swift in Sources */,
D8EC3E1D1E9BDA35006712EB /* WMFTitleInsetRespectingButton.m in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,11 @@ extension ArticleViewController: ArticleWebMessageHandling {
let titleItem = TableOfContentsItem(id: 0, titleHTML: article.displayTitleHTML, anchor: "", rootItemId: 0, indentationLevel: 0)
var allItems: [TableOfContentsItem] = [titleItem]
allItems.append(contentsOf: items)
let aboutThisArticleTitle = CommonStrings.aboutThisArticleTitle(with: articleLanguageCode)
let readMoreTitle = CommonStrings.readMoreTitle(with: articleLanguageCode)

// While `items` includes strings localized to the language of the article, our additional appended strings here are not. We need to specify we want localized strings for a local `.lproj` we actually have (which unfortunately doesn't always match the article itself). Here, we send the full language variant code to hint to pull the most accurate localized string we may have available based on the language variant of the article itself.
let languageCode = articleURL.wmf_contentLanguageCode ?? articleLanguageCode
let aboutThisArticleTitle = CommonStrings.aboutThisArticleTitle(with: languageCode)
let readMoreTitle = CommonStrings.readMoreTitle(with: languageCode)
let aboutThisArticleItem = TableOfContentsItem(id: -2, titleHTML: aboutThisArticleTitle, anchor: PageContentService.Footer.Menu.fragment, rootItemId: -2, indentationLevel: 0)
allItems.append(aboutThisArticleItem)
let readMoreItem = TableOfContentsItem(id: -3, titleHTML: readMoreTitle, anchor: PageContentService.Footer.ReadMore.fragment, rootItemId: -3, indentationLevel: 0)
Expand Down
9 changes: 6 additions & 3 deletions Wikipedia/Code/NotificationsCenterFilterView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,17 @@ struct NotificationsCenterFilterView: View {
.foregroundColor(Color(viewModel.theme.colors.primaryText))
}
)
.background(Color(viewModel.theme.colors.baseBackground).edgesIgnoringSafeArea(.all))
.listBackgroundColor(Color(viewModel.theme.colors.baseBackground))
.navigationBarTitle(Text(WMFLocalizedString("notifications-center-filters-title", value: "Filters", comment: "Navigation bar title text for the filters view presented from notifications center. Allows for filtering by read status and notification type.")), displayMode: .inline)
.onAppear(perform: {
if #unavailable(iOS 16) {
UITableView.appearance().backgroundColor = UIColor.clear
}
})
.onDisappear(perform: {

UITableView.appearance().backgroundColor = UIColor.systemGroupedBackground
if #unavailable(iOS 16) {
UITableView.appearance().backgroundColor = UIColor.systemGroupedBackground
}
})
}
}
9 changes: 6 additions & 3 deletions Wikipedia/Code/NotificationsCenterInboxView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,17 @@ struct NotificationsCenterInboxView: View {
}
)
.padding(.horizontal, horizontalSizeClass == .regular ? (UIFont.preferredFont(forTextStyle: .body).pointSize) : 0)
.background(Color(viewModel.theme.colors.baseBackground).edgesIgnoringSafeArea(.all))
.listBackgroundColor(Color(viewModel.theme.colors.baseBackground))
.navigationBarTitle(Text(WMFLocalizedString("notifications-center-inbox-title", value: "Projects", comment: "Navigation bar title text for the inbox view presented from notifications center. Allows for filtering out notifications by Wikimedia project type.")), displayMode: .inline)
.onAppear(perform: {
if #unavailable(iOS 16) {
UITableView.appearance().backgroundColor = UIColor.clear
}
})
.onDisappear(perform: {

UITableView.appearance().backgroundColor = UIColor.systemGroupedBackground
if #unavailable(iOS 16) {
UITableView.appearance().backgroundColor = UIColor.systemGroupedBackground
}
})
}
}
18 changes: 7 additions & 11 deletions Wikipedia/Code/URL+LinkParsing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,13 @@ extension URL {
/// Resolves a relative href from a wiki page against the callee.
/// The callee should be a standardized page URL generated with wmf_databaseURL, non-article namespaces are OK
public func resolvingRelativeWikiHref(_ href: String) -> URL? {
let urlComponentsString: String

/// The link is sometimes encoded, and sometimes unencoded. (In some cases, this depends on whether an editor put added an escaped or unescaped version of the URL.) So we remove any potential encoding, so that we can be assured we are starting with an unencoded string.
let hrefWithoutEncoding = href.removingPercentEncoding ?? href

if hrefWithoutEncoding.hasPrefix(".") || hrefWithoutEncoding.hasPrefix("/") {
urlComponentsString = hrefWithoutEncoding.addingPercentEncoding(withAllowedCharacters: .relativePathAndFragmentAllowed) ?? href
} else {
urlComponentsString = hrefWithoutEncoding
}
let components = URLComponents(string: urlComponentsString)
// The link is sometimes encoded, and sometimes unencoded (In some cases, this depends on
// whether an editor put an escaped or unescaped version of the URL). We percent-encode
// certain characters first because URLComponents cannot ingest strings with these chacters
// in some versions of iOS (e.g. 15.5).
let urlComponentsString = href.addingPercentEncoding(withAllowedCharacters: .rfc3986Allowed) ?? href
var components = URLComponents(string: urlComponentsString)

// Encode this URL to handle titles with forward slashes, otherwise URLComponents thinks they're separate path components
let encodedBaseURL = encodedWikiURL
var resolvedURL = components?.url(relativeTo: encodedBaseURL)?.absoluteURL
Expand Down
1 change: 1 addition & 0 deletions Wikipedia/Localizations/fr.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,7 @@
"talk-page-unsubscription-failed-alert" = "Le désabonnement du sujet a échoué, veuillez essayer à nouveau.";
"talk-page-user-about" = "À propos des pages de discussion des utilisateurs";
"talk-page-user-contributions" = "Contributions";
"talk-pages-archives-view-title" = "Archives";
"talk-pages-coffee-roll-read-more" = "Lire davantage";
"talk-pages-comment-added-alert-title" = "Votre commentaire a été ajouté";
"talk-pages-compose-close-confirmation-keep" = "Continuer à modifier";
Expand Down
1 change: 1 addition & 0 deletions Wikipedia/Localizations/he.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,7 @@
"talk-page-unsubscription-failed-alert" = "ביטול הרישום לפריט נכשל, נא לנסות שוב.";
"talk-page-user-about" = "אודות דפי שיחת משתמש";
"talk-page-user-contributions" = "תרומות";
"talk-pages-archives-view-title" = "ארכיונים";
"talk-pages-coffee-roll-read-more" = "לקרוא עוד";
"talk-pages-comment-added-alert-title" = "התגובה שלך נוספה";
"talk-pages-compose-close-confirmation-keep" = "להמשיך לערוך";
Expand Down
2 changes: 2 additions & 0 deletions Wikipedia/Localizations/hu.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// Author: Bencemac
// Author: Csega
// Author: Dj
// Author: Eukarióta
// Author: Hanna Tardos
// Author: Macofe
// Author: MeskoBalazs
Expand Down Expand Up @@ -687,6 +688,7 @@
"talk-page-title-article-talk" = "Szócikk Vitalap";
"talk-page-title-user-talk" = "Szerkesztővita";
"talk-page-unsubscribe-to-topic" = "Leiratkozás";
"talk-pages-archives-view-title" = "Archívumok";
"talk-pages-coffee-roll-read-more" = "Továbbolvas";
"talk-pages-reply-button-title" = "Válasz erre a témára";
"theme-black-display-name" = "Fekete";
Expand Down
1 change: 1 addition & 0 deletions Wikipedia/Localizations/it.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,7 @@
"talk-page-topic-title" = "Discussione";
"talk-page-unsubscribe-to-topic" = "Annulla iscrizione";
"talk-page-unsubscribed-alert-title" = "Hai annullato l'iscrizione.";
"talk-pages-archives-view-title" = "Archivi";
"talk-pages-comment-added-alert-title" = "Il tuo commento è stato aggiunto";
"talk-pages-compose-close-confirmation-keep" = "Continua a modificare";
"talk-pages-empty-view-button-article-add-topic" = "Aggiungi un nuovo argomento";
Expand Down
1 change: 1 addition & 0 deletions Wikipedia/Localizations/ja.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -973,6 +973,7 @@
"talk-page-topic-title" = "議論";
"talk-page-unsubscribe-to-topic" = "購読解除";
"talk-page-user-contributions" = "投稿記録";
"talk-pages-archives-view-title" = "アーカイブ";
"talk-pages-coffee-roll-read-more" = "さらに読む";
"talk-pages-comment-added-alert-title" = "あなたのコメントが追加されました";
"talk-pages-compose-close-confirmation-keep" = "編集を続行";
Expand Down
1 change: 1 addition & 0 deletions Wikipedia/Localizations/ko.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@
"explore-random-article-sub-heading-from-language-wikipedia" = "$1 위키백과에서";
"explore-random-article-sub-heading-from-wikipedia" = "위키백과에서";
"explore-randomizer" = "임의의 문서 보기";
"export-user-data-confirmation-title" = "앱 라이브러리를 공유하시겠습니까?";
"export-user-data-generic-error" = "데이터를 내보내는 동안 오류가 발생했습니다. 나중에 다시 시도해 주십시오.";
"export-user-data-space-error" = "사용자 데이터를 내보낼 장치 공간이 부족합니다. 나중에 다시 시도해 주십시오.";
"export-user-data-title" = "사용자 데이터 내보내기";
Expand Down
13 changes: 5 additions & 8 deletions Wikipedia/Localizations/mk.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -489,10 +489,8 @@
"import-shared-reading-list-survey-prompt-button-cancel" = "Не сега";
"import-shared-reading-list-survey-prompt-button-take-survey" = "Пополнете ја анкетата";
"import-shared-reading-list-survey-prompt-footer" = "ПОгледајте ја нашата $1изјава за личните податоци$2. Анкетата ја овозможува трето лице. Погледајте ги нивните $3правила за личните податоци$4.";
// Fuzzy
"import-shared-reading-list-survey-prompt-subtitle" = "Споделени списоци за читање е пробна функција и ни тербаат ваши мислења за да ја подобриме или отстраниме.";
// Fuzzy
"import-shared-reading-list-survey-prompt-title" = "Дали би ни помогнале да ја подобриме оваа функција, пополнувајќи анкета за неа?";
"import-shared-reading-list-survey-prompt-subtitle" = "„Сподели списоци за читање“ е пробна функција и ни требаат ваши мислења за да ја подобриме или отстраниме.";
"import-shared-reading-list-survey-prompt-title" = "Можете ли да ни помогнете да ја подобриме „Сподели списоци за читање“?";
"import-shared-reading-list-title" = "Увези споделен список за читање";
"in-the-news-sub-title-from-language-wikipedia" = "Од Википедија на $1";
"in-the-news-sub-title-from-wikipedia" = "Од Википедија";
Expand Down Expand Up @@ -1061,6 +1059,7 @@
"talk-page-unsubscription-failed-alert" = "Отпишувањето од темата не успеа. Обидете се повторно.";
"talk-page-user-about" = "За корисничките разговорни страници";
"talk-page-user-contributions" = "Придонеси";
"talk-pages-archives-view-title" = "Архиви";
"talk-pages-coffee-roll-read-more" = "Прочитајте повеќе";
"talk-pages-comment-added-alert-title" = "Вашиот коментар е додаден";
"talk-pages-compose-close-confirmation-keep" = "Продолжи со уредување";
Expand Down Expand Up @@ -1122,10 +1121,8 @@
"vanish-account-warning-title" = "Предупредување";
"vanish-modal-item" = "Ако го завршивте барањето за отстранување, дајте ни пар денови за да го обработи администратор.";
"vanish-modal-item-2" = "Ако не сте сигурни дали сме го примиле барањето, проверете го вашиот прилог Пошта";
// Fuzzy
"vanish-modal-item-3" = "Ако имате други прашања во врска со остранувањето на сметки, појдете на Википедија:Право на исчезнување";
// Fuzzy
"vanish-modal-item-3-ios15" = "If you have further questions about vanishing please visit $1Википедија:Право на исчезнување$2$3.";
"vanish-modal-item-3" = "Ако имате други прашања во врска со остранувањето на сметки, појдете на Meta:Right_to_vanish";
"vanish-modal-item-3-ios15" = "Ако имате уште прашања за исчезнувањето, посетете ја страницата $1Meta:Right_to_vanish$2$3";
"vanish-modal-title" = "Барање за поништување";
"vanishing-request-email-title" = "Побарај исчезнување";
"variants-alert-dismiss-button" = "Не, благодарам";
Expand Down
Loading

0 comments on commit e3e43ec

Please sign in to comment.