git/list[1] front-page[2] threads[3] people[4] search[5] about
wed 2026-10-07 17:01 UTC

Re: [PATCH v3 1/5] l10n: add .gitattributes to simplify location filtering

From
Jiang Xin <worldhello.net@gmail.com>
Date
Mar 16, 2026, 03:21 UTC
Message-ID
<CANYiYbEiDi3-MputSiHi0RZJa+BUe_6viT9HTVz+aJiSwCiw7g@mail.gmail.com>
In-Reply-To
<87220e93-8159-4a92-9c3f-b3f9fa34ba4e@kdbg.org>
On Sun, Mar 15, 2026 at 7:13 PM Johannes Sixt <j6t@kdbg.org> wrote:
Show 38 quoted lines
>
> Am 14.03.26 um 15:38 schrieb Jiang Xin:
> > +# Two filter types are used:
> > +# 1. gettext-no-file-no-location: Strips both filenames and line numbers
> > +#    (e.g., removes "#: main.c:123" entirely)
> > +# 2. gettext-no-location: Preserves filenames but removes line numbers, which
> > +#    requires gettext 0.20 or higher
> > +#    (e.g., "#: main.c:123" becomes "#: main.c")
> > +#
> > +# See `po/README.md` for instructions on setting up the required filter drivers.
> > +
> > +# Do not apply these filters to all `*.po` files via a wildcard. For legacy,
> > +# unmaintained PO files, that would cause discrepancies between the filtered
> > +# blob in the index and the unfiltered file in the working tree.
> > +
> > +# Languages that strip both filenames and line numbers
> > +bg.po        filter=gettext-no-file-no-location
> > +de.po        filter=gettext-no-file-no-location
> > +#es.po       filter=gettext-no-file-no-location
> > +fr.po        filter=gettext-no-file-no-location
> > +#ga.po       filter=gettext-no-file-no-location
> > +#ru.po       filter=gettext-no-file-no-location
> > +sv.po        filter=gettext-no-file-no-location
> > +tr.po        filter=gettext-no-file-no-location
> > +uk.po        filter=gettext-no-file-no-location
> > +vi.po        filter=gettext-no-file-no-location
> > +
> > +# Languages that preserve filenames but strip line numbers
> > +#ca.po       filter=gettext-no-location
> > +id.po        filter=gettext-no-location
> > +zh_CN.po     filter=gettext-no-location
> > +zh_TW.po     filter=gettext-no-location
>
> How settled is the use of these two different filters (and names) in the
> community of translators? I am asking because I'm about to align the
> translation workflow in the Gitk repository with that in the Git
> repository. I need to know which of the two variants of filter names I
> should ask translators to use.

This is a very good question, and it reminds me to revisit the names of these two filters.

When storing PO files in the repository, filtering location comments is necessary, because it reduces the storage growth caused by frequent changes in location comments, and also reduces the “diff churn” in commits caused by location changes.

Either removing the entire location lines (filenames + line numbers) or removing only the line numbers can solve the two problems above. Both also improve blob compression equally well, so there is no difference in terms of repository storage savings. Therefore, maintainers may choose either approach according to their own preference. As long as they do not switch back and forth between the two frequently, there is no impact. Recording the maintainer’s choice in the repository through .gitattributes can avoid l10n teams repeatedly changing their choices.

For the gitk project, there is only one source file, so removing line numbers while keeping the filename brings no benefit; removing the entire location is the best choice. However, for the Git project, some l10n teams keep filenames in PO files while removing line numbers, and this can still be somewhat helpful for locating the correspondence between PO entries and the source code when the PO files have not been regenerated from the POT file.

This also reminds me to rethink the naming of the following filters. Judging from the msgcat --no-location option, “location” refers to filename + line number, so defining the filters like this may be more appropriate:

```shell
git config --global filter.gettext-no-location.clean \
           "msgcat --no-location -"
git config --global filter.gettext-no-line-number.clean \
           "msgcat --add-location=file -"
```

Please let me know your thoughts, and I will make the corresponding changes in reroll v4.

-- Jiang Xin
Previous: Junio C HamanoNext: Jiang Xin
Message 34 of 45 in “[RFC] Introducing AI Agents to Git Localization”
  1. Jiang XinFeb 4, 2026
  2. Peter KreftingFeb 4, 2026
  3. Michal SuchánekFeb 4, 2026
  4. 依云Feb 4, 2026
  5. Jiang XinFeb 5, 2026
  6. brian m. carlsonFeb 5, 2026
  7. Jiang XinFeb 5, 2026
  8. Michal SuchánekFeb 5, 2026
  9. Jiang XinFeb 5, 2026
  10. Jiang XinFeb 5, 2026
  11. 1/2 l10n: add .gitattributes to simplify location filteringJiang Xin, Feb 5, 2026
  12. 2/2 l10n: README: document AI assistant guidelinesJiang Xin, Feb 5, 2026
  13. Michal SuchánekFeb 5, 2026
  14. Junio C HamanoFeb 5, 2026
  15. Junio C HamanoFeb 5, 2026
  16. Jiang XinFeb 6, 2026
  17. 0/5 docs(l10n): AI agent instructions and workflow improvementsJiang Xin, Mar 3, 2026
  18. 1/5 l10n: add .gitattributes to simplify location filteringJiang Xin, Mar 3, 2026
  19. 2/5 docs(l10n): add AGENTS.md with optimized update-pot instructionsJiang Xin, Mar 3, 2026
  20. 3/5 docs(l10n): add AI agent instructions for updating po/XX.po filesJiang Xin, Mar 3, 2026
  21. 4/5 docs(l10n): add AI agent instructions for translating PO filesJiang Xin, Mar 3, 2026
  22. 5/5 docs(l10n): add AI agent instructions to review translationsJiang Xin, Mar 3, 2026
  23. Jiang XinMar 12, 2026
  24. Jiang XinMar 12, 2026
  25. Jiang XinMar 12, 2026
  26. 0/5 docs(l10n): AI agent instructions and workflow improvementsJiang Xin, Mar 14, 2026
  27. 1/5 l10n: add .gitattributes to simplify location filteringJiang Xin, Mar 14, 2026
  28. 2/5 docs(l10n): add AGENTS.md with optimized update-pot instructionsJiang Xin, Mar 14, 2026
  29. 3/5 docs(l10n): add AI agent instructions for updating po/XX.po filesJiang Xin, Mar 14, 2026
  30. 4/5 docs(l10n): add AI agent instructions for translating PO filesJiang Xin, Mar 14, 2026
  31. 5/5 docs(l10n): add AI agent instructions to review translationsJiang Xin, Mar 14, 2026
  32. Johannes SixtMar 15, 2026
  33. Junio C HamanoMar 15, 2026
  34. Jiang XinMar 16, 2026
  35. Jiang XinMar 16, 2026
  36. Johannes SixtMar 16, 2026
  37. 0/5 docs(l10n): AI agent instructions and workflow improvementsJiang Xin, Mar 16, 2026
  38. 1/5 l10n: add .gitattributes to simplify location filteringJiang Xin, Mar 16, 2026
  39. 2/5 docs(l10n): add AGENTS.md with optimized update-pot instructionsJiang Xin, Mar 16, 2026
  40. 3/5 docs(l10n): add AI agent instructions for updating po/XX.po filesJiang Xin, Mar 16, 2026
  41. 4/5 docs(l10n): add AI agent instructions for translating PO filesJiang Xin, Mar 16, 2026
  42. 5/5 docs(l10n): add AI agent instructions to review translationsJiang Xin, Mar 16, 2026
  43. Jiang XinMar 31, 2026
  44. Junio C HamanoMar 31, 2026
  45. Jiang XinMar 31, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.