Reducing diff noise from Gettext translation files

almirsarajcic

almirsarajcic

Created 6 months ago

If you’ve been using Gettext in your Elixir application, you quickly realized most of the diff in your PRs comes down to .po and .pot files because of all the references to strings in your app. These references need to be updated whenever you move your code around or add new code.

There’s an option to avoid that.

In your mix.exs file add

def project do
  [
    # ...
    gettext: [write_reference_line_numbers: false]
  ]
end

With that change

#: lib/myapp_web/live/hello_live.html.heex:2
#, elixir-autogen, elixir-format

becomes

#: lib/myapp_web/live/hello_live.html.heex
#, elixir-autogen, elixir-format

Recently, we’ve managed to solve this problem here:
https://github.com/3Stones-io/omedis/pull/433/files

There’s also an option to remove these reference comments completely called :write_reference_comments.
https://hexdocs.pm/gettext/Gettext.html#module-mix-tasks-configuration