Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions AsyncImageView/Renderers/CacheRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

import UIKit
import Foundation

import ReactiveSwift

Expand Down Expand Up @@ -67,8 +68,20 @@ extension RenderDataType where Self: DataFileType {
}
}

private let renderDataSubdirectoryLocale = Locale(identifier: "en_US_POSIX")
private let renderDataSubdirectoryFormat = "%.2fx%.2f"

internal func subdirectoryForSize(_ size: CGSize, locale: Locale) -> String {
return String(
format: renderDataSubdirectoryFormat,
locale: locale,
size.width,
size.height
)
}

public func subdirectoryForSize(_ size: CGSize) -> String {
return String(format: "%.2fx%.2f", size.width, size.height)
return subdirectoryForSize(size, locale: renderDataSubdirectoryLocale)
}

private enum CacheRendererError: Error {
Expand All @@ -90,4 +103,3 @@ private extension UIImage {
)
}
}

8 changes: 7 additions & 1 deletion AsyncImageViewTests/CachingSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Nimble
import Foundation
import CoreGraphics

import AsyncImageView
@testable import AsyncImageView

class InMemoryCacheSpec: QuickSpec {
override class func spec() {
Expand Down Expand Up @@ -139,6 +139,12 @@ class RenderDataTypeCacheSubdirectorySpec: QuickSpec {
it("has limited precision") {
expect(subdirectoryForSize(CGSize(width: 15.1245, height: 10.6123))) == "15.12x10.61"
}

it("does not depend on the current locale's decimal separator") {
let locale = Locale(identifier: "fr_FR")
expect(subdirectoryForSize(CGSize(width: 15.1245, height: 10.6123), locale: locale)) == "15,12x10,61"
expect(subdirectoryForSize(CGSize(width: 15.1245, height: 10.6123))) == "15.12x10.61"
}
}
}

Expand Down