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

Remove Stale Localizations and Standardize Keys with Underscores #62

Open
1 task done
jdisho opened this issue Jan 25, 2025 · 6 comments
Open
1 task done

Remove Stale Localizations and Standardize Keys with Underscores #62

jdisho opened this issue Jan 25, 2025 · 6 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@jdisho
Copy link
Collaborator

jdisho commented Jan 25, 2025

Problem

  • Leveral localizations are outdated, generating Xcode warnings. Have a look at Localizable.strings
  • Inconsistent localization key naming: some keys lack underscores, making them more error prone when referenced in code.

Solution

  • Remove stale localizations from Localizable.strings to clear Xcode warnings and improve maintainability.
  • Convert existing localization keys to underscore format (e.g., 'USER_SETTINGS' instead of 'User Settings')

Additional context

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct and Contributing Guidelines
@jdisho jdisho added enhancement New feature or request good first issue Good for newcomers labels Jan 25, 2025
@jdisho jdisho self-assigned this Jan 25, 2025
@PSchmiedmayer
Copy link
Member

We have generally moved to use the non uppercase/underscore variants in the Spezi Packages & Apps to make the localization catalogues easier to understand.

I would only aim to use them in exceptions where we have longer strings that continuously change such as prompts in LLMonFHIR or larger multiline text.

@jdisho
Copy link
Collaborator Author

jdisho commented Jan 27, 2025

Interesting, and good to know 👍

I mean, string literals can be error-prone during runtime. The same applies to the uppercase ones with underscores, though in this case, mistakes might be more noticeable.

@jdisho
Copy link
Collaborator Author

jdisho commented Jan 27, 2025

Perhaps it’s worth considering auto-generating these localized strings in code?

@PSchmiedmayer
Copy link
Member

I am not sure if I completely understood the comment, but as far as I see we should use Localization Catalogues and use an automatic extraction of strings anyways. Normally Xcode should warn us if a string is stale and should automatically extract new stings if we use LocalizedStringResource or the relevant SwiftUI initializers.

@jdisho
Copy link
Collaborator Author

jdisho commented Jan 27, 2025

I'm concerned about typos that might go unnoticed. Instead of using string literals as localizable keys, we can auto-generate (with a script or a something like this) these localizations as stored properties within an enum. WDYT?

Going from this:

private var openAISettings: some View {
    Section("SETTINGS_OPENAI") {
        NavigationLink(value: SettingsDestinations.openAIKey) {
            Text("SETTINGS_OPENAI_KEY")
        }
        ...
    }
}

To this:

private var openAISettings: some View {
    Section(.settings.openai) {
        NavigationLink(value: SettingsDestinations.openAIKey) {
            Text(.settings.openaiKey)
        }
        ...
    }
}

@PSchmiedmayer
Copy link
Member

Apple seems to have moved the other direction with their automatic extraction in xcstrings catalogues where the code is driving the localizations and warnings are emitted in the localization catalogue.

Nevertheless, I like the idea of using some more type-safe elements. I think they are working on xcstrings catalogues which would be a requirement before we can use it here (SwiftGen/SwiftGen#1124). We might need to wait for this & then adopt it here and in other apps in the future if it still is a valuable addition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants