Swiftpack.co - teufelaudio/FoundationExtensions as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by teufelaudio.
teufelaudio/FoundationExtensions v0.1.19
Useful extensions for Swift Foundation library
⭐️ 4
🕓 1 week ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/teufelaudio/FoundationExtensions.git", from: "v0.1.19")

FoundationExtensions

A description of this package.

GitHub

link
Stars: 4
Last commit: 1 week ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

v0.1.19
1 week ago

Add L10n

Gives type-safe localization in 3 easy steps ✨.

Step 1: Define your strings in an extension of L10n (i.e. in App/Sources/L10n/L10n.swift).

extension L10n {
    public enum HomeScreen: Localizable {
        // sourcery: comment=Navigation Bar Title on Home screen
        case navigationBarTitle

        // sourcery: comment=Some value with parameters
        case value(/* sourcery: format=%d */ count: Int, another: String, /* sourcery: format=%.2f */ exacly: Float)

        // sourcery: comment=Title for submit button on Home screen
        case submitButton
    }
}

Step 2: Use sourcery + genstrings + MergeL10n to generate Localizable.strings. See .sourcery-l10n-example.yml and adjust the paths to your project. The sourcery template can be found in Tools/Sourcery/Templates/Sources/Localizable.stencil.

# Makefile excerpt
App/Sources/Generated/Localizable.generated.swift: App/Sources/L10n/L10n.swift
    sourcery --config App/Sources/.sourcery-l10n.yml
    genstrings -o App/Sources/Resources/zz.lproj -s LS App/Sources/Generated/Localizable.generated.swift
    Tools/MergeL10n pseudo-to-languages --base-paths="App/Sources/Resources"

Step 3: Refer to the strings using the .localizedString method.

public struct Example: View {
    public var body: some View {
        Text(L10n.HomeScreen.navigationBarTitle.localizedString)
    }
}

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics