Skip to content

Comments

Localize authentication success message#2617

Open
GLWine wants to merge 3 commits intoEDCD:developfrom
GLWine:develop
Open

Localize authentication success message#2617
GLWine wants to merge 3 commits intoEDCD:developfrom
GLWine:develop

Conversation

@GLWine
Copy link
Contributor

@GLWine GLWine commented Feb 12, 2026

Description

This PR replaces hardcoded English strings in the Frontier authentication success dialog with translatable strings using the existing l10n translation system. The authentication message shown after successful CAPI authorization (companion.py line ~670) will now be properly localized based on the user's language preference.

Key changes:

  • Replaced hardcoded title and message strings with tr.tl() calls
  • Implemented a {CR} placeholder for the newline character, allowing translators to position line breaks appropriately for their language
  • Applied PEP8 formatting standards with proper indentation and comment placement

Technical approach:
The translation key contains {CR} as a placeholder, which is replaced with \n after translation using .format(). This ensures:

  1. Translation keys remain clean without escape sequences
  2. Translators can reposition the line break as needed for different languages
  3. The translation system correctly matches keys in .strings files

Example Images

N/A - This is a localization change with no visual modifications to the UI layout or styling.

Type of Change

Translation Update / Localization Enhancement

This enables existing UI elements to be properly localized without altering functionality or behavior.

How Tested

Code verification:

  • ✅ Confirmed tr (translations module) is imported at line 36 of companion.py
  • ✅ Verified the pattern follows existing tr.tl() usage throughout the codebase (error messages, warnings, etc.)
  • ✅ Validated that .format(CR="\n") correctly substitutes the placeholder after translation
  • ✅ Checked PEP8 compliance: proper indentation (4 spaces), line length (<120 chars), comment placement

Fallback behavior:

  • The l10n system automatically falls back to English if translations are missing, ensuring zero breaking changes for existing users
  • Translation keys are structured to work with the existing .strings file format used by EDMC

Pattern consistency:

  • Reviewed similar translation implementations in companion.py (lines with tr.tl("Error: ..."))
  • Verified {CR} placeholder approach is compatible with Python's .format() method
  • Confirmed type hint comment # type: ignore placement matches project conventions

Notes

Translation keys added:

"Authentication Successful"
"Authentication with cAPI Successful.{CR}You may now close the Frontier login tab if it is still open."

For translators:

  • The {CR} placeholder represents a line break and should be preserved in translations
  • Translators can reposition {CR} as appropriate for their language's sentence structure
  • Example Italian translation:
    "Authentication with cAPI Successful.{CR}You may now close the Frontier login tab if it is still open." = "Autenticazione con cAPI riuscita.{CR}Ora puoi chiudere la scheda di login Frontier se è ancora aperta.";
    

Compatibility:

  • ✅ Backward compatible: Users without language-specific translations will see the original English text
  • ✅ No dependencies added: Uses existing l10n infrastructure
  • ✅ No logic changes: Only affects display strings, not authentication flow

Future work:
Translation maintainers will need to add corresponding entries to language-specific .strings files (e.g., it.strings, de.strings, fr.strings, etc.) to provide localized versions of these messages.


The change was committed to the correct source branch (GLWine\develop), and the pull request was opened against the correct target branch (EDCD\develop). The old PR #2614 has been closed in favor of this one.


Attention: @Rixxan

Updated message box title and content to use translation functions.
@GLWine GLWine marked this pull request as ready for review February 12, 2026 21:02
Copy link
Contributor

@Rixxan Rixxan left a comment

Choose a reason for hiding this comment

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

Overall, I like the idea. However, there's a few steps that need to be taken before I can send this in.

companion.py Outdated
message="Authentication with cAPI Successful.\n"
"You may now close the Frontier login tab if it is still open.")
tk.messagebox.showinfo( # type: ignore
title=tr.tl("Authentication Successful"),
Copy link
Contributor

Choose a reason for hiding this comment

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

These need LANG comments for the AST and to be added to en.template.

Similar examples can be found in the code, such as:

label=tr.tl("Open in {URL}").format(URL=url), # LANG: Open Element In Selected Provider

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you think it will be okay now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Rixxan up

Add two new localization entries to L10n/en.template for companion.py: a messagebox title "Authentication Successful" and a cAPI success body "Authentication with cAPI Successful.{CR}You may now close the Frontier login tab if it is still open." to display after successful authentication.
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