liamnichols / xcstrings-tool

A plugin to generate Swift constants for your Strings Catalogs.
https://swiftpackageindex.com/liamnichols/xcstrings-tool/documentation/documentation
MIT License
169 stars 26 forks source link

Only generating constants/definitions and not localization helpers #104

Open liamnichols opened 1 month ago

liamnichols commented 1 month ago

The code generated by xcstrings-tool can be broken down into two categories:

  1. Definitions
  2. Helpers

Definitions

https://github.com/liamnichols/xcstrings-tool/blob/ca65df3b231944d6041a55d446bd6b78d1413575/Tests/XCStringsToolTests/__Snapshots__/GenerateTests/testGenerate.Localizable.swift#L50-L124

Helpers

https://github.com/liamnichols/xcstrings-tool/blob/ca65df3b231944d6041a55d446bd6b78d1413575/Tests/XCStringsToolTests/__Snapshots__/GenerateTests/testGenerate.Localizable.swift#L211-L219

https://github.com/liamnichols/xcstrings-tool/blob/ca65df3b231944d6041a55d446bd6b78d1413575/Tests/XCStringsToolTests/__Snapshots__/GenerateTests/testGenerate.Localizable.swift#L222-L233

https://github.com/liamnichols/xcstrings-tool/blob/ca65df3b231944d6041a55d446bd6b78d1413575/Tests/XCStringsToolTests/__Snapshots__/GenerateTests/testGenerate.Localizable.swift#L336-L411


While the helpers are helpful in getting you up and running in 95% of use cases, they are not always exactly what everybody wants. In my use case, I still have a UIKit application that does custom localizations, so the generated String.init(localizable:locale:) method is not actually useful to me because I need to resolve the language in a different way.

It would be good in my project if I could just generate the definitions, and then write my own String.init(localizable:) method that works exactly how I need it instead of using the generated one.


While I'm aware that I could still do this by just creating a method with a different name, the concern that I have with leaving the default String.init(localizable:) method is that it makes things confusing and risks potentially using the wrong method. It would be better to eliminate it entirely.

liamnichols commented 1 month ago

Similar to modifying the Access Level, this can probably be achieved using a --exclude-helpers flag, which can also be read from build settings.