mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-04-28 16:01:15 -03:00
The overwhelming majority of localizable messages comes from
completions:
$ ls share/completions/ | wc -l
$ 1048
OTOH functions also contribute a small amount, mostly via their
descriptions (so usually just one per file).
$ ls share/functions/ | wc -l
$ 237
Most of these are private and almost never shown to the user, so it's
not worth bothering translators with them. So:
- Skip private (see the parent commit) and deprecated functions.
- Skip wrapper functions like grep (where the translation seems to
be provided by apropos), and even the English description is not
helpful.
- Assume that most real systems have "seq", "realpath" etc.,
so it's no use providing our own translations for our fallbacks.
- Mark fish's own functions as tier1, and some barely-used functiosn
and completions as tier3, so we can order them that way in
po/*.po. Most translators should only look at tier1 and tier2.
In future we could disable localization for tier3.
See the explanation at the bottom of
tests/checks/message-localization-tier-is-declared.fish
Part of #11833
43 lines
1.4 KiB
Fish
43 lines
1.4 KiB
Fish
# localization: tier1
|
|
function setenv
|
|
# No arguments should cause the current env vars to be displayed.
|
|
if not set -q argv[1]
|
|
env
|
|
return
|
|
end
|
|
|
|
# A single argument should set the named var to nothing.
|
|
if not set -q argv[2]
|
|
set -gx $argv[1] ''
|
|
return
|
|
end
|
|
|
|
# `setenv` accepts only two arguments: the var name and the value. If there are more than two
|
|
# args it is an error. The error message is verbatim from csh.
|
|
if set -q argv[3]
|
|
printf (_ '%s: Too many arguments\n') setenv >&2
|
|
return 1
|
|
end
|
|
|
|
# We have exactly two arguments as required by the csh `setenv` command.
|
|
set -l var $argv[1]
|
|
set -l val $argv[2]
|
|
|
|
# Validate the variable name.
|
|
if not string match -qr '^\w+$' -- $var
|
|
# This message is verbatim from csh. We don't really need to do this but if we don't fish
|
|
# will display a different error message which might confuse someone expecting the csh
|
|
# message.
|
|
echo "setenv: Variable name must contain alphanumeric characters" >&2
|
|
return 1
|
|
end
|
|
|
|
# We need to special case some vars to be compatible with fish. In particular how they are
|
|
# treated as arrays split on colon characters. All other var values are treated literally.
|
|
if contains -- $var PATH CDPATH MANPATH
|
|
set -gx $var (string split -- ':' $val)
|
|
else
|
|
set -gx $var $val
|
|
end
|
|
end
|