From f016d462c3d99be0765507a8a9e71b4cd47a5d10 Mon Sep 17 00:00:00 2001 From: Randy Lai Date: Wed, 4 May 2022 14:56:57 -0700 Subject: [PATCH] set LANG to en_US.UTF-8 if not set for R 4.2 windows --- radian/app.py | 2 ++ radian/rutils.py | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/radian/app.py b/radian/app.py index 85f68de..fcc766e 100644 --- a/radian/app.py +++ b/radian/app.py @@ -204,6 +204,8 @@ def run(self, options, cleanup=None): rchitect.init(args=args, register_signal_handlers=True) + rutils.set_lang() + try: rutils.source_radian_profile(options.profile) except RuntimeError as e: diff --git a/radian/rutils.py b/radian/rutils.py index 9ca840d..0bddbc8 100644 --- a/radian/rutils.py +++ b/radian/rutils.py @@ -1,6 +1,6 @@ import os import sys -from rchitect import rcopy, rcall +from rchitect import rcopy, reval, rcall from rchitect._cffi import ffi, lib from rchitect.interface import roption, protected, rstring_p from .key_bindings import map_key @@ -89,6 +89,14 @@ def register_cleanup(cleanup): onexit=True) +def set_lang(): + if sys.platform.startswith("win"): + if not os.environ.get("LANG", ""): + if rcopy(reval( + 'compareVersion(paste0(R.version$major, ".", R.version$minor), "4.2.0") >= 0')): + os.environ["LANG"] = "en_US.UTF-8" + + def run_on_load_hooks(): hooks = roption("radian.on_load_hooks", []) for hook in hooks: