mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-04-30 17:41:14 -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
(cherry picked from commit d835c5252a)
84 lines
2.3 KiB
Fish
84 lines
2.3 KiB
Fish
# localization: tier1
|
|
|
|
# This defines a compatibility shim for the `trap` command found in other shells like bash and zsh.
|
|
function trap -d 'Perform an action when the shell receives a signal'
|
|
set -l options h/help l/list-signals p/print
|
|
argparse -n trap $options -- $argv
|
|
or return
|
|
|
|
if set -q _flag_help
|
|
__fish_print_help trap
|
|
return 0
|
|
end
|
|
|
|
set -l mode
|
|
set -l cmd
|
|
set -l sig
|
|
|
|
# Determine the mode based on either an explicit flag or the non-flag args.
|
|
if set -q _flag_print
|
|
set mode print
|
|
else if set -q _flag_list_signals
|
|
set mode list
|
|
else
|
|
switch (count $argv)
|
|
case 0
|
|
set mode print
|
|
case 1
|
|
set mode clear
|
|
case '*'
|
|
if test $argv[1] = -
|
|
set -e argv[1]
|
|
set mode clear
|
|
else
|
|
set mode set
|
|
end
|
|
end
|
|
end
|
|
|
|
switch $mode
|
|
case clear
|
|
for sig in (string upper -- $argv | string replace -r '^SIG' '')
|
|
if test -n "$sig"
|
|
functions -e __trap_handler_$sig
|
|
end
|
|
end
|
|
|
|
case set
|
|
set -l cmd $argv[1]
|
|
set -e argv[1]
|
|
|
|
for sig in (string upper -- $argv | string replace -r '^SIG' '')
|
|
if test -n "$sig"
|
|
set -l sw --on-signal $sig
|
|
if string match -qi exit -- $sig
|
|
set sw --on-event fish_exit
|
|
end
|
|
echo "function __trap_handler_$sig $sw; $cmd; end" | source
|
|
else
|
|
return 1
|
|
end
|
|
end
|
|
|
|
case print
|
|
set -l names
|
|
if set -q argv[1]
|
|
set names $argv
|
|
else
|
|
set names (functions -a | string split ',' | string match "__trap_handler_*" | string replace '__trap_handler_' '')
|
|
end
|
|
|
|
for sig in (string upper -- $names | string replace -r '^SIG' '')
|
|
if test -n "$sig"
|
|
functions __trap_handler_$sig
|
|
echo ""
|
|
else
|
|
return 1
|
|
end
|
|
end
|
|
|
|
case list
|
|
kill -l
|
|
end
|
|
end
|