Skip to content

Localization scaffolding (String Catalog, no hard-coded UI strings) #8

Description

@nftechie

Context

All UI text is written as English string literals. We'd love translations, but first the app needs to be localizable. This issue covers the scaffolding and moving every user-facing string into a catalog, not the translations themselves.

Where strings live

  • SwiftUI views in Sources/Snapcap/Views/ (including SettingsView.swift, OnboardingView.swift, QuickRecordView.swift and EditorView.swift) and in Sources/Snapcap/Windows/RecordingPanels.swift. Literals passed to Text, Button and Toggle are already LocalizedStringKeys, but strings passed as String aren't. Examples: SliderRow(title:), Banner(title:message:), HUDButton(help:), and EditorModel.showToast(_:) messages.
  • AppKit strings: NSMenuItem titles in Sources/Snapcap/App/AppDelegate.swift (makeMainMenu) and StatusItemController.swift (buildMenu), plus NSAlert text in AppModel.swift, AppDelegate.swift and LibraryView.swift.
  • SnapcapCore labels shown in the UI: CameraShape.label, CameraAspect.label, ExportResolution.label, ExportCodec.label and RecorderError.errorDescription.
  • Sources/Snapcap/Windows/RegionSelector.swift, which draws text with NSString.draw.
  • Resources/Info.plist: NSCameraUsageDescription and NSMicrophoneUsageDescription, which need an InfoPlist.strings.
  • Build: Package.swift has no defaultLocalization or resources yet, and scripts/build-app.sh assembles Snapcap.app by hand.

Proposal

  • Add a String Catalog (Localizable.xcstrings) with English as the development language. SwiftUI and String(localized:) look in Bundle.main by default, so the simplest route is to compile the catalog into en.lproj inside Snapcap.app/Contents/Resources during build-app.sh (for example with xcrun xcstringstool compile). The alternative is SwiftPM resources with bundle: .module everywhere. Pick one and document it.
  • Convert String parameters to LocalizedStringResource or String(localized:). Use plural variations for counts, such as "1 recording" and "2 recordings" in LibraryView.
  • Add CFBundleLocalizations to Info.plist.

Acceptance criteria

  • Every user-facing string (SwiftUI, AppKit menus and alerts, toasts, core labels and errors, permission prompts) is in the catalog.
  • Launching with build/Snapcap.app/Contents/MacOS/Snapcap -NSDoubleLocalizedStrings YES doubles every visible string in the setup window, HUD, countdown, editor, Recordings, Settings, onboarding, popover and menus, which shows nothing is left hard-coded.
  • Plurals are handled correctly.
  • make run and make test still work, and the English UI is unchanged.
  • CONTRIBUTING.md gains a short "Adding a translation" section.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions