我想将docker容器中的浏览器语言设置为德语。
我在 chrome 选项中设置语言是这样的。当我使用 VS 测试资源管理器在 docker 外部执行测试时,这是有效的:
ChromeOptions options = new();
options.AddArguments("--incognito");
options.AddArguments("--ignore-ssl-errors=yes");
options.AddArguments("--ignore-certificate-errors");
options.AddArguments("--disable-gpu");
options.AddArguments("--disable-infobars");
options.AddArguments("--window-size=1920,1080");
options.AddArguments("--lang=de_DE");
我还尝试在 dockerfile 中设置区域设置:
ENV TZ="Europe/Vienna"
# Install locales package
RUN apt-get update && apt-get install -y locales
# Set the locale to German
RUN sed -i -e 's/# de_DE.UTF-8 UTF-8/de_DE.UTF-8 UTF-8/' /etc/locale.gen && \
dpkg-reconfigure --frontend=noninteractive locales && \
update-locale LANG=de_DE.UTF-8
# Set environment variables
ENV LANG de_DE.UTF-8
ENV LANGUAGE de_DE:de
ENV LC_ALL de_DE.UTF-8
# Optionally, you might need to regenerate the locales
RUN locale-gen de_DE.UTF-8
但是浏览器启动时仍然是英文。我找不到任何其他解决方案,希望我能在这里获得帮助。 我也不明白为什么当我添加参数时,chrome 选项没有将容器中的 chrome 浏览器设置为德语。