Skip to content

Conversation

@w-dan
Copy link

@w-dan w-dan commented Dec 29, 2025

A little issue I found

I was using the app for a couple days on my homelab, and I loved it! The minor issue I found is that cards could only be searched by their English names, for example, searching for "Ajani Melena Dorada" (Spanish for "Ajani Goldmane") returns no results. This was rather inconvenient because I own some cards in different languages, partly because of CardMarket purchases, or my local stores, which sell mostly translated versions. Manually translating them took long, but I noticed MTGJSON provides foreign card names, and the database already contains a card_foreign_data table, so it could be automated

Why I think this happened

The import script was using the faceName field from MTGJSON’s foreign data, which I found was apparently only populated for multi-face cards. For single-face cards, this field was null, leaving the foreign_name column empty. After some testing, I found out that MTGJSON actually stores all foreign names in a name field, it is quite confusing.

Changes I made

  1. Updated Import Script: Updated the import logic to use the correct foreign name field for all cards.
  2. Database Index: Added an index on the foreign_name column to improve search performance.
  3. Enhanced Search: Modified the search function to query both English and foreign names.

Testing

All multilingual search tests were conducted comparing results to Gatherer's translations

  • Regular cards, enchantments, split cards, adventure cards, and double-faced cards all return correct results in multiple languages.
  • Searches with special characters and accents (e.g., á, é, ñ, ü) now work correctly (not normalized to unicode yet though, so you can't replace "á" by "a", for example).
  • Searches in non-Latin languages like Japanese successfully return the correct cards.

Usage Impact

As an example, users can now perform searches like "Gegenzauber" or "対抗呪文" and obtain the "Counterspell" card as a result.

Benefits

  • Supports international users searching in their local language.
  • Easier collection management for decks which contain cards in different languages.
  • English search functionality remains unchanged.
  • Performance remains fast.

Migration Notes

It is necessary to reimport card data for this fix to take effect. This can be done with the import script or by setting FORCE_REIMPORT=true (default in the project's compose file) and restarting the container.

- Updated import script to use fd.name instead of fd.faceName for foreign card names
- Added index on foreign_name for better search performance
- Modified searchCards to query card_foreign_data table
- Searches now work with Spanish, Japanese, German, French, etc. card names
- Fixed foreign name field
- Added index on foreign name + FTS fallback
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