l10n: add .gitattributes to simplify location filtering

To simplify the location filtering process for l10n contributors when
committing po/XX.po files, add filter attributes for selected PO
files to the repository. This ensures all contributors automatically
get the same filter configuration without manual setup in
.git/info/attributes.

The default filter (gettext-no-location) is applied to all .po files
except:

- Legacy, unmaintained PO files that still contain location comments.
  Leaving the filter off avoids index vs working-tree discrepancies for
  these files. The CI pipeline will report an error when future updates
  touch these legacy files.
- Some PO files use a different filter that strips only line numbers
  from location comments while keeping filenames.

Contributors still need to manually define the filter drivers via
git-config as documented in po/README.md.

Four PO files that use location filtering (po/ca.po, po/es.po, po/ga.po,
po/ru.po) were batch-modified so their on-disk format matches the filter
output (e.g. line wrapping), avoiding index vs working-tree mismatch.

Additionally, po/README.md has been reorganized: the material on
preparing location-less PO files for commit has been moved from
"Updating a XX.po file" to a separate "Preparing a XX.po file for
commit" section. This prevents AI agents from introducing unrelated
operations when updating PO files.

Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
maint
Jiang Xin 2026-02-04 11:39:22 +08:00
parent 256554692d
commit 3a14bcfec8
6 changed files with 161 additions and 119 deletions

35
po/.gitattributes vendored Normal file
View File

@ -0,0 +1,35 @@
# Git Attributes for PO Files
#
# This file configures Git filters to automatically strip location information
# from PO files when committing, producing cleaner diffs and saving repository
# space.
#
# Two filter types are used:
# 1. gettext-no-location: Strips both filenames and line numbers
# (e.g., removes "#: main.c:123" entirely)
# 2. gettext-no-line-number: 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.

# Default: Strip the whole location comments for all .po files
*.po filter=gettext-no-location

# Legacy, unmaintained PO files: filter disabled to avoid index vs
# working-tree mismatch (these files still have location comments).
el.po -filter
is.po -filter
it.po -filter
ko.po -filter
pl.po -filter
pt_PT.po -filter

# These files use gettext-no-line-number (keep filenames, strip line
# numbers). The choice is per l10n team preference. Requires gettext 0.20+.
# The only benefit is locating source files from location comments when
# the .po file is not updated from the POT via make po-update.
ca.po filter=gettext-no-line-number
id.po filter=gettext-no-line-number
zh_CN.po filter=gettext-no-line-number
zh_TW.po filter=gettext-no-line-number

View File

@ -159,38 +159,6 @@ It will:
and these location lines will help translation tools to locate
translation context easily.

Once you are done testing the translation (see below), it's better
to commit a location-less "po/XX.po" file to save repository space
and make a user-friendly patch for review.

To save a location-less "po/XX.po" automatically in repository, you
can:

First define a new attribute for "po/XX.po" by appending the following
line in ".git/info/attributes":

```
/po/XX.po filter=gettext-no-location
```

Then define the driver for the "gettext-no-location" clean filter to
strip out both filenames and locations from the contents as follows:

```shell
git config --global filter.gettext-no-location.clean \
"msgcat --no-location -"
```

For users who have gettext version 0.20 or higher, it is also possible
to define a clean filter to preserve filenames but not locations:

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

You're now ready to ask the l10n coordinator to pull from you.


## Fuzzy translation

@ -229,6 +197,45 @@ git-po-helper check-commits <rev-list-opts>
```


## Preparing a "XX.po" file for commit

Once you are done testing the translation, it's better to commit a
location-less "po/XX.po" file to save repository space and make a
user-friendly patch for review.

To save a location-less "po/XX.po" automatically in the repository,
follow these steps:

First, check which filter is configured for your "po/XX.po" file:

```
git check-attr filter po/XX.po
```

The filter configuration is defined in the "po/.gitattributes" file.

Then define the driver for the filter. Most languages use the
"gettext-no-location" clean filter, which strips out both filenames and line
numbers from location comments. To set this up, run the following command:

```shell
git config --global filter.gettext-no-location.clean \
"msgcat --no-location -"
```

Some PO files use the "gettext-no-line-number" clean filter, which keeps
filenames but strips line numbers. This filter requires gettext 0.20 or
later. The only benefit is being able to locate source files from location
comments when the .po file is not updated from the POT via `make po-update`.

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

You're now ready to ask the l10n coordinator to pull from you.


## Marking strings for translation

(This is done by the core developers).

View File

@ -512,8 +512,8 @@ msgstr ""
#, c-format
msgid "Discard mode change from index and worktree [y,n,q,a,d%s,?]? "
msgstr ""
"Descarta el canvi de mode de l'índex i de l'arbre de treball [y,n,q,a,d"
"%s,?]? "
"Descarta el canvi de mode de l'índex i de l'arbre de treball "
"[y,n,q,a,d%s,?]? "

#: add-patch.c
#, c-format
@ -3879,11 +3879,11 @@ msgstr "HEAD no trobat sota refs/heads!"

#: builtin/branch.c
msgid ""
"branch with --recurse-submodules can only be used if submodule."
"propagateBranches is enabled"
"branch with --recurse-submodules can only be used if "
"submodule.propagateBranches is enabled"
msgstr ""
"la branca amb --recurse-submodules només es pot utilitzar si submodule."
"propagateBranches està habilitat"
"la branca amb --recurse-submodules només es pot utilitzar si "
"submodule.propagateBranches està habilitat"

#: builtin/branch.c
msgid "--recurse-submodules can only be used to create branches"
@ -7983,11 +7983,11 @@ msgstr "el protocol no admet --negotiate-only, se surt"

#: builtin/fetch.c
msgid ""
"--filter can only be used with the remote configured in extensions."
"partialclone"
"--filter can only be used with the remote configured in "
"extensions.partialclone"
msgstr ""
"--filter només es pot utilitzar amb el remot configurat en extensions."
"partialclone"
"--filter només es pot utilitzar amb el remot configurat en "
"extensions.partialclone"

#: builtin/fetch.c
msgid "--atomic can only be used when fetching from one remote"
@ -11436,8 +11436,8 @@ msgid ""
"| -C) <object>] [<object>] [-e]"
msgstr ""
"git notes [--ref <referència-notes>] add [-f] [--allow-empty] [--"
"[no-]separator|--separator=<salt-paràgraf>] [--[no-]stripspace] [-m <msg> | -"
"F <fitxer> | (-c | -C) <objecte>] [<objecte>]"
"[no-]separator|--separator=<salt-paràgraf>] [--[no-]stripspace] [-m <msg> | "
"-F <fitxer> | (-c | -C) <objecte>] [<objecte>]"

#: builtin/notes.c
msgid "git notes [--ref <notes-ref>] copy [-f] <from-object> <to-object>"
@ -11451,8 +11451,8 @@ msgid ""
"| -C) <object>] [<object>] [-e]"
msgstr ""
"git notes [--ref <referència-notes>] append [--allow-empty] [--"
"[no-]separator|--separator=<salt-paràgraf>] [--[no-]stripspace] [-m <msg> | -"
"F <fitxer> | (-c | -C) <objecte>] [<objecte>] [-e]"
"[no-]separator|--separator=<salt-paràgraf>] [--[no-]stripspace] [-m <msg> | "
"-F <fitxer> | (-c | -C) <objecte>] [<objecte>] [-e]"

#: builtin/notes.c
msgid "git notes [--ref <notes-ref>] edit [--allow-empty] [<object>]"
@ -13231,8 +13231,8 @@ msgstr "--empty=ask és obslolet; utilitzeu '--empty=stop' en el seu lloc."
#: builtin/rebase.c
#, c-format
msgid ""
"unrecognized empty type '%s'; valid values are \"drop\", \"keep\", and \"stop"
"\"."
"unrecognized empty type '%s'; valid values are \"drop\", \"keep\", and "
"\"stop\"."
msgstr ""
"tipus buit «%s» no reconegut; els valors vàlids són \"drop\", \"keep\" i "
"\"stop\"."
@ -14440,8 +14440,8 @@ msgid ""
msgstr ""
"Els reempaquetaments incrementals són incompatibles amb els índexs de mapes "
"de bits. Useu\n"
"--no-write-bitmap-index o inhabiliteu el paràmetre de configuració pack."
"writeBitmaps."
"--no-write-bitmap-index o inhabiliteu el paràmetre de configuració "
"pack.writeBitmaps."

#: builtin/repack.c
msgid "could not start pack-objects to repack promisor objects"
@ -19350,11 +19350,11 @@ msgstr ""
#: commit-graph.c
#, c-format
msgid ""
"attempting to write a commit-graph, but 'commitGraph."
"changedPathsVersion' (%d) is not supported"
"attempting to write a commit-graph, but 'commitGraph.changedPathsVersion' "
"(%d) is not supported"
msgstr ""
"s'ha intentat escriure un graf de comissió, però no s'admet 'commitGraph."
"changedPathsVersion' (%d)"
"s'ha intentat escriure un graf de comissió, però no s'admet "
"'commitGraph.changedPathsVersion' (%d)"

#: commit-graph.c
msgid "too many commits to write graph"
@ -22940,8 +22940,8 @@ msgstr "el fitxer de l'índex multipaquet %s és massa petit"
#, c-format
msgid "multi-pack-index signature 0x%08x does not match signature 0x%08x"
msgstr ""
"la signatura de l'índex multipaquet 0x%08x no coincideix amb la signatura 0x"
"%08x"
"la signatura de l'índex multipaquet 0x%08x no coincideix amb la signatura "
"0x%08x"

#: midx.c
#, c-format

View File

@ -391,8 +391,8 @@ msgstr ""
#, c-format, perl-format
msgid "Apply mode change to index and worktree [y,n,q,a,d%s,?]? "
msgstr ""
"¿Aplicar cambio de modo para el índice y el árbol de trabajo [y,n,q,a,"
"d%s,?]? "
"¿Aplicar cambio de modo para el índice y el árbol de trabajo "
"[y,n,q,a,d%s,?]? "

#, c-format, perl-format
msgid "Apply deletion to index and worktree [y,n,q,a,d%s,?]? "
@ -2294,9 +2294,9 @@ msgid ""
"=<term>] [--no-checkout] [--first-parent] [<bad> [<good>...]] [--] "
"[<paths>...]"
msgstr ""
"git bisect--helper --bisect-start [--term-{new,bad}=<término> --term-{old,"
"good}=<término>] [--no-checkout] [--first-parent] [<malo> [<bueno>...]] [--] "
"[<rutas>...]"
"git bisect--helper --bisect-start [--term-{new,bad}=<término> --term-"
"{old,good}=<término>] [--no-checkout] [--first-parent] [<malo> [<bueno>...]] "
"[--] [<rutas>...]"

msgid "git bisect--helper --bisect-state (bad|new) [<rev>]"
msgstr "git bisect--helper --bisect-state (bad|new) [<rev>]"
@ -2983,11 +2983,11 @@ msgid "HEAD not found below refs/heads!"
msgstr "¡HEAD no encontrado dentro de refs/heads!"

msgid ""
"branch with --recurse-submodules can only be used if submodule."
"propagateBranches is enabled"
"branch with --recurse-submodules can only be used if "
"submodule.propagateBranches is enabled"
msgstr ""
"branch con --recurse-submodules solo se puede usar si submodule."
"propagateBranches está habilitado"
"branch con --recurse-submodules solo se puede usar si "
"submodule.propagateBranches está habilitado"

msgid "--recurse-submodules can only be used to create branches"
msgstr "--recurse-submodules solo se puede usar para crear ramas"
@ -5983,11 +5983,11 @@ msgid "protocol does not support --negotiate-only, exiting"
msgstr "el protocolo no soporta --negotiate-only, saliendo"

msgid ""
"--filter can only be used with the remote configured in extensions."
"partialclone"
"--filter can only be used with the remote configured in "
"extensions.partialclone"
msgstr ""
"--filter solo puede ser usado con el remoto configurado en extensions."
"partialclone"
"--filter solo puede ser usado con el remoto configurado en "
"extensions.partialclone"

msgid "--atomic can only be used when fetching from one remote"
msgstr "--atomic solo se puede usar cuando se busca desde un control remoto"
@ -8914,8 +8914,8 @@ msgstr "objeto esperado en el desplazamiento %<PRIuMAX> en el paquete %s"

msgid "disabling bitmap writing, packs are split due to pack.packSizeLimit"
msgstr ""
"deshabilitando escritura bitmap, paquetes son divididos debido a pack."
"packSizeLimit"
"deshabilitando escritura bitmap, paquetes son divididos debido a "
"pack.packSizeLimit"

msgid "Writing objects"
msgstr "Escribiendo objetos"
@ -9489,8 +9489,8 @@ msgstr ""
msgid ""
"\n"
"To avoid automatically configuring upstream branches when their name\n"
"doesn't match the local branch, see option 'simple' of branch."
"autoSetupMerge\n"
"doesn't match the local branch, see option 'simple' of "
"branch.autoSetupMerge\n"
"in 'git help config'.\n"
msgstr ""
"\n"

View File

@ -382,8 +382,8 @@ msgstr "Caitheamh breisiú ó innéacs agus crann oibre [y, n, q, a, d %s,?]? "
#, c-format
msgid "Discard this hunk from index and worktree [y,n,q,a,d%s,?]? "
msgstr ""
"An bhfuil an píosa beag seo le fáil réidh ón innéacs agus ón gcrann oibre [y,"
"n,q,a,d%s,?]? "
"An bhfuil an píosa beag seo le fáil réidh ón innéacs agus ón gcrann oibre "
"[y,n,q,a,d%s,?]? "

msgid ""
"y - discard this hunk from index and worktree\n"
@ -402,8 +402,8 @@ msgstr ""
#, c-format
msgid "Apply mode change to index and worktree [y,n,q,a,d%s,?]? "
msgstr ""
"Cuir athrú mód i bhfeidhm ar an innéacs agus ar an gcrann oibre [y,n,q,a,"
"d%s,?]? "
"Cuir athrú mód i bhfeidhm ar an innéacs agus ar an gcrann oibre "
"[y,n,q,a,d%s,?]? "

#, c-format
msgid "Apply deletion to index and worktree [y,n,q,a,d%s,?]? "
@ -413,14 +413,14 @@ msgstr ""
#, c-format
msgid "Apply addition to index and worktree [y,n,q,a,d%s,?]? "
msgstr ""
"Cuir an breiseán i bhfeidhm ar an innéacs agus ar an gcrann oibre [y,n,q,a,"
"d%s,?]? "
"Cuir an breiseán i bhfeidhm ar an innéacs agus ar an gcrann oibre "
"[y,n,q,a,d%s,?]? "

#, c-format
msgid "Apply this hunk to index and worktree [y,n,q,a,d%s,?]? "
msgstr ""
"Cuir an píosa seo i bhfeidhm ar an innéacs agus ar an gcrann oibre [y,n,q,a,"
"d%s,?]? "
"Cuir an píosa seo i bhfeidhm ar an innéacs agus ar an gcrann oibre "
"[y,n,q,a,d%s,?]? "

msgid ""
"y - apply this hunk to index and worktree\n"
@ -3114,11 +3114,11 @@ msgid "HEAD not found below refs/heads!"
msgstr "Ní fhaightear CEAD thíos na refs/heads!"

msgid ""
"branch with --recurse-submodules can only be used if submodule."
"propagateBranches is enabled"
"branch with --recurse-submodules can only be used if "
"submodule.propagateBranches is enabled"
msgstr ""
"ní féidir brainse le --recurse-submodules a úsáid ach amháin má tá submodule."
"propagateBranches cumasaithe"
"ní féidir brainse le --recurse-submodules a úsáid ach amháin má tá "
"submodule.propagateBranches cumasaithe"

msgid "--recurse-submodules can only be used to create branches"
msgstr "Ní féidir --recurse-submodules a úsáid ach chun brainsí a chruthú"
@ -6034,8 +6034,8 @@ msgid ""
"'strip-if-invalid' is not a valid mode for git fast-export with --signed-"
"commits=<mode>"
msgstr ""
"'strip-if-invalid' ní mód bailí é seo le haghaidh easpórtáil le haghaidh git fast-export le --signed-"
"commits=<mód>"
"'strip-if-invalid' ní mód bailí é seo le haghaidh easpórtáil le haghaidh git "
"fast-export le --signed-commits=<mód>"

#, c-format
msgid ""
@ -6067,8 +6067,8 @@ msgid ""
"'strip-if-invalid' is not a valid mode for git fast-export with --signed-"
"tags=<mode>"
msgstr ""
"'strip-if-invalid' ní mód bailí é seo le haghaidh git fast-export le --signed-"
"tags=<mode>"
"'strip-if-invalid' ní mód bailí é seo le haghaidh git fast-export le --"
"signed-tags=<mode>"

#, c-format
msgid ""
@ -7048,8 +7048,8 @@ msgid "protocol does not support --negotiate-only, exiting"
msgstr "ní thacaíonn an prótacal le --negotiate-only, ag scoir"

msgid ""
"--filter can only be used with the remote configured in extensions."
"partialclone"
"--filter can only be used with the remote configured in "
"extensions.partialclone"
msgstr ""
"--filter Ní féidir ach an scagaire a úsáid ach leis an iargúlta cumraithe in "
"extensions.partialclone"
@ -7584,8 +7584,8 @@ msgstr "Theip ar 'git multi-pack-index repack'"
msgid ""
"skipping incremental-repack task because core.multiPackIndex is disabled"
msgstr ""
"ag scipeáil an tasc athphacála incriminteach mar go bhfuil core."
"multiPackIndex díchumasaithe"
"ag scipeáil an tasc athphacála incriminteach mar go bhfuil "
"core.multiPackIndex díchumasaithe"

msgid "failed to perform geometric repack"
msgstr "theip ar athphacáil gheoiméadrach a dhéanamh"
@ -10097,8 +10097,8 @@ msgstr ""

msgid "disabling bitmap writing, packs are split due to pack.packSizeLimit"
msgstr ""
"scríobh bitmap a dhíchumasú, roinntear pacáistí mar gheall ar pack."
"packSizeLimit"
"scríobh bitmap a dhíchumasú, roinntear pacáistí mar gheall ar "
"pack.packSizeLimit"

msgid "Writing objects"
msgstr "Rudaí a scríobh"
@ -11904,8 +11904,8 @@ msgid ""
msgstr ""
"Tá tagairtí contrártha sa\n"
"tagarmharc sprice nua ag an gcianrialtán atá tú ag iarraidh a athainmniú. Is "
"dóichí gur mar gheall ar iarracht a dhéanamh cianrialtán a neadú ann féin, e."
"g. trí 'tuismitheoir' a athainmniú go 'tuismitheoir/leanbh'\n"
"dóichí gur mar gheall ar iarracht a dhéanamh cianrialtán a neadú ann féin, "
"e.g. trí 'tuismitheoir' a athainmniú go 'tuismitheoir/leanbh'\n"
"nó trí chianrialtán a dhí-neadú, e.g. an bealach eile.\n"
"\n"
"Más amhlaidh atá, is féidir leat é seo a réiteach tríd an\n"
@ -16114,11 +16114,11 @@ msgstr ""

#, c-format
msgid ""
"attempting to write a commit-graph, but 'commitGraph."
"changedPathsVersion' (%d) is not supported"
"attempting to write a commit-graph, but 'commitGraph.changedPathsVersion' "
"(%d) is not supported"
msgstr ""
"ag iarraidh commit-graph a scríobh, ach tá 'commitGraph."
"changedPathsVersion' (%d) ní thacaítear leis"
"ag iarraidh commit-graph a scríobh, ach tá 'commitGraph.changedPathsVersion' "
"(%d) ní thacaítear leis"

msgid "too many commits to write graph"
msgstr "an iomarca gealltanais graf a scríobh"
@ -18266,8 +18266,8 @@ msgid ""
"given pattern contains NULL byte (via -f <file>). This is only supported "
"with -P under PCRE v2"
msgstr ""
"tá byte NULL (trí -f<file>) i bpatrún tugtha. Ní thacaítear leis seo ach le -"
"P faoi PCRE v2"
"tá byte NULL (trí -f<file>) i bpatrún tugtha. Ní thacaítear leis seo ach le "
"-P faoi PCRE v2"

#, c-format
msgid "'%s': unable to read %s"
@ -18433,8 +18433,8 @@ msgid ""
msgstr ""
"Rinneadh neamhaird ar an gcroca '%s' toisc nach bhfuil sé socraithe mar "
"infheidhmithe.\n"
"Is féidir leat an rabhadh seo a dhíchumasú le `git config set advice."
"ignoredHook false `."
"Is féidir leat an rabhadh seo a dhíchumasú le `git config set "
"advice.ignoredHook false `."

msgid "not a git repository"
msgstr "ní stór git é"

View File

@ -369,8 +369,8 @@ msgstr ""
#, c-format
msgid "Discard mode change from index and worktree [y,n,q,a,d%s,?]? "
msgstr ""
"Отменить изменения режима доступа в индексе и рабочем каталоге [y,n,q,a,"
"d%s,?]? "
"Отменить изменения режима доступа в индексе и рабочем каталоге "
"[y,n,q,a,d%s,?]? "

#, c-format
msgid "Discard deletion from index and worktree [y,n,q,a,d%s,?]? "
@ -400,8 +400,8 @@ msgstr ""
#, c-format
msgid "Apply mode change to index and worktree [y,n,q,a,d%s,?]? "
msgstr ""
"Применить изменения режима доступа к индексу и рабочему каталогу [y,n,q,a,"
"d%s,?]? "
"Применить изменения режима доступа к индексу и рабочему каталогу "
"[y,n,q,a,d%s,?]? "

#, c-format
msgid "Apply deletion to index and worktree [y,n,q,a,d%s,?]? "
@ -2966,8 +2966,8 @@ msgid "HEAD not found below refs/heads!"
msgstr "HEAD не найден в refs/heads!"

msgid ""
"branch with --recurse-submodules can only be used if submodule."
"propagateBranches is enabled"
"branch with --recurse-submodules can only be used if "
"submodule.propagateBranches is enabled"
msgstr ""

msgid "--recurse-submodules can only be used to create branches"
@ -3997,8 +3997,8 @@ msgid ""
"clean.requireForce defaults to true and neither -i, -n, nor -f given; "
"refusing to clean"
msgstr ""
"clean.requireForce установлен по умолчанию как true и ни одна из опций -i, -"
"n или -f не указана; отказ очистки"
"clean.requireForce установлен по умолчанию как true и ни одна из опций -i, "
"-n или -f не указана; отказ очистки"

msgid "-x and -X cannot be used together"
msgstr "нельзя использовать одновременно -x и -X"
@ -5890,8 +5890,8 @@ msgid "protocol does not support --negotiate-only, exiting"
msgstr ""

msgid ""
"--filter can only be used with the remote configured in extensions."
"partialclone"
"--filter can only be used with the remote configured in "
"extensions.partialclone"
msgstr ""

msgid "--atomic can only be used when fetching from one remote"
@ -8385,8 +8385,8 @@ msgstr "Каталог %s в индексе и не является подмо

msgid "Please stage your changes to .gitmodules or stash them to proceed"
msgstr ""
"Чтобы продолжить, проиндексируйте или спрячьте ваши изменения в файле ."
"gitmodules"
"Чтобы продолжить, проиндексируйте или спрячьте ваши изменения в "
"файле .gitmodules"

#, c-format
msgid "%.*s is in index"
@ -16134,8 +16134,8 @@ msgid ""
msgstr ""
"Перехватчик «%s» был проигнорирован, так как он не установлен как "
"исполняемый.\n"
"Вы можете отключить это предупреждение с помощью команды «git config advice."
"ignoredHook false»."
"Вы можете отключить это предупреждение с помощью команды «git config "
"advice.ignoredHook false»."

#, c-format
msgid "argument to --packfile must be a valid hash (got '%s')"