diff options
author | EuAndreh <eu@euandre.org> | 2021-06-17 22:22:22 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2021-06-17 22:31:49 -0300 |
commit | bf41672f72ee3ff7679c93e0d5a8f8646c19db3e (patch) | |
tree | 33ea422f4bf63f56ae6b33874f3a9a21991bd79d /aux/workflow/assert-manpages.sh | |
parent | Makefile: Use mkdir+cp over install (diff) | |
download | git-permalink-bf41672f72ee3ff7679c93e0d5a8f8646c19db3e.tar.gz git-permalink-bf41672f72ee3ff7679c93e0d5a8f8646c19db3e.tar.xz |
src/git-permalink.sh: Translate program output to pt, fr and eo
The choice of implementation was very basic: Use strings in the script
itself rather than relying on external tools.
Compared to a compiled C program using, say, gettext.3, an sh script
could also depend on it, but at runtime. An equivalent C code would
require the gettext.3 dependency, but at compile time. After
compilation, the code required for doing the translation is already on
the binary, while an sh script would need gettext.1 to run gettext.1
commands while it executes, such as "gettext -s 'MSG_ABC'".
Bash has a very appealing feature: using $"" does a lookup and
translates the string. In other words, $"" runs gettext for you,
without the script requiring gettext.1, just Bash.
As tempting as it was, I chose not to rely on Bash. I preferred the
cost of an ad-hoc solution over requiring Bash over POSIX sh.
The final solution is simple enough for the git-permalink.1 program,
but wouldn't scale for bigger scripts. Strings are placed together for
translation, and no external tool is used for this.
Due to the way that strings are now given to printf.1, ShellCheck
complains a lot about those strings, alonside saying that the
string translation variables are unused. They actually are used, but
hidden behind an eval.
Overall I'm satisfied with the solution, but I probably won't follow
the same path for the manpages, and will choose something like po4a for
it, instead.
Diffstat (limited to 'aux/workflow/assert-manpages.sh')
0 files changed, 0 insertions, 0 deletions