Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why _ isn't removed when sanitizing identifiers #904

Closed
qeude opened this issue Aug 26, 2024 · 1 comment
Closed

Why _ isn't removed when sanitizing identifiers #904

qeude opened this issue Aug 26, 2024 · 1 comment

Comments

@qeude
Copy link

qeude commented Aug 26, 2024

👋 Hi!

I was just wondering why _ was explicitly removed from disallowedCharacters.

I'm asking because it creates weird variables and methods names such as this: key home_page.title would become R.string.localizable.home_pageTitle while it would be more elegant and Swifty to have R.string.localizable.homePageTitle.

It could be great to at least have a configuration (like proposed here) to allow that if we don't want that behavior as a default one.

Thanks!

@mac-cain13
Copy link
Owner

Because it's an allowed character in variable names in Swift. R.swift tries to just take over your original asset name as the variable name used, only characters that aren't allowed to be used are cleaned up. When we need to do cleanup we do some formatting of the variable name to make sure things are still readable/logical.

I can see how homePageTitle reads nicer in code, but I think it having a setting for it would be a bit overkill. I feel the maintenance load such settings bring to the codebase don't outweigh the benefit. I would advise to rename the localisable string key instead if possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants