fork/fish-shell
git clone https://git.julia.blue/fork/fish-shell
d835c5252
master
1# RUN: fish=%fish %fish %s 2#REQUIRES: command -v msgfmt 3#REQUIRES: %fish -c 'status buildinfo | grep localize-messages' 4 5set -l workspace_root( path resolve --( status dirname) /../../) 6 7set -g ok true 8 9for filein $workspace_root /share/functions/*.fish 10function error --inherit-variable workspace_root --inherit-variable file 11echo "$ ( string replace $workspace_root / '' $file ) :1: error: $argv " 12set -g ok false 13end 14set -l basename( path basename$file ) 15set -l tier 16set -l localize_directives( string match -r'^# localization:.*' < $file ) 17if test ( count $localize_directives ) -gt 1 18error 'multiple ' # localization:' directives' 19continue 20end 21if set -q localize_directives[ 1 ] 22if not set tier( string replace -rf --\ 23'^# localization: (tier[123]|skip(?:\(\S*\))?)$' '$1' \ 24$localize_directives ) 25error 'invalid ' # localization:' directive' 26continue 27end 28end 29if string match -q --'fish_*' $basename 30if set -q tier[ 1 ] && test $tier != 'skip(barely-used)' 31error "unexpected '# localization:' directive in fish_* file, those are currently implicitly tier1" 32end 33continue 34end 35if not set -q tier[ 1 ] 36error "missing '^# localization: (tier[123]|skip)\$' directive" 37continue 38end 39end 40 41if $ok 42return 43end 44 45# If the test fails, output some flight rules. Here's some rationale: 46# 47# Files named 'share/functions/fish_*' are implicitly tier1 unless overridden. 48# 49# Private functions (starting with __fish) are probably not worth bothering translators. 50# The only thing that's translated is usually the function description. 51# Most of those private functions will barely ever be seen by most users. 52# They are shown when: 53# - typing '__fish_' TAB, but only if the function has been loaded before. 54# - running 'type __fish_ps' or 'functions __fish_ps'. 55# The exception is if a function is directly or indirectly called by a default 56# binding; then the user might look it up with 'type __fish_list_current_token'. 57# So we use tier1 (for interesting ones) until these are un-dundered and properly documented. 58# 59# Beyond functions, completions for share/completions/<name>.fish are implicitly 'tier3', 60# unless doc_src/cmds/<name>.rst exists, in which case they are 'tier1'. This can be overridden. 61# For common tools like coreutils, use 'tier2'. 62# 63# Wrapper functions like grep don't need translations because we use 'apropos grep'. 64 65echo " 66- Use '# localization: tier1' for 67- user-visible functions provided by fish such as 'll' 68- functions used in bindings like '__fish_list_current_token' 69- Use '# localization: tier2' for: 70- rarely-used or less important functions provided by fish. 71- completions for common tools like coreutils 72- Use '# localization: tier3' 73- for completions that add for third-party commands, or functions that do the same 74E.g. the ones that contain 'complete foo ... -d some-translatable-string'. 75- Use '# localization: skip(<reason>)' in function files that should not be translated. 76- 'skip(private)' for private functions, unless they are used in bindings 77- 'skip(uses-apropos)' for wrapper functions 78- 'skip(deprecated)' for functions that have been superseded 79- 'skip(barely-used)' for functions that are not documented or probably barely used 80"