Skip to content

Add UK MPG fuel consumption unit#197

Merged
javedh-dev merged 2 commits intojavedh-dev:devfrom
jake-walker:uk-mileage
Mar 27, 2026
Merged

Add UK MPG fuel consumption unit#197
javedh-dev merged 2 commits intojavedh-dev:devfrom
jake-walker:uk-mileage

Conversation

@jake-walker
Copy link
Copy Markdown
Contributor

Summary

This adds a "UK MPG" option to the mileage selection. As mentioned in #66, in the UK, we have a strange mix of measuring petrol volume in litres, distance as miles and fuel consumption as miles/gallon. With Tracktor currently, if I use litres and miles for my units, I can only choose between mi/L and L/100mi.

Why a dedicated UK option?

In the GitHub issue, someone raised the very valid point of it being strange to have a dedicated "UK" option. According to AI, the UK is the only place with a strange mix of units like this, so I felt like this is the best solution.

The other option was to implement individual units that are independent from what the volume and distance units are set to. I felt like this would have added a lot of complexity to the calculations, especially given the two options already in Tracktor are fine for most users. For context, the following units (and conversions for each) would have needed to be implemented:

List of fuel consumption units
  • mpg (imperial)
  • mpg (US)
  • L/100km
  • mi/L
  • km/L
  • L/km
  • kg/100km
  • kg/km
  • lb/100km and lb/km
  • mi/kg and km/kg

Changes

  • Added a new uk-mpg option for mileageUnitFormat.
  • Added English translations for the new labels.
  • Added client-side validation to ensure the UK MPG option can only be used when the distance unit is miles and volume unit is litres. This is so the server doesn't calculate wrong mileage when using kilometres and/or gallons.
    • On the server side, it will fallback to the default distance-per-fuel format if, for example, you had uk-mpg selected but units don't match.

Screenshots

Valid settings:

image

Invalid settings (distance must be miles):

image

Fuel log with new unit:

image

I do get this approach with the dedicated "UK" option is a little opinionated, but hopefully my reasoning above explains why the other approach was a little more messy. Hopefully that makes sense, but I'm happy to make any changes with suggestions or explain further if needed :)

Copy link
Copy Markdown
Owner

@javedh-dev javedh-dev left a comment

Choose a reason for hiding this comment

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

@jake-walker MPG - stands for miles per gallon. and for this UK has distance as miles and fuel volume in litres. Is this a correct understanding?

@jake-walker
Copy link
Copy Markdown
Contributor Author

@javedh-dev that's correct yes

@javedh-dev javedh-dev merged commit cec57a9 into javedh-dev:dev Mar 27, 2026
1 check passed
@jake-walker jake-walker deleted the uk-mileage branch March 27, 2026 10:57
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