Skip to content

protonpass/swift-macro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Macro

This package contains macros used in the Pass project.

LocalizedMacro

A freestanding expression macro that converts a static string literal into a localized string, with optional format arguments and bundle support.

Usage

Basic localization

#localized("Hello world")
// expands to:
String(localized: "Hello world")

With format arguments

#localized("Hello %@", "world")
// expands to:
String(format: String(localized: "Hello %@"), "world")

#localized("Version %@ (%d)", "1.0.0", 5)
// expands to:
String(format: String(localized: "Version %@ (%d)"), "1.0.0", 5)

With a custom bundle

#localized("Hello world", bundle: .module)
// expands to:
String(localized: "Hello world", bundle: .module)

#localized("Hello %@", bundle: .module, "world")
// expands to:
String(format: String(localized: "Hello %@", bundle: .module), "world")

Requirements

  • Swift 6.0+
  • macOS 12+, iOS 15+, tvOS 15+, watchOS 8+

Installation

Add this package as a dependency in your Package.swift:

.package(url: "<repo-url>", from: "<version>"),

Then add "Macro" to your target's dependencies.

About

Macro for Swift

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages