Make use of the information in $LANGUAGE, $LC_ALL, or $LC_MESSAGES, if set.
From: David Shea dshea@redhat.com
Grab language information from $LANGUAGE, $LC_ALL, or $LC_MESSAGES, if available, and then clear all these extra variables so we don't need to worry about them when switching languages. This way translations will work in live environments regardless of which crazy language variable the user or desktop environment or whatever is using to try to communicate with anaconda.
Cherry picked from 56a26b81086e392efbc163f1cfcb0672b631e30d from f22-branch, with modifications not to use empty variables (#1222262). --- anaconda | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
diff --git a/anaconda b/anaconda index 203281c..1a8ec07 100755 --- a/anaconda +++ b/anaconda @@ -1226,6 +1226,23 @@ if __name__ == "__main__": from pyanaconda import localization # Set the language before loading an interface, when it may be too late.
+ # GNU defines four (four!) ways to set the locale via the environment. + # At least three of those are just going to get in the way of anaconda's + # ability to set the language and locale after startup. If any of, in + # order, $LANGUAGE, $LC_ALL, or $LC_MESSAGES is in the environment and not + # empty, copy the information to $LANG, and then clear the rest. + # + # If the variable is set but empty, it doesn't count, and some programs + # (KDE) insist on setting empty variables. Be sure not to use those. + for varname in ("LANGUAGE", "LC_ALL", "LC_MESSAGES"): + if varname in os.environ and os.environ[varname]: + os.environ["LANG"] = os.environ[varname] # pylint: disable=environment-modify + break + + for varname in ("LANGUAGE", "LC_ALL", "LC_MESSAGES"): + if varname in os.environ: + del os.environ[varname] # pylint: disable=environment-modify + # first, try to load firmware language if nothing is already set in # the environment if "LANG" not in os.environ:
Looks good to me.
Added label: ACK.
Pushed.
Closed.
anaconda-patches@lists.fedorahosted.org