Skip to content

refactor: convert locale keys to standard AceLocale format#144

Merged
Xerrion merged 1 commit into
masterfrom
refactor/locale-standard-format
Mar 27, 2026
Merged

refactor: convert locale keys to standard AceLocale format#144
Xerrion merged 1 commit into
masterfrom
refactor/locale-standard-format

Conversation

@Xerrion
Copy link
Copy Markdown
Owner

@Xerrion Xerrion commented Mar 27, 2026

Summary

Reverts the UPPER_SNAKE_CASE locale key convention (from bdc09db) back to standard AceLocale format where English text serves as the key (L["English text"] = true). This aligns with the broader addon ecosystem and unblocks PR #143 (zhCN translations).

Changes

  • enUS.lua - 202 SNAKE_CASE keys converted to 201 English text keys (FONT/HEADER_FONT collapsed to single L["Font"])
  • deDE.lua - Matching conversion, all German translations preserved
  • 15 code files - ~175 L["SNAKE_KEY"] references updated to L["English text"]
  • .luacheckrc - Re-enabled linting on locale files with max_line_length = false override

Testing

  • luacheck . passes with 0 warnings, 0 errors
  • Pure string substitution refactor - no logic changes
  • Manual in-game testing recommended: /dt test, /dt config, verify all option labels render correctly

Summary by CodeRabbit

  • Refactor
    • Migrated localization system to use human-readable English strings as keys instead of constant-style identifiers.
    • Updated German locale translations to align with new key system.
    • Updated UI labels and options text throughout the addon interface with improved formatting and clarity.

Reverts the UPPER_SNAKE_CASE locale key convention introduced in bdc09db
back to standard AceLocale format where the English text serves as the key.

- enUS.lua: L["English text"] = true (201 keys, down from 202 due to
  FONT/HEADER_FONT collision collapse)
- deDE.lua: L["English text"] = "German translation"
- All 15 code files updated to reference English text keys
- .luacheckrc: re-enable linting on locale files with max_line_length = false
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 27, 2026

📝 Walkthrough

Walkthrough

This pull request refactors localization key patterns across the DragonToast addon. Constant-style keys (e.g., FORMAT_PLUS_HONOR, YOU, LOADED_MESSAGE) are replaced with literal English strings as keys (e.g., L["+%s Honor"], L["You"], L["Loaded. Type /dt help for commands."]). Changes span core initialization, display logic, event listeners, and options tabs, with corresponding updates to locale files.

Changes

Cohort / File(s) Summary
Localization Configuration
.luacheckrc
Excluded DragonToast/Locales/ from global luacheck, then re-enabled analysis via per-directory config with max_line_length = false.
Locale Definitions
DragonToast/Locales/enUS.lua, DragonToast/Locales/deDE.lua
Migrated 200+ localization entries from constant-style keys (LOADED_MESSAGE, FORMAT_*, YOU, HEADER_*, TOOLTIP_*, etc.) to literal English strings as keys. Redefined all mapping targets using new key patterns.
Core & Event Listeners
DragonToast/Core/Init.lua, DragonToast/Listeners/XPListener.lua, DragonToast/Listeners/HonorListener_Shared.lua, DragonToast/Listeners/ReputationListener_Shared.lua, DragonToast/Listeners/MailListener_Shared.lua, DragonToast/Listeners/MessageBridge.lua
Updated all L[...] lookups to use new literal string keys (e.g., L["+%s XP"] replacing L["FORMAT_PLUS_XP"], L["You"] replacing L["YOU"], L["Mail - %s"] replacing L["FORMAT_MAIL_FROM"]).
Toast Display Logic
DragonToast/Display/ToastFrame.lua, DragonToast/Display/ToastManager.lua, DragonToast/Display/TestToasts.lua
Changed localization key references in toast formatting and labels to match new literal string key patterns (e.g., item level, looter text, duplicate-stack formatting).
Options Interface Tabs
DragonToast_Options/Tabs/GeneralTab.lua, DragonToast_Options/Tabs/AnimationTab.lua, DragonToast_Options/Tabs/AppearanceTab.lua, DragonToast_Options/Tabs/DisplayTab.lua, DragonToast_Options/Tabs/FiltersTab.lua, DragonToast_Options/Tabs/ProfilesTab.lua
Replaced UI widget labels, headers, tooltips, and dropdown entries from localization constants to new English string keys (e.g., L["Animation"] instead of L["TAB_ANIMATION"], L["Enable Animations"] instead of L["ENABLE_ANIMATIONS"]).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~28 minutes

Suggested labels

localization, core, display, listeners, options

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title follows Conventional Commit format with 'refactor' type and clearly describes the main change: converting locale keys to standard AceLocale format.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (3)
DragonToast/Display/ToastFrame.lua (2)

285-289: Stale doc comment references old key.

Line 287 references L["YOU"] but the implementation uses L["You"].

📝 Suggested fix
 -- Shows or hides the looter label on a reward toast according to configuration.
 -- If `db.display.showLooter` is false the looter label is hidden; otherwise the label
--- is set to the localized "YOU" text, colored with `SELF_LOOTER_COLOR`, and shown.
+-- is set to the localized "You" text, colored with `SELF_LOOTER_COLOR`, and shown.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@DragonToast/Display/ToastFrame.lua` around lines 285 - 289, Update the stale
doc comment to match the implementation: change the referenced localization key
from L["YOU"] to L["You"] (or state that the looter label uses L["You"]) and
ensure the comment references the `looter` FontString and
`db.display.showLooter` behavior used in the toast handling function that
shows/hides the looter label.

301-304: Stale doc comment references old key.

Line 303 references L["YOU"] but the implementation now uses L["You"].

📝 Suggested fix
 -- Update the toast's looter label according to configuration and loot data.
 -- Shows or hides the looter text; when the looter is the player displays
--- `L["YOU"]` with the self looter color, otherwise displays the looter's
+-- `L["You"]` with the self looter color, otherwise displays the looter's
 -- name with a muted color.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@DragonToast/Display/ToastFrame.lua` around lines 301 - 304, The doc comment
above the looter label update is stale: it references L["YOU"] but the code now
uses L["You"]; update the comment text to mention L["You"] (or remove the
specific key reference) so the comment matches the implementation in the looter
label logic that uses L["You"] and the self looter color.
DragonToast/Listeners/MailListener_Shared.lua (1)

44-47: Stale doc comment references old locale keys.

The function documentation still references L["AUCTION_WON"], L["AUCTION_SALE"], L["FORMAT_MAIL_FROM"], and L["MAIL"] but the implementation now uses L["Auction Won"], L["Auction Sale"], L["Mail - %s"], and L["Mail"].

📝 Suggested doc update
 -- Shared helpers
 -- Return a localized label describing the source of the mail at the given inbox index.
 -- `@param` index The inbox mail index to inspect.
--- `@return` A localized string: `L["AUCTION_WON"]` for buyer invoices,
---   `L["AUCTION_SALE"]` for seller invoices, a formatted
---   `L["FORMAT_MAIL_FROM"]` with the sender when present, or
---   `L["MAIL"]` as a fallback.
+-- `@return` A localized string: `L["Auction Won"]` for buyer invoices,
+--   `L["Auction Sale"]` for seller invoices, a formatted
+--   `L["Mail - %s"]` with the sender when present, or
+--   `L["Mail"]` as a fallback.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@DragonToast/Listeners/MailListener_Shared.lua` around lines 44 - 47, Update
the stale doc comment that describes the return value to match the current
localization keys used in the implementation: replace references to
L["AUCTION_WON"], L["AUCTION_SALE"], L["FORMAT_MAIL_FROM"], and L["MAIL"] with
L["Auction Won"], L["Auction Sale"], L["Mail - %s"], and L["Mail"] respectively
so the documented return values align with the actual strings used by the
function in MailListener_Shared.lua.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@DragonToast/Display/ToastFrame.lua`:
- Around line 285-289: Update the stale doc comment to match the implementation:
change the referenced localization key from L["YOU"] to L["You"] (or state that
the looter label uses L["You"]) and ensure the comment references the `looter`
FontString and `db.display.showLooter` behavior used in the toast handling
function that shows/hides the looter label.
- Around line 301-304: The doc comment above the looter label update is stale:
it references L["YOU"] but the code now uses L["You"]; update the comment text
to mention L["You"] (or remove the specific key reference) so the comment
matches the implementation in the looter label logic that uses L["You"] and the
self looter color.

In `@DragonToast/Listeners/MailListener_Shared.lua`:
- Around line 44-47: Update the stale doc comment that describes the return
value to match the current localization keys used in the implementation: replace
references to L["AUCTION_WON"], L["AUCTION_SALE"], L["FORMAT_MAIL_FROM"], and
L["MAIL"] with L["Auction Won"], L["Auction Sale"], L["Mail - %s"], and
L["Mail"] respectively so the documented return values align with the actual
strings used by the function in MailListener_Shared.lua.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 0f940c3e-18e8-4299-a14d-1e466618a701

📥 Commits

Reviewing files that changed from the base of the PR and between 999646f and 8031140.

📒 Files selected for processing (18)
  • .luacheckrc
  • DragonToast/Core/Init.lua
  • DragonToast/Display/TestToasts.lua
  • DragonToast/Display/ToastFrame.lua
  • DragonToast/Display/ToastManager.lua
  • DragonToast/Listeners/HonorListener_Shared.lua
  • DragonToast/Listeners/MailListener_Shared.lua
  • DragonToast/Listeners/MessageBridge.lua
  • DragonToast/Listeners/ReputationListener_Shared.lua
  • DragonToast/Listeners/XPListener.lua
  • DragonToast/Locales/deDE.lua
  • DragonToast/Locales/enUS.lua
  • DragonToast_Options/Tabs/AnimationTab.lua
  • DragonToast_Options/Tabs/AppearanceTab.lua
  • DragonToast_Options/Tabs/DisplayTab.lua
  • DragonToast_Options/Tabs/FiltersTab.lua
  • DragonToast_Options/Tabs/GeneralTab.lua
  • DragonToast_Options/Tabs/ProfilesTab.lua

@Xerrion Xerrion merged commit 38270ed into master Mar 27, 2026
3 checks passed
@Xerrion Xerrion deleted the refactor/locale-standard-format branch March 27, 2026 12:14
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.

1 participant