Files
purchases-ios/Sources/Paywalls/Components/Common/PaywallComponentLocalization.swift
T
Josh Holtz 3d86d7dbbb [Paywalls V2] Remove/replace PAYWALL_COMPONENTS compiler flag and fix OS/platform compile issues (#4727)
* We can't just remove PAYWALL_COMPONENT because we don't support macos and tv and things were failing

* Move PartialComponent outside of PaywallComponent extension

* Fix some lint errors

* Wrong thing

* Undid things i shouldn't have done

* Removed more

* Added comment

* Removed/fix some places for the check thingies

* RevenueCat module compiles on all the things

* RevenueCatUI compiles in all the platforms now

* Make all the things compile again

* Make work for visionOS

* Fix some platform and xcode version issues

* Fix failing spm ios 15 test

* Undo circleci changes

* Replace smooth with easeInOut

* Only run the thing i want

* Attempt to remove circular

* Explicit returns

* Does this pass

* This is it

* Swift 5.9 for this

* All tests again

* Undid public testing processor stuff

* Undo this too

* Swift compiler check out pill style circular

* Fixes from PR review

* Fix compile for mac
2025-01-29 11:53:25 -06:00

45 lines
1.2 KiB
Swift

//
// Copyright RevenueCat Inc. All Rights Reserved.
//
// Licensed under the MIT License (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://opensource.org/licenses/MIT
//
// PaywallComponentLocalization.swift
//
// Created by James Borthwick on 2024-09-03.
// swiftlint:disable missing_docs
import Foundation
extension PaywallComponent.LocalizationDictionary {
public func string(key: String) throws -> String {
guard case let .string(value) = self[key] else {
throw LocalizationValidationError.missingLocalization(
"Missing string localization for property with id: \"\(key)\""
)
}
return value
}
public func image(key: String) throws -> PaywallComponent.ThemeImageUrls {
guard case let .image(value) = self[key] else {
throw LocalizationValidationError.missingLocalization(
"Missing image localization for property with id: \"\(key)\""
)
}
return value
}
}
enum LocalizationValidationError: Error {
case missingLocalization(String)
case invalidUrl(String)
}