Skip to content

Conversation

@Dima-1
Copy link
Collaborator

@Dima-1 Dima-1 commented Nov 28, 2025

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a new bcp47Lang field to the wiki_mapping database table to store BCP 47-compliant language codes alongside the original Wikipedia language codes. It also refactors the WikiLangConverter class by moving it from the net.osmand.wiki.commonswiki package to net.osmand.wiki for broader reusability, and applies language normalization to commonswiki descriptions.

Key changes:

  • Added bcp47Lang column to wiki_mapping table with corresponding indexes
  • Moved WikiLangConverter from commonswiki to wiki package for better organization
  • Applied BCP 47 conversion to commonswiki descriptions using WikiLangConverter.normalizeLang()

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
WikiLangConverter.java Moved from net.osmand.wiki.commonswiki to net.osmand.wiki package
WikiLangConverterTest.java Updated import statements to reflect package change
WikiDataHandler.java Added bcp47Lang field to schema, prepares statement, and index; converts wiki language codes to BCP47 during data insertion
CommonsWikimediaPreparation.java Applied WikiLangConverter.normalizeLang() to description metadata to normalize language codes in JSON
WikiDatabasePreparation.java Updated schema and queries to include bcp47Lang field, added index for bcp47Lang lookups
IndexCreatorSettings.java Updated comment to document new bcp47Lang field in schema

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

mappingPrep.setString(2, siteLink.lang());
mappingPrep.setString(3, siteLink.title());
mappingPrep.setString(2, siteLang);
mappingPrep.setString(3, WikiLangConverter.toBcp47FromWiki(siteLang));
Copy link

Copilot AI Nov 28, 2025

Choose a reason for hiding this comment

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

WikiLangConverter.toBcp47FromWiki(siteLang) can return null when the language code cannot be recognized (see method documentation). This null value should be handled explicitly before inserting into the database, either by providing a default value or by skipping the insertion. Consider using a fallback such as the original siteLang or an empty string when the conversion returns null.

Copilot uses AI. Check for mistakes.
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