swiftIdentifier converts all caps to title case
Closed this issue · 3 comments
I'm currently using this through SwiftGen
for generating localized strings.
If I have the strings PDF-title
it returns the identifier PDFTitle
, but if it's passed PDF
it results in the string Pdf
which isn't the correct capitalization for an abbreviation. It seems like there is a difference in behaviour if the passed string has some capitals vs all capitals.
This is by design. The filter has 2 modes: normal and pretty (check the docs). The pretty mode will additionally apply the snakeToCamelCase
filter (check the docs), which is giving the behaviour you're seeing here.
The filter can't know this is an "abbreviation". It just sees a fully uppercase string PDF
, and tries to prettify it. The same would happen with HELLO
. What does happen in the other case, is that the (snakeToCamelCase) filter sees there are multiple "words", and not all of them are fully uppercase. In that case, it'll try to keep the casing for the uppercased elements.
Closing due to inactivity
There's now a new mode valid
for the swift identifier filter, where it will not touch the casing in your string.