Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Validate field presence and key integrity for translations.txt #968

Merged
merged 4 commits into from
Sep 3, 2021

Conversation

aababilov
Copy link
Collaborator

@aababilov aababilov commented Aug 24, 2021

Checks that fields and values provided in translations are correct and checks that a
translation references existing entity.

This validator gracefully handles legacy Google translations format. If translations.txt
does not follow the new format, then no validations are performed.

Copy link
Contributor

@lionel-nj lionel-nj left a comment

Choose a reason for hiding this comment

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

Thanks @aababilov for this contribution! I like how this adapts to unofficial tables! You will find a few questions in-line.
Could you also add documentation for the new classes/methods as well as unit test for TranslationValidator please? :)

@isabelle-dr
Copy link
Contributor

Thank you for this contribution @aababilov!


/**
* Validates that translations are provided in accordance with GTFS Specification. Supports two
* types of specifications * unofficial Google extension * official GTFS specification Checks that
Copy link
Member

Choose a reason for hiding this comment

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

unofficial Google extension

Is this extension documented somewhere that you could link to from here?

Also, it looks like the auto-formatting destroyed the bulleted list here - I'd suggest re-formatting in a way that keeps the list and complies with the Google Java Format.

Copy link
Member

Choose a reason for hiding this comment

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

@lionel-nj As you work on profiles, perhaps pulling checks for the unofficial Google extension into a profile would be a good use case?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sorry for bad formatting!

Google translation.txt extension is hard to support in open-source since the "Google" translations.txt has different columns:

  • trans_id
  • lang (not language!)
  • translation

Fields table_name, field_name and language are required in GTFS standard but not used in Google extension. So, it is not enough to add a plugin for validation of Google translations - instead, the schema has to be patched and officially required fields become optional in order to support Google translations.

Copy link
Contributor

Choose a reason for hiding this comment

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

@barbeau since this extension requires modification of schema we might consider a more simple use case for the first implementation of profiles custom validators.

Copy link
Member

Choose a reason for hiding this comment

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

@aababilov I see. So is the comment wrong, the Google extension isn't supported here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, that was a bad copypaste from the internal code. Fixed.

@aababilov
Copy link
Collaborator Author

Thank you for this contribution @aababilov!

My pleasure!

@aababilov
Copy link
Collaborator Author

I am splitting this change into pieces. #979

@isabelle-dr isabelle-dr linked an issue Aug 31, 2021 that may be closed by this pull request
@isabelle-dr isabelle-dr added this to the v3.0.0 milestone Aug 31, 2021
@aababilov aababilov force-pushed the translations-validator branch 3 times, most recently from 4258282 to 2fb6a03 Compare September 2, 2021 15:29
@aababilov aababilov changed the title feat: Validate key integrity for translations.txt feat: Validate field presence and key integrity for translations.txt Sep 2, 2021
@aababilov
Copy link
Collaborator Author

Please take another look.

Copy link
Collaborator

@asvechnikov2 asvechnikov2 left a comment

Choose a reason for hiding this comment

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

Thank you for exporting this, looks much better with GtfsFeedContainer! LGTM!

@isabelle-dr isabelle-dr self-requested a review September 3, 2021 02:32
@aababilov
Copy link
Collaborator Author

Thanks for review!

@aababilov aababilov merged commit 07c631a into MobilityData:master Sep 3, 2021
@isabelle-dr isabelle-dr mentioned this pull request Oct 28, 2021
4 tasks
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.

Check conditional requirement on translations.txt fields
5 participants