Skip to content

Commit

Permalink
Merge localizations into master
Browse files Browse the repository at this point in the history
  • Loading branch information
richardtop committed Jan 12, 2020
2 parents 939fc0c + c56a995 commit e424985
Show file tree
Hide file tree
Showing 15 changed files with 147 additions and 17 deletions.
3 changes: 2 additions & 1 deletion CalendarKit.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = "CalendarKit"
s.summary = "Fully customizable calendar for iOS"
s.version = "0.11.1"
s.version = "0.11.2"
s.homepage = "https://github.com/richardtop/CalendarKit"
s.license = 'MIT'
s.author = { "Richard Topchii" => "[email protected]" }
Expand All @@ -11,6 +11,7 @@ Pod::Spec.new do |s|
s.swift_version = '5.1'
s.requires_arc = true
s.source_files = 'Source/**/*'
s.ios.resource_bundle = { 'CalendarKit' => ['Localizations/*.lproj'] }
s.dependency 'DateToolsSwift'
s.dependency 'Neon'
end
12 changes: 6 additions & 6 deletions CalendarKitDemo/CalendarApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
75776AF58133F6BBDDCF1CE7 /* Pods_CalendarApp.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A223D8E39EB8C7A25F4E823A /* Pods_CalendarApp.framework */; };
7924834B23CB7B57003E3D27 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7924834923CB7B57003E3D27 /* Main.storyboard */; };
7924834D23CB7B58003E3D27 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 7924834C23CB7B58003E3D27 /* Assets.xcassets */; };
7924835023CB7B58003E3D27 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7924834E23CB7B58003E3D27 /* LaunchScreen.storyboard */; };
Expand All @@ -16,7 +17,6 @@
7924836C23CB7BFE003E3D27 /* CustomCalendarExampleController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7924836623CB7BFE003E3D27 /* CustomCalendarExampleController.swift */; };
7924836D23CB7BFE003E3D27 /* ExampleController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7924836723CB7BFE003E3D27 /* ExampleController.swift */; };
7924836E23CB7BFE003E3D27 /* ExampleNotificationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7924836823CB7BFE003E3D27 /* ExampleNotificationController.swift */; };
DFA7CAE4CAC5C89EE8AF6696 /* Pods_CalendarApp.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A05C820D1C9D1BE2E012F4DF /* Pods_CalendarApp.framework */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -32,7 +32,7 @@
7924836623CB7BFE003E3D27 /* CustomCalendarExampleController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomCalendarExampleController.swift; sourceTree = "<group>"; };
7924836723CB7BFE003E3D27 /* ExampleController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExampleController.swift; sourceTree = "<group>"; };
7924836823CB7BFE003E3D27 /* ExampleNotificationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExampleNotificationController.swift; sourceTree = "<group>"; };
A05C820D1C9D1BE2E012F4DF /* Pods_CalendarApp.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_CalendarApp.framework; sourceTree = BUILT_PRODUCTS_DIR; };
A223D8E39EB8C7A25F4E823A /* Pods_CalendarApp.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_CalendarApp.framework; sourceTree = BUILT_PRODUCTS_DIR; };
FEBA81B9D67F9FBBA5381D09 /* Pods-CalendarApp.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CalendarApp.debug.xcconfig"; path = "Target Support Files/Pods-CalendarApp/Pods-CalendarApp.debug.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand All @@ -41,7 +41,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
DFA7CAE4CAC5C89EE8AF6696 /* Pods_CalendarApp.framework in Frameworks */,
75776AF58133F6BBDDCF1CE7 /* Pods_CalendarApp.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -96,7 +96,7 @@
D2B9A4777F5DB09BCFA26C1E /* Frameworks */ = {
isa = PBXGroup;
children = (
A05C820D1C9D1BE2E012F4DF /* Pods_CalendarApp.framework */,
A223D8E39EB8C7A25F4E823A /* Pods_CalendarApp.framework */,
);
name = Frameworks;
sourceTree = "<group>";
Expand All @@ -112,7 +112,7 @@
7924833C23CB7B57003E3D27 /* Sources */,
7924833D23CB7B57003E3D27 /* Frameworks */,
7924833E23CB7B57003E3D27 /* Resources */,
7016FF6EA52C87C95AE483A7 /* [CP] Embed Pods Frameworks */,
5A00DDEECC79568B66DC9F20 /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
Expand Down Expand Up @@ -193,7 +193,7 @@
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
7016FF6EA52C87C95AE483A7 /* [CP] Embed Pods Frameworks */ = {
5A00DDEECC79568B66DC9F20 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1130"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7924833F23CB7B57003E3D27"
BuildableName = "CalendarApp.app"
BlueprintName = "CalendarApp"
ReferencedContainer = "container:CalendarApp.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = "en"
region = "US"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES"
showNonLocalizedStrings = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7924833F23CB7B57003E3D27"
BuildableName = "CalendarApp.app"
BlueprintName = "CalendarApp"
ReferencedContainer = "container:CalendarApp.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7924833F23CB7B57003E3D27"
BuildableName = "CalendarApp.app"
BlueprintName = "CalendarApp"
ReferencedContainer = "container:CalendarApp.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
2 changes: 2 additions & 0 deletions Localizations/da.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"all-day" = "heldag";
"12:00" = "Middag";
2 changes: 2 additions & 0 deletions Localizations/de.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"all-day" = "Ganztägig";
"12:00" = "Mittag";
2 changes: 2 additions & 0 deletions Localizations/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"all-day" = "all-day";
"12:00" = "Noon";
2 changes: 2 additions & 0 deletions Localizations/es.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"all-day" = "todo el día";
"12:00" = "12:00;
2 changes: 2 additions & 0 deletions Localizations/fr.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"all-day" = "Jour entier";
"12:00" = "Midi";
2 changes: 2 additions & 0 deletions Localizations/nl.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"all-day" = "hele dag";
"12:00" = "12 PM";
2 changes: 2 additions & 0 deletions Localizations/ru.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"all-day" = "весь день";
"12:00" = "12:00";
2 changes: 2 additions & 0 deletions Localizations/sv.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"all-day" = "heldag";
"12:00" = "12:00";
19 changes: 19 additions & 0 deletions Source/Localization.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import Foundation

extension Bundle {
static var localizationBundle: Bundle? {
let bundle = Bundle(for: DayViewController.self)
guard let bundlePath = bundle.path(forResource: "CalendarKit",
ofType: "bundle"),
let targetBundle = Bundle(path: bundlePath) else {
return nil
}
return targetBundle
}
}

func localizedString(_ key: String) -> String {
return Bundle.localizationBundle?.localizedString(forKey: key,
value: nil,
table: nil) ?? key
}
3 changes: 1 addition & 2 deletions Source/Timeline/AllDayView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ public class AllDayView: UIView {

private lazy var textLabel: UILabel = {
let label = UILabel(frame: CGRect(x: 8.0, y: 4.0, width: allDayLabelWidth, height: 24.0))
label.text = "all-day"
label.text = localizedString("all-day")
label.autoresizingMask = [.flexibleWidth]

return label
}()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import Foundation

enum Generator {
static func timeStrings24H() -> [String] {
struct TimeStringsFactory {
private let calendar: Calendar

init(_ calendar: Calendar = Calendar.autoupdatingCurrent) {
self.calendar = calendar
}

func make24hStrings() -> [String] {
var numbers = [String]()
numbers.append("00:00")

Expand All @@ -15,7 +21,7 @@ enum Generator {
return numbers
}

static func timeStrings12H() -> [String] {
func make12hStrings() -> [String] {
var numbers = [String]()
numbers.append("12")

Expand All @@ -24,9 +30,10 @@ enum Generator {
numbers.append(string)
}

var am = numbers.map { $0 + " AM" }
var pm = numbers.map { $0 + " PM" }
am.append("Noon")
var am = numbers.map { $0 + " " + calendar.amSymbol}
var pm = numbers.map { $0 + " " + calendar.pmSymbol}

am.append(localizedString("12:00"))
pm.removeFirst()
pm.append(am.first!)
return am + pm
Expand Down
11 changes: 9 additions & 2 deletions Source/Timeline/TimelineView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ public class TimelineView: UIView {
didSet {
snappingBehavior = snappingBehaviorType.init(calendar)
nowLine.calendar = calendar
regenerateTimeStrings()
setNeedsLayout()
}
}
Expand All @@ -128,8 +129,14 @@ public class TimelineView: UIView {
return is24hClock ? _24hTimes : _12hTimes
}

fileprivate lazy var _12hTimes: [String] = Generator.timeStrings12H()
fileprivate lazy var _24hTimes: [String] = Generator.timeStrings24H()
private lazy var _12hTimes: [String] = TimeStringsFactory(calendar).make12hStrings()
private lazy var _24hTimes: [String] = TimeStringsFactory(calendar).make24hStrings()

private func regenerateTimeStrings() {
let factory = TimeStringsFactory(calendar)
_12hTimes = factory.make12hStrings()
_24hTimes = factory.make24hStrings()
}

public lazy var longPressGestureRecognizer = UILongPressGestureRecognizer(target: self,
action: #selector(longPress(_:)))
Expand Down

0 comments on commit e424985

Please sign in to comment.