Merge pull request #2601 from stuartbreckenridge/main

Widget Localized
This commit is contained in:
Maurice Parker 2020-11-21 09:54:27 -06:00 committed by GitHub
commit 4a3c4a1082
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 194 additions and 43 deletions

View File

@ -7,6 +7,8 @@
objects = {
/* Begin PBXBuildFile section */
1701E1B52568983D009453D8 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 1701E1B72568983D009453D8 /* Localizable.strings */; };
1701E1E725689D1E009453D8 /* Localized.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1701E1E625689D1E009453D8 /* Localized.swift */; };
1704053424E5985A00A00787 /* SceneNavigationModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1704053324E5985A00A00787 /* SceneNavigationModel.swift */; };
1704053524E5985A00A00787 /* SceneNavigationModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1704053324E5985A00A00787 /* SceneNavigationModel.swift */; };
1710B9132552354E00679C0D /* AddAccountHelpView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1710B9122552354E00679C0D /* AddAccountHelpView.swift */; };
@ -1313,6 +1315,8 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
1701E1B62568983D009453D8 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
1701E1E625689D1E009453D8 /* Localized.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Localized.swift; sourceTree = "<group>"; };
1704053324E5985A00A00787 /* SceneNavigationModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneNavigationModel.swift; sourceTree = "<group>"; };
1710B9122552354E00679C0D /* AddAccountHelpView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddAccountHelpView.swift; sourceTree = "<group>"; };
1710B928255246F900679C0D /* EnableExtensionPointHelpView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EnableExtensionPointHelpView.swift; sourceTree = "<group>"; };
@ -2119,7 +2123,6 @@
176814792564BE3C00D98635 /* Resources */,
176813FB2564BB2D00D98635 /* Assets.xcassets */,
176813FD2564BB2D00D98635 /* Info.plist */,
17D0682B2564F47E00C0B37E /* Localizable.stringsdict */,
);
path = Widget;
sourceTree = "<group>";
@ -2146,7 +2149,10 @@
176814792564BE3C00D98635 /* Resources */ = {
isa = PBXGroup;
children = (
1701E1E625689D1E009453D8 /* Localized.swift */,
1768147A2564BE5400D98635 /* widget-sample.json */,
1701E1B72568983D009453D8 /* Localizable.strings */,
17D0682B2564F47E00C0B37E /* Localizable.stringsdict */,
);
path = Resources;
sourceTree = "<group>";
@ -3520,6 +3526,7 @@
176813EF2564BB2C00D98635 /* Sources */,
176813F02564BB2C00D98635 /* Frameworks */,
176813F12564BB2C00D98635 /* Resources */,
1701E1BF25689B44009453D8 /* SwiftGen Localization */,
);
buildRules = (
);
@ -3934,6 +3941,7 @@
buildActionMask = 2147483647;
files = (
176813FC2564BB2D00D98635 /* Assets.xcassets in Resources */,
1701E1B52568983D009453D8 /* Localizable.strings in Resources */,
1768147B2564BE5400D98635 /* widget-sample.json in Resources */,
17D0682C2564F47E00C0B37E /* Localizable.stringsdict in Resources */,
);
@ -4177,6 +4185,24 @@
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
1701E1BF25689B44009453D8 /* SwiftGen Localization */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = "SwiftGen Localization";
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if ! command -v swiftgen &> /dev/null\nthen\n echo \"swiftgen could not be found\"\n exit\nfi\n\nswiftgen run strings -t structured-swift5 \"$PROJECT_DIR/Widget/Resources/en.lproj/Localizable.strings\" \"$PROJECT_DIR/Widget/Resources/Localizable.stringsdict\" --output \"$PROJECT_DIR/Widget/Resources/Localized.swift\";\n";
};
515D50802326D02600EE1167 /* Run Script: Verify No Build Settings */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 8;
@ -4288,6 +4314,7 @@
1768146C2564BD8100D98635 /* WidgetDeepLinks.swift in Sources */,
1768143E2564BCC800D98635 /* TodayWidget.swift in Sources */,
1768142D2564BCA800D98635 /* TimelineProvider.swift in Sources */,
1701E1E725689D1E009453D8 /* Localized.swift in Sources */,
176814652564BD7F00D98635 /* WidgetData.swift in Sources */,
1768145E2564BD7B00D98635 /* WidgetDataDecoder.swift in Sources */,
176814132564BC8A00D98635 /* WidgetBundle.swift in Sources */,
@ -5282,6 +5309,14 @@
/* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */
1701E1B72568983D009453D8 /* Localizable.strings */ = {
isa = PBXVariantGroup;
children = (
1701E1B62568983D009453D8 /* en */,
);
name = Localizable.strings;
sourceTree = "<group>";
};
510C416224E5CDE3008226FD /* ShareViewController.xib */ = {
isa = PBXVariantGroup;
children = (

View File

@ -0,0 +1,76 @@
// swiftlint:disable all
// Generated using SwiftGen https://github.com/SwiftGen/SwiftGen
import Foundation
// swiftlint:disable superfluous_disable_command file_length implicit_return
// MARK: - Strings
// swiftlint:disable explicit_type_interface function_parameter_count identifier_name line_length
// swiftlint:disable nesting type_body_length type_name vertical_whitespace_opening_braces
internal enum L10n {
/// Your smart feeds, summarized.
internal static let smartFeedSummaryWidgetDescription = L10n.tr("Localizable", "SmartFeedSummary_Widget_Description")
/// Your Smart Feed Summary
internal static let smartFeedSummaryWidgetTitle = L10n.tr("Localizable", "SmartFeedSummary_Widget_Title")
/// Starred
internal static let starred = L10n.tr("Localizable", "Starred")
/// A sneak peek at your starred articles.
internal static let starredWidgetDescription = L10n.tr("Localizable", "Starred_Widget_Description")
/// You've not starred any artices.
internal static let starredWidgetNoItems = L10n.tr("Localizable", "Starred_Widget_NoItems")
/// Your Starred Articles
internal static let starredWidgetTitle = L10n.tr("Localizable", "Starred_Widget_Title")
/// Plural format key: "%#@starred_count@"
internal static func starredCount(_ p1: Int) -> String {
return L10n.tr("Localizable", "StarredCount", p1)
}
/// Today
internal static let today = L10n.tr("Localizable", "Today")
/// A sneak peek at recently published unread articles.
internal static let todayWidgetDescription = L10n.tr("Localizable", "Today_Widget_Description")
/// There are no recent articles to read.
internal static let todayWidgetNoItems = L10n.tr("Localizable", "Today_Widget_NoItems")
/// Your Today Articles
internal static let todayWidgetTitle = L10n.tr("Localizable", "Today_Widget_Title")
/// Plural format key: "%#@today_count@"
internal static func todayCount(_ p1: Int) -> String {
return L10n.tr("Localizable", "TodayCount", p1)
}
/// Unread
internal static let unread = L10n.tr("Localizable", "Unread")
/// A sneak peek at your unread articles.
internal static let unreadWidgetDescription = L10n.tr("Localizable", "Unread_Widget_Description")
/// There's nothing to read right now.
internal static let unreadWidgetNoItems = L10n.tr("Localizable", "Unread_Widget_NoItems")
/// Your Unread Articles
internal static let unreadWidgetTitle = L10n.tr("Localizable", "Unread_Widget_Title")
/// Plural format key: "%#@unread_count@"
internal static func unreadCount(_ p1: Int) -> String {
return L10n.tr("Localizable", "UnreadCount", p1)
}
}
// swiftlint:enable explicit_type_interface function_parameter_count identifier_name line_length
// swiftlint:enable nesting type_body_length type_name vertical_whitespace_opening_braces
// MARK: - Implementation Details
extension L10n {
private static func tr(_ table: String, _ key: String, _ args: CVarArg...) -> String {
let format = BundleToken.bundle.localizedString(forKey: key, value: nil, table: table)
return String(format: format, locale: Locale.current, arguments: args)
}
}
// swiftlint:disable convenience_type
private final class BundleToken {
static let bundle: Bundle = {
#if SWIFT_PACKAGE
return Bundle.module
#else
return Bundle(for: BundleToken.self)
#endif
}()
}
// swiftlint:enable convenience_type

View File

@ -0,0 +1,34 @@
/*
Localizable.strings
NetNewsWire
Created by Stuart Breckenridge on 21/11/2020.
Copyright © 2020 Ranchero Software. All rights reserved.
*/
/* Bundle */
"Unread_Widget_Title" = "Your Unread Articles";
"Unread_Widget_Description" = "A sneak peek at your unread articles.";
"Today_Widget_Title" = "Your Today Articles";
"Today_Widget_Description" = "A sneak peek at recently published unread articles.";
"Starred_Widget_Title" = "Your Starred Articles";
"Starred_Widget_Description" = "A sneak peek at your starred articles.";
"SmartFeedSummary_Widget_Title" = "Your Smart Feed Summary";
"SmartFeedSummary_Widget_Description" = "Your smart feeds, summarized.";
/* Unread Widget */
"Unread_Widget_NoItems" = "There's nothing to read right now.";
/* Today Widget */
"Today_Widget_NoItems" = "There are no recent articles to read.";
/* Starred Widget */
"Starred_Widget_NoItems" = "You've not starred any artices.";
/* Smart Feed Summary Widget */
"Unread" = "Unread";
"Today" = "Today";
"Starred" = "Starred";

View File

@ -32,10 +32,14 @@ struct SmartFeedSummaryWidgetView: View {
@ViewBuilder
var smallWidget: some View {
VStack(alignment: .leading) {
Spacer()
Link(destination: WidgetDeepLink.today.url, label: {
HStack {
todayImage
Text(formattedCount(entry.widgetData.currentTodayCount) + " Today").font(.caption)
VStack(alignment: .leading, spacing: nil, content: {
Text(formattedCount(entry.widgetData.currentTodayCount)).font(Font.system(.caption, design: .rounded)).bold()
Text(L10n.today).bold().font(.caption).textCase(.uppercase)
}).foregroundColor(.white)
Spacer()
}
})
@ -43,7 +47,10 @@ struct SmartFeedSummaryWidgetView: View {
Link(destination: WidgetDeepLink.unread.url, label: {
HStack {
unreadImage
Text(formattedCount(entry.widgetData.currentUnreadCount) + " Unread").font(.caption)
VStack(alignment: .leading, spacing: nil, content: {
Text(formattedCount(entry.widgetData.currentUnreadCount)).font(Font.system(.caption, design: .rounded)).bold()
Text(L10n.unread).bold().font(.caption).textCase(.uppercase)
}).foregroundColor(.white)
Spacer()
}
})
@ -51,16 +58,14 @@ struct SmartFeedSummaryWidgetView: View {
Link(destination: WidgetDeepLink.starred.url, label: {
HStack {
starredImage
Text(formattedCount(entry.widgetData.currentStarredCount) + " Starred").font(.caption)
VStack(alignment: .leading, spacing: nil, content: {
Text(formattedCount(entry.widgetData.currentStarredCount)).font(Font.system(.caption, design: .rounded)).bold()
Text(L10n.starred).bold().font(.caption).textCase(.uppercase)
}).foregroundColor(.white)
Spacer()
}
})
Spacer()
HStack {
Spacer()
Text("Smartfeeds").bold().textCase(.uppercase).font(.caption2)
Spacer()
}
}.padding()
}
@ -75,7 +80,7 @@ struct SmartFeedSummaryWidgetView: View {
Image(systemName: "largecircle.fill.circle")
.resizable()
.frame(width: 20, height: 20, alignment: .center)
.foregroundColor(.accentColor)
.foregroundColor(.white)
}
var nnwImage: some View {
@ -89,14 +94,22 @@ struct SmartFeedSummaryWidgetView: View {
Image(systemName: "star.fill")
.resizable()
.frame(width: 20, height: 20, alignment: .center)
.foregroundColor(.yellow)
.foregroundColor(.white)
}
var todayImage: some View {
Image(systemName: "sun.max.fill")
.resizable()
.frame(width: 20, height: 20, alignment: .center)
.foregroundColor(.orange)
.foregroundColor(.white)
}
}
struct SmartFeedSummaryWidgetView_Previews: PreviewProvider {
static var previews: some View {
SmartFeedSummaryWidgetView(entry: Provider.Entry.init(date: Date(), widgetData: WidgetDataDecoder.sampleData()))
}
}

View File

@ -69,9 +69,7 @@ struct StarredWidgetView : View {
count = count - 3
}
if count < 0 { count = 0 }
let formatString = NSLocalizedString("StarredCount",
comment: "Starred Count Format")
let str = String.localizedStringWithFormat(formatString, UInt(count))
let str = L10n.starredCount(count)
return Text(str)
.font(.caption2)
.bold()
@ -88,9 +86,9 @@ struct StarredWidgetView : View {
var inboxZero: some View {
VStack {
Spacer()
Text("#StarredZero")
.italic()
.font(Font.system(.subheadline, design: .serif))
Image(systemName: "checkmark.circle")
.foregroundColor(.accentColor)
.font(.title)
Spacer()
HStack {
@ -99,7 +97,7 @@ struct StarredWidgetView : View {
.frame(width: 15, height: 15, alignment: .center)
.cornerRadius(4)
Text("You've not starred any artices.")
Text(L10n.starredWidgetNoItems)
.font(.caption2)
.foregroundColor(.gray)
}

View File

@ -69,9 +69,7 @@ struct TodayWidgetView : View {
count = count - 3
}
if count < 0 { count = 0 }
let formatString = NSLocalizedString("TodayCount",
comment: "Today Count Format")
let str = String.localizedStringWithFormat(formatString, UInt(count))
let str = L10n.todayCount(count)
return Text(str)
.font(.caption2)
.bold()
@ -88,9 +86,9 @@ struct TodayWidgetView : View {
var inboxZero: some View {
VStack {
Spacer()
Text("#TodayZero")
.italic()
.font(Font.system(.subheadline, design: .serif))
Image(systemName: "checkmark.circle")
.foregroundColor(.accentColor)
.font(.title)
Spacer()
HStack {
@ -99,7 +97,7 @@ struct TodayWidgetView : View {
.frame(width: 15, height: 15, alignment: .center)
.cornerRadius(4)
Text("There are no recent articles to read.")
Text(L10n.todayWidgetNoItems)
.font(.caption2)
.foregroundColor(.gray)
}

View File

@ -42,7 +42,6 @@ struct UnreadWidgetView : View {
}
.padding()
.widgetURL(WidgetDeepLink.unread.url)
}
}
@ -69,9 +68,7 @@ struct UnreadWidgetView : View {
count = count - 3
}
if count < 0 { count = 0 }
let formatString = NSLocalizedString("UnreadCount",
comment: "Unread Count Format")
let str = String.localizedStringWithFormat(formatString, UInt(count))
let str = L10n.unreadCount(count)
return Text(str)
.font(.caption2)
.bold()
@ -88,9 +85,9 @@ struct UnreadWidgetView : View {
var inboxZero: some View {
VStack {
Spacer()
Text("#UnreadZero")
.italic()
.font(Font.system(.subheadline, design: .serif))
Image(systemName: "checkmark.circle")
.foregroundColor(.accentColor)
.font(.title)
Spacer()
HStack {
@ -99,7 +96,7 @@ struct UnreadWidgetView : View {
.frame(width: 15, height: 15, alignment: .center)
.cornerRadius(4)
Text("There's nothing to read right now.")
Text(L10n.unreadWidgetNoItems)
.font(.caption2)
.foregroundColor(.gray)
}

View File

@ -22,8 +22,8 @@ struct UnreadWidget: Widget {
.background(Color("WidgetBackground"))
})
.configurationDisplayName("Your Unread Articles")
.description("A sneak peak at what's left unread.")
.configurationDisplayName(L10n.unreadWidgetTitle)
.description(L10n.unreadWidgetDescription)
.supportedFamilies([.systemMedium, .systemLarge])
}
@ -40,8 +40,8 @@ struct TodayWidget: Widget {
.background(Color("WidgetBackground"))
})
.configurationDisplayName("Your Today Articles")
.description("A sneak peak at unread recently published articles.")
.configurationDisplayName(L10n.todayWidgetTitle)
.description(L10n.todayWidgetDescription)
.supportedFamilies([.systemMedium, .systemLarge])
}
@ -58,8 +58,8 @@ struct StarredWidget: Widget {
.background(Color("WidgetBackground"))
})
.configurationDisplayName("Your Starred Articles")
.description("A sneak peak at your starred articles.")
.configurationDisplayName(L10n.starredWidgetTitle)
.description(L10n.starredWidgetDescription)
.supportedFamilies([.systemMedium, .systemLarge])
}
@ -73,11 +73,11 @@ struct SmartFeedSummaryWidget: Widget {
return StaticConfiguration(kind: kind, provider: Provider(), content: { entry in
SmartFeedSummaryWidgetView(entry: entry)
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(Color("WidgetBackground"))
.background(Color("AccentColor"))
})
.configurationDisplayName("Your Smart Feed Summary")
.description("A count of your smart feeds.")
.configurationDisplayName(L10n.smartFeedSummaryWidgetTitle)
.description(L10n.smartFeedSummaryWidgetDescription)
.supportedFamilies([.systemSmall])
}