27

Should I check in *.mo translation files into my version control system?

This is a general question. But in particular I'm working on Django projects with git repositories.

muhuk
  • 15,777
  • 9
  • 59
  • 98

3 Answers3

20

The general answer is:
if you do need those files to compile or to deploy (in shot: to "work" with) your component (set of files queried from your VCS), then yes, they should be stored in it (here: in Git).
This is the same for other kind of files (like project files for instance)

.mo files are particular:

django-admin.py compilemessages utility.

This tool runs over all available .po files and creates .mo files, which are binary files optimized for use by gettext

Meaning:

  • you should be able to rebuild them every time you need them (guarantying in effect that they are in synch with their .po couterparts)
  • Git is not so good with binary storage and that would avoid it to store a full version for every changes

So the specific answer is not so clear-cut:

  • if your po files are stables and will not evolve too often, you could definitively store the .mo file
  • you should absolutely store a big README file explaning how to generate mo from po files.
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 1
    "if you do need those files to compile or to deploy" -> this would mean that you should also commit your libraries and all dependencies. And this is a big NONO. – ravenwing Jan 11 '21 at 15:15
  • @ravenwing (almost 12 years later). I agree: the best practice is to *declare* its dependencies rather than include them, and see that third-party tool will fetch those dependencies from an external referential (like `maven/mvn` does from `pom.xml` and Nexus.org) – VonC Jan 11 '21 at 16:14
17

The general answer is to not store generated contents in version control.

You can include it in tarball, if it requires rare tools, or even have separate repository or disconnected branch with only those generated files (like 'html' and 'man' branches in git.git repository).

Jakub Narębski
  • 309,089
  • 65
  • 217
  • 230
0

For asked question Jakub answer is pretty neat.

But one could ask:

So where should I store such files? Should I generate them every time I deploy my code?

And for that... it depends. You could deploy it in tarball (as Jakub sugested) or even better - create pip or system package (RPM for fedora, DEB for debian, etc.).

ravenwing
  • 668
  • 3
  • 20