Skip to content

Add support for translations.txt to gtfs-schedule module#37

Merged
sargunv merged 3 commits intomainfrom
copilot/add-translations-txt-support
Oct 24, 2025
Merged

Add support for translations.txt to gtfs-schedule module#37
sargunv merged 3 commits intomainfrom
copilot/add-translations-txt-support

Conversation

Copy link
Contributor

Copilot AI commented Oct 23, 2025

This PR adds support for the translations.txt file to the gtfs-schedule module, following the GTFS Schedule reference specification.

Changes

New Model: Translation

Added a new Translation data class representing records in the translations.txt file with all seven fields from the GTFS specification:

  • Required fields:

    • tableName - Defines the table containing the field to be translated
    • fieldName - Name of the field to be translated
    • language - Language code for the translation (using LanguageCode type)
    • translation - The translated value
  • Optional fields:

    • recordId - Identifies the record containing the field to be translated (first or only field of table's primary key)
    • recordSubId - Additional identifier for tables without unique IDs (second field of table's primary key)
    • fieldValue - Alternative to record identifiers; applies translation when field contains this exact value

Testing

Added comprehensive test coverage in TranslationTest.kt demonstrating all usage patterns:

  • Translation using recordId (e.g., translating agency name)
  • Translation using recordSubId (e.g., translating stop name with composite key)
  • Translation using fieldValue (e.g., translating headsign text)

Documentation

Added translations.txt to the TODO list in ProducerTest.kt for finding sample datasets that publish translation data.

Implementation Notes

The implementation follows all existing patterns in the codebase:

  • Uses @Serializable for CSV parsing with kotlinx-serialization
  • Proper KDoc comments on all fields
  • Consistent with data types used in other models (e.g., LanguageCode from utils)
  • All tests pass across all platforms (JVM, JS, Native, WASM)
  • API dumps automatically updated
  • Zero linting issues

This enables applications using the library to parse and utilize multilingual GTFS datasets that provide translations for customer-facing text.

Original prompt

Please add support for translations.txt to the gtfs-schedule module. Use gtfs.org/documentation/schedule/reference#translationstxt as a reference. Follow all existing patterns, especially the data types used and the tests. Remember to uncomment the relevant lines in producertest when you've added the model, or add it to the list at the bottom if none are available.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

🤖 Generated with [GitHub Copilot](https://copilot.github.com)

Co-Authored-By: GitHub Copilot <noreply@github.com>

Co-authored-by: sargunv <1320357+sargunv@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for translations.txt in gtfs-schedule module Add support for translations.txt to gtfs-schedule module Oct 23, 2025
Copilot AI requested a review from sargunv October 23, 2025 05:58
@sargunv sargunv marked this pull request as ready for review October 23, 2025 22:13
@sargunv sargunv merged commit fe0741b into main Oct 24, 2025
3 checks passed
@sargunv sargunv deleted the copilot/add-translations-txt-support branch October 24, 2025 00:46
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