Closed nebnola closed 3 years ago
I have no qualms with adding this. I think it would follow the LANG
specification (e.g. a singular 4 character language code to use) and that the language look-up would be to prepend TLDR_LANGUAGE
environment variable to the language list look-up that is derived as part of the client specification.
Implementation would be (I think) to modify the get_language_list
function to do this check and prepend and also get_default_langauge
function so that it gets returned instead LANG
if set.
As a matter of fact, I don't believe this client is even complying with the spec until this is fixed.
If a client has access to environment variables, it MUST use them derive the preferred user language as described in the next paragraphs.
@bl-ue The spec prescribes only usage of the LANG
and LANGUAGE
environment variables as being used to determine language, which this client does do and is spec compliant.
Adding support for TLDR_LANGUAGE
would if anything make the client less spec compliant, but I think it's a useful feature, and one that can be used as an implementation reference to perhaps adopting into the spec (or at the very least add language to the spec allowing this modification).
Oh, I see. I thought that TLDR_LANGUAGE
was merely a suggestion. @nebnola are you aware that you can set LANG=de
(for example) to customize the default language that tldr
uses?
Yes, I'm aware of that. However LANG
affects the whole system, while I would like to be able to set a default for tldr without specifying the -L
argument each time. So basically, if -L
is unset, as @MasterOdin said, I would prepend the value of TLDR_LANGUAGE
to the existing list which is derived from LANG
and LANGUAGES
Hm, thinking about it, I think that you want to modify the get_language_list
function to prepend the value of TLDR_LANGUAGE
and modify here:
so that it first calls a function that returns the value of TLDR_LANGUAGE
, and if that's not set, then it calls get_default_language
, or something of that nature. We would ideally keep the behavior of appending LANG
into LANGUAGES
if both are set, but still allow the usage of TLDR_LANGUAGE
as the principal language if set.
Hopefully that makes sense.
Resolved by #157. Thanks everyone for your help!
Hi, I just discovered your project and think this would be a useful feature: A
TLDR_LANGUAGE
environment variable that sets the default language for tldr. This way, users who want tldr to use a different language by default than the system language can set it permanently in their~/.bashrc
. I would be happy to write the changes myself, I'd just like to know if that feature would be welcome or not.