Repository navigation
Use mul as multilingual text fallback - #71
Merged
Merged
Conversation
Prefer Wikidata's mul default value when no English label or English locale variant is available. Preserve the existing arbitrary fallback for multilingual mappings without either value, and cover the selection order with regression tests. Closes #70 Assisted-by: Codex:gpt-5.6-sol
There was a problem hiding this comment.
Pull request overview
This PR fixes MultilingualText.__str__() to use Wikidata’s mul language code as a stable fallback when no English label is available, eliminating prior dependence on JSON/dict insertion order.
Changes:
- Updated
MultilingualText.__str__()to preferen, then English variants (en_…/en-…), thenmul, and only then fall back to the final mapping value. - Added regression tests to pin the precedence rules and ensure results are independent of insertion order around
mul. - Documented the behavior change in the changelog for the upcoming release.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| wikidata/multilingual.py | Implements mul fallback after English/English-variant checks, preserving legacy last-entry fallback otherwise. |
| tests/multilingual_test.py | Adds tests covering en vs variants vs mul precedence and insertion-order independence. |
| docs/changes.rst | Records the behavior change for release notes, referencing issue #70. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Wikidata uses the
mullanguage code for a default label that applies when a language-specific label is absent.MultilingualText.__str__()previously skipped that default when no English label existed and returned the final entry in the mapping instead. This made the result depend on JSON insertion order. For Q187560, for example,mulcontainsScheme, but the later Kurdish label was rendered.The lookup in wikidata/multilingual.py keeps the existing English-first behavior. It checks an exact
envalue, accepts both Babel-era underscore variants such asen_USand Wikidata-style hyphen variants such asen-gb, and then consultsmul. The previous last-entry fallback remains for mappings without any of those values. This gives the Wikidata default a defined place without changing the result when an English value is available.The regression cases in tests/multilingual_test.py put
mulbefore and after an unrelated label to make the result independent of insertion order. Separate cases pin each precedence boundary and retain the old fallback for mappings that have neither an English value normul.Closes #70.