diff --git a/README.md b/README.md index 80c377b..4f8dae3 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,8 @@ If you are not familiar with [Apple's String Catalog](https://developer.apple.co - It can be constructed manually, all you need is to use a `LocalizedStringKey` in `SwiftUI.View`, not the String itself. - Helper function: `var key: LocalizedStringKey { LocalizedStringKey(rawValue) }` - OR use the [StringCatalogEnum](./StringCatalogEnum) CLI tool in this repo. - - Copy `xcstrings-enum-generate` to your project. + - Download from [releases](./releases), and copy `xcstrings-enum-generate` to your project. + - OR build from source: `cd StringCatalogEnum && make release` - Added something like `xcstrings-enum-generate --xcstrings-path ../Resources/Localizable.xcstrings --output-filename ../Generated/XcodeString.swift` to generate the `enum`. - OR use [SwiftGen](https://github.com/SwiftGen/SwiftGen/issues/1065) - hopefully better support will be added in future. - OR explore how to achieve it with [Sourcery](https://github.com/krzysztofzablocki/Sourcery). diff --git a/StringCatalogEnum/Makefile b/StringCatalogEnum/Makefile index 508fd2a..25e9ff3 100644 --- a/StringCatalogEnum/Makefile +++ b/StringCatalogEnum/Makefile @@ -1,11 +1,15 @@ NAME=xcstrings-enum-generate +# TODO: get from ENV +EXPORT_PROJECT_ROOT=~/prj/business/quible/quible-ios +# TODO: remove other hard-coded paths + all: debug ./$(NAME) \ - --xcstrings-path ~/prj/ios/quible/Quible/Resources/Localizable.xcstrings \ + --xcstrings-path $(EXPORT_PROJECT_ROOT)/Quible/Resources/Localizable.xcstrings \ --enum-name XcodeString \ --enum-typealias X \ - --output-filename ~/prj/ios/quible/Quible/Const/Generated/XcodeString.swift + --output-filename $(EXPORT_PROJECT_ROOT)/Quible/Const/Generated/XcodeString.swift debug: swift build @@ -14,6 +18,7 @@ debug: release: clean swift build -c release cp ./.build/release/$(NAME) . + cp xcstrings-enum-generate $(EXPORT_PROJECT_ROOT)/utility/ test: swift test diff --git a/StringCatalogEnum/Sources/StringCatalogEnum/main.swift b/StringCatalogEnum/Sources/StringCatalogEnum/main.swift index 9677220..aee1c59 100644 --- a/StringCatalogEnum/Sources/StringCatalogEnum/main.swift +++ b/StringCatalogEnum/Sources/StringCatalogEnum/main.swift @@ -126,7 +126,7 @@ struct StringCatalogEnum: ParsableCommand { /// Usage: `SwiftUI.Text(\(enumTypealias).yourStringCatalogKey.key)` var key: LocalizedStringKey { LocalizedStringKey(rawValue) } - // var text: String { String(localized: key) } + var string: String { NSLocalizedString(self.rawValue, comment: "Generated localization from String Catalog key: \\(key)") } // var text: String.LocalizationValue { String.LocalizationValue(rawValue) } }