mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-09 03:51:20 -03:00
l10n: implement status language builtin
Based on the discussion in https://github.com/fish-shell/fish-shell/pull/11967 Introduce a `status language` builtin, which has subcommands for controlling and inspecting fish's message localization status. The motivation for this is that using only the established environment variables `LANGUAGE`, `LC_ALL`, `LC_MESSAGES`, and `LANG` can cause problems when fish interprets them differently from GNU gettext. In addition, these are not well-suited for users who want to override their normal localization settings only for fish, since fish would propagate the values of these variables to its child processes. Configuration via these variables still works as before, but now there is the `status language set` command, which allows overriding the localization configuration. If `status language set` is used, the language precedence list will be taken from its remaining arguments. Warnings will be shown for invalid arguments. Once this command was used, the localization related environment variables are ignored. To go back to taking the configuration from the environment variables after `status language set` was executed, users can run `status language unset`. Running `status language` without arguments shows information about the current message localization status, allowing users to better understand how their settings are interpreted by fish. The `status language list-available` command shows which languages are available to choose from, which is used for completions. This commit eliminates dependencies from the `gettext_impl` module to code in fish's main crate, allowing for extraction of this module into its own crate in a future commit. Closes #12106
This commit is contained in:
committed by
Johannes Altmanninger
parent
c0b95a0ee1
commit
aa8f5fc77e
@@ -55,6 +55,12 @@ begin
|
||||
set -l LANG C
|
||||
echo (_ file)
|
||||
# CHECK: file
|
||||
set -l LANG POSIX
|
||||
echo (_ file)
|
||||
# CHECK: file
|
||||
set -l LANG C.UTF-8
|
||||
echo (_ file)
|
||||
# CHECK: file
|
||||
end
|
||||
echo (_ file)
|
||||
# CHECK: arquivo
|
||||
@@ -73,6 +79,13 @@ end
|
||||
echo (_ file)
|
||||
# CHECK: arquivo
|
||||
|
||||
# Check that empty vars are ignored
|
||||
begin
|
||||
set -l LC_ALL
|
||||
echo (_ file)
|
||||
# CHECK: arquivo
|
||||
end
|
||||
|
||||
# Check that all relevant locale variables are respected.
|
||||
set --erase LANG
|
||||
set --erase LC_MESSAGES
|
||||
@@ -104,3 +117,71 @@ echo (_ file)
|
||||
set -l LC_ALL de_DE.utf8
|
||||
echo (_ file)
|
||||
# CHECK: Datei
|
||||
|
||||
# Check `status language` builtin
|
||||
set --erase LANG
|
||||
set --erase LC_MESSAGES
|
||||
set --erase LC_ALL
|
||||
set --erase LANGUAGE
|
||||
status language
|
||||
# CHECK: Active languages (default):
|
||||
echo (_ file)
|
||||
# CHECK: file
|
||||
|
||||
set -l LANGUAGE pt_BR de_DE
|
||||
status language
|
||||
# CHECK: Active languages (from variable LANGUAGE): pt_BR de
|
||||
echo (_ file)
|
||||
# CHECK: arquivo
|
||||
|
||||
# We have fr but not fr_FR. For the builtin command, only exact matches are allowed.
|
||||
status language set fr_FR de pt_BR
|
||||
# CHECKERR: No catalogs available for language specifiers: fr_FR
|
||||
status language
|
||||
# CHECK: Active languages (from command `status language set`): de pt_BR
|
||||
echo (_ file)
|
||||
# CHECK: Datei
|
||||
|
||||
set -l LANGUAGE zh_TW
|
||||
status language
|
||||
# CHECK: Active languages (from command `status language set`): de pt_BR
|
||||
echo (_ file)
|
||||
# CHECK: Datei
|
||||
|
||||
set -l LC_MESSAGES C
|
||||
status language
|
||||
# CHECK: Active languages (from command `status language set`): de pt_BR
|
||||
echo (_ file)
|
||||
# CHECK: Datei
|
||||
|
||||
status language unset
|
||||
status language
|
||||
# CHECK: Active languages (from variable LC_MESSAGES):
|
||||
echo (_ file)
|
||||
# CHECK: file
|
||||
|
||||
set --erase LC_MESSAGES
|
||||
status language
|
||||
# CHECK: Active languages (from variable LANGUAGE): zh_TW
|
||||
echo (_ file)
|
||||
# CHECK: 檔案
|
||||
|
||||
set --erase LANGUAGE
|
||||
status language
|
||||
# CHECK: Active languages (default):
|
||||
echo (_ file)
|
||||
# CHECK: file
|
||||
|
||||
# Check `status language set` warnings
|
||||
status language set asdf
|
||||
# CHECKERR: No catalogs available for language specifiers: asdf
|
||||
|
||||
# This will have to be changed if we add catalogs for languages used here.
|
||||
status language set zh_HK it_IT
|
||||
# CHECKERR: No catalogs available for language specifiers: zh_HK it_IT
|
||||
|
||||
status language set de de
|
||||
# CHECKERR: Language specifiers appear repeatedly: de
|
||||
|
||||
status language set \xff quote\"
|
||||
# CHECKERR: No catalogs available for language specifiers: \Xff 'quote"'
|
||||
|
||||
Reference in New Issue
Block a user