Skip to content

refactor: introduce ScribeLanguage Enum to replace raw string comparisons (Part 4/6) (#426) - #672

Merged
andrewtavis merged 2 commits into
scribe-org:mainfrom
prince-0408:refactor/scribe-language-enum-426
Aug 14, 2026
Merged

refactor: introduce ScribeLanguage Enum to replace raw string comparisons (Part 4/6) (#426)#672
andrewtavis merged 2 commits into
scribe-org:mainfrom
prince-0408:refactor/scribe-language-enum-426

Conversation

@prince-0408

@prince-0408 prince-0408 commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

Description

This PR is Part 4 of 6 in modularizing GeneralKeyboardIME for #426.

It introduces a strongly-typed ScribeLanguage enum class to replace error-prone raw string comparisons (e.g., "English", "German") across keyboard services, subclasses, and helper classes.

Detailed Changes Table:

File / Component Changes Applied Detailed Impact
ScribeLanguage.kt [NEW] Created ScribeLanguage enum in be.scri.models with displayName and isoCode properties, plus fromString(), fromDisplayName(), and fromIsoCode() parsing helpers. Provides compile-time type safety for supported languages.
GeneralKeyboardIME.kt Updated primary constructor to accept val scribeLanguage: ScribeLanguage, added overloaded string constructor, provided override val language: String get() = scribeLanguage.displayName for backwards compatibility, and replaced raw string comparisons with scribeLanguage enum checks. Eliminates raw string checks while maintaining 100% backward compatibility.
All 8 Keyboard Subclasses Updated EnglishKeyboardIME, FrenchKeyboardIME, GermanKeyboardIME, ItalianKeyboardIME, PortugueseKeyboardIME, RussianKeyboardIME, SpanishKeyboardIME, and SwedishKeyboardIME constructors to pass ScribeLanguage enum instances (e.g. ScribeLanguage.ENGLISH). Strongly types language instantiation across all IME subclasses.
LanguageMappingConstants.kt Updated getLanguageAlias() to support ScribeLanguage enum directly. Streamlines language alias lookup logic.

Key Benefits:

  • Compile-time Safety: Replaces magic string literals with strongly-typed ScribeLanguage enum values.
  • Maintainability: Centralizes language metadata (displayName, isoCode) in a single source of truth.
  • Zero Behavioral / API Breakage: Retains string accessor language: String so existing callers continue working seamlessly.

Related Issue

Refactors part of #426

@andrewtavis

Copy link
Copy Markdown
Member

quick note, @prince-0408: Could we ask that you not have resolve #ISSUE_NUMBER is your PR messages? You're doing it correctly in the Related Issue section of the comment, but your first sentence - before I edited it - was "This PR is Part 4 of 6 in modularizing GeneralKeyboardIME to resolve #426." That will close the issue if we were to merge :)

@prince-0408

Copy link
Copy Markdown
Collaborator Author

quick note, @prince-0408: Could we ask that you not have resolve #ISSUE_NUMBER is your PR messages? You're doing it correctly in the Related Issue section of the comment, but your first sentence - before I edited it - was "This PR is Part 4 of 6 in modularizing GeneralKeyboardIME to resolve #426." That will close the issue if we were to merge :)

Thanks so much for heads-up and for editing that, @andrewtavis!

Got it! I will make sure to use for #426 or refactoring part of #426 instead of resolve #426 in all future PR descriptions so the main issue stays open.

@andrewtavis

Copy link
Copy Markdown
Member

Would you be able to fix the merge conflicts here, @prince-0408?

@andrewtavis

Copy link
Copy Markdown
Member

I'll get to the review soon after :)

@prince-0408

Copy link
Copy Markdown
Collaborator Author

Would you be able to fix the merge conflicts here, @prince-0408?

Hi @andrewtavis

I have resolved all merge conflicts with upstream/main on PR #672, formatted the code.

Ready for your review whenever you have a moment. Thanks! 😊

@andrewtavis andrewtavis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

praise: All's working well here, @prince-0408! Thanks for this and the many other PRs recently 😊

@andrewtavis
andrewtavis merged commit 7be8e61 into scribe-org:main Aug 14, 2026
6 checks passed
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

Successfully merging this pull request may close these issues.

2 participants