mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-30 19:41:15 -03:00
Add message localization tests
These tests require building with the `localize-messages` feature. If certain translations are updated, this test might fail, either because a message was changed in the source, or because a translation of a message was changed, or because a translation was added in a language which previously did not have a translation for a particular message, and we rely on that in the test. If any of these happen, the tests need to be updated accordingly. Closes #11726
This commit is contained in:
committed by
Johannes Altmanninger
parent
bee1e122f9
commit
397969ddcc
@@ -58,7 +58,7 @@ freebsd_task:
|
|||||||
freebsd_instance:
|
freebsd_instance:
|
||||||
image: freebsd-14-3-release-amd64-ufs
|
image: freebsd-14-3-release-amd64-ufs
|
||||||
tests_script:
|
tests_script:
|
||||||
- pkg install -y cmake-core devel/pcre2 devel/ninja lang/rust misc/py-pexpect git-lite
|
- pkg install -y cmake-core devel/pcre2 devel/ninja gettext git-lite lang/rust misc/py-pexpect
|
||||||
# libclang.so is a required build dependency for rust-c++ ffi bridge
|
# libclang.so is a required build dependency for rust-c++ ffi bridge
|
||||||
- pkg install -y llvm
|
- pkg install -y llvm
|
||||||
# BSDs have the following behavior: root may open or access files even if
|
# BSDs have the following behavior: root may open or access files even if
|
||||||
|
|||||||
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
@@ -166,7 +166,7 @@ jobs:
|
|||||||
- name: cmake
|
- name: cmake
|
||||||
run: |
|
run: |
|
||||||
mkdir build && cd build
|
mkdir build && cd build
|
||||||
cmake -DWITH_GETTEXT=NO -DCMAKE_BUILD_TYPE=Debug ..
|
cmake -DCMAKE_BUILD_TYPE=Debug ..
|
||||||
- name: make
|
- name: make
|
||||||
run: |
|
run: |
|
||||||
make -C build VERBOSE=1
|
make -C build VERBOSE=1
|
||||||
|
|||||||
106
tests/checks/message-localization.fish
Normal file
106
tests/checks/message-localization.fish
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
# RUN: fish=%fish %fish %s
|
||||||
|
#REQUIRES: command -v msgfmt
|
||||||
|
#REQUIRES: %fish -c 'status buildinfo | grep localize-messages'
|
||||||
|
|
||||||
|
set -l custom_gettext_var asdf
|
||||||
|
|
||||||
|
set -lx LANG de_DE.utf8
|
||||||
|
|
||||||
|
# Check if translations work.
|
||||||
|
|
||||||
|
$fish --not-a-real-flag
|
||||||
|
# CHECKERR: fish: --not-a-real-flag: unbekannte Option
|
||||||
|
|
||||||
|
set --show custom_gettext_var
|
||||||
|
# CHECK: $custom_gettext_var: Gesetzt in local Gültigkeit als nicht exportiert, mit 1 Elementen
|
||||||
|
# CHECK: $custom_gettext_var[1]: |asdf|
|
||||||
|
|
||||||
|
set -lx LANG en_US.utf8
|
||||||
|
|
||||||
|
# Changing the locale should result in different localizations.
|
||||||
|
|
||||||
|
$fish --not-a-real-flag
|
||||||
|
# CHECKERR: fish: --not-a-real-flag: unknown option
|
||||||
|
|
||||||
|
set --show custom_gettext_var
|
||||||
|
# CHECK: $custom_gettext_var: set in local scope, unexported, with 1 elements
|
||||||
|
# CHECK: $custom_gettext_var[1]: |asdf|
|
||||||
|
|
||||||
|
# Test un-exported, local scoping
|
||||||
|
begin
|
||||||
|
set -l LANG de_DE.utf8
|
||||||
|
echo (_ file)
|
||||||
|
# CHECK: Datei
|
||||||
|
end
|
||||||
|
echo (_ file)
|
||||||
|
# CHECK: file
|
||||||
|
|
||||||
|
# Test LANGUAGE fallback
|
||||||
|
set -lx LANGUAGE pt de_DE
|
||||||
|
|
||||||
|
# This is available in Portuguese. (echo is used to get add a newline)
|
||||||
|
echo (_ file)
|
||||||
|
# CHECK: arquivo
|
||||||
|
|
||||||
|
# This is not available in Portuguese, but in German.
|
||||||
|
echo (_ "Control disassembler syntax highlighting style")
|
||||||
|
# CHECK: Steuert den Stil der Syntaxhervorhebung im Disassembler
|
||||||
|
|
||||||
|
# This is not available in any catalog.
|
||||||
|
echo (_ untranslatable)
|
||||||
|
# CHECK: untranslatable
|
||||||
|
|
||||||
|
# Check that C locale disables localization
|
||||||
|
begin
|
||||||
|
set -l LANG C
|
||||||
|
echo (_ file)
|
||||||
|
# CHECK: file
|
||||||
|
end
|
||||||
|
echo (_ file)
|
||||||
|
# CHECK: arquivo
|
||||||
|
begin
|
||||||
|
set -l LC_MESSAGES C
|
||||||
|
echo (_ file)
|
||||||
|
# CHECK: file
|
||||||
|
end
|
||||||
|
echo (_ file)
|
||||||
|
# CHECK: arquivo
|
||||||
|
begin
|
||||||
|
set -l LC_ALL C
|
||||||
|
echo (_ file)
|
||||||
|
# CHECK: file
|
||||||
|
end
|
||||||
|
echo (_ file)
|
||||||
|
# CHECK: arquivo
|
||||||
|
|
||||||
|
# Check that all relevant locale variables are respected.
|
||||||
|
set --erase LANG
|
||||||
|
set --erase LC_MESSAGES
|
||||||
|
set --erase LC_ALL
|
||||||
|
set --erase LANGUAGE
|
||||||
|
echo (_ file)
|
||||||
|
# CHECK: file
|
||||||
|
begin
|
||||||
|
set -l LANG fr_FR.utf8
|
||||||
|
echo (_ file)
|
||||||
|
# CHECK: fichier
|
||||||
|
begin
|
||||||
|
set -l LC_ALL de_DE.utf8
|
||||||
|
echo (_ file)
|
||||||
|
# CHECK: Datei
|
||||||
|
set -g LC_MESSAGES pt_BR.utf8
|
||||||
|
# Should still be German, since LC_ALL overrides LC_MESSAGES
|
||||||
|
echo (_ file)
|
||||||
|
# CHECK: Datei
|
||||||
|
end
|
||||||
|
# LC_ALL is no longer in scope, so now LC_MESSAGES should be used.
|
||||||
|
echo (_ file)
|
||||||
|
# CHECK: arquivo
|
||||||
|
end
|
||||||
|
# Now, only LC_MESSAGES should be in scope
|
||||||
|
echo (_ file)
|
||||||
|
# CHECK: arquivo
|
||||||
|
# LC_ALL should still override LC_MESSAGES
|
||||||
|
set -l LC_ALL de_DE.utf8
|
||||||
|
echo (_ file)
|
||||||
|
# CHECK: Datei
|
||||||
Reference in New Issue
Block a user