我有一个在python:3.6-alpine
上运行的码头工人,并且我使用this来使语言环境进入pt_BR
。
问题是我的LocaleHTMLCalendar
在docker上没有以葡萄牙语显示我的输出(如果我在我的机器上运行,它可以工作)。
这是我的Dockerfile:
FROM python:3.6-alpine as BUILD
RUN apk --no-cache add ca-certificates wget && \
wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.25-r0/glibc-2.25-r0.apk && \
wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.25-r0/glibc-bin-2.25-r0.apk && \
wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.25-r0/glibc-i18n-2.25-r0.apk && \
apk add --allow-untrusted glibc-bin-2.25-r0.apk glibc-i18n-2.25-r0.apk glibc-2.25-r0.apk
COPY ./locale.md /locale.md
RUN cat locale.md | xargs -i /usr/glibc-compat/bin/localedef -i {} -f UTF-8 {}.UTF-8
ENV LANG=pt_BR.UTF-8 \
LANGUAGE=pt_BR.UTF-8 \
LC_ALL=pt_BR.UTF-8
COPY . /app/
EXPOSE 8000
CMD ["./start.sh"]
因此,如果我在docker上运行它:
>>> import locale
>>> locale.getlocale()
('pt_BR', 'UTF-8')
>>> import calendar
>>> x = calendar.LocaleHTMLCalendar()
>>> x.formatmonth(2019,2)
'<table border="0" cellpadding="0" cellspacing="0" class="month">\n<tr><th colspan="7" class="month">February 2019</th></tr>\n<tr><th class="mon">Mon</th><th class="tue">Tue</th><th class="wed">Wed</th><th class="thu">Thu</th><th class="fri">Fri</th><th class="sat">Sat</th><th class="sun">Sun</th></tr>\n<tr><td class="noday"> </td><td class="noday"> </td><td class="noday"> </td><td class="noday"> </td><td class="fri">1</td><td class="sat">2</td><td class="sun">3</td></tr>\n<tr><td class="mon">4</td><td class="tue">5</td><td class="wed">6</td><td class="thu">7</td><td class="fri">8</td><td class="sat">9</td><td class="sun">10</td></tr>\n<tr><td class="mon">11</td><td class="tue">12</td><td class="wed">13</td><td class="thu">14</td><td class="fri">15</td><td class="sat">16</td><td class="sun">17</td></tr>\n<tr><td class="mon">18</td><td class="tue">19</td><td class="wed">20</td><td class="thu">21</td><td class="fri">22</td><td class="sat">23</td><td class="sun">24</td></tr>\n<tr><td class="mon">25</td><td class="tue">26</td><td class="wed">27</td><td class="thu">28</td><td class="noday"> </td><td class="noday"> </td><td class="noday"> </td></tr>\n</table>\n'
您可以看到我的输出是英语而不是葡萄牙语。
我想念什么吗?
编辑
这是我的docker run命令:
docker run --env LANG=pt_BR.UTF-8 --env LANGUAGE=pt_BR.UTF-8 --env LC_ALL=pt_BR.UTF-8 --env LC_TIME=pt_BR.UTF-8 -p 8000:8000 myapp:locale