I think all that needs is the following observation:

For a fixed rational r,

1) Every rational can be written as sum of another rational and r, uniquely.

2) Every irrational can be written as sum of another irrational and r, uniquely.

f(x+r) = f(x) for all x, where f is the Dirichlet function.