Skip to content

Commit 45aeb49

Browse files
authored
Merge pull request #574 from code4history/ppe_i18n
Update i18n resources for PPE calculator features
2 parents 94eb9ce + a851b7c commit 45aeb49

File tree

5 files changed

+32
-10
lines changed

5 files changed

+32
-10
lines changed

docs/contributing/app-dev.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,16 @@ STREAMLIT_SERVER_PORT=1234 \
8585
PARAMETERS=./defaults/webapp.cfg streamlit run st_app.py
8686
```
8787

88+
### Choosing a Different Language
89+
90+
If you want to run the application in another language, do the following. You can select Japanese as the language other than English.
91+
92+
```bash
93+
ASSETS=./defaults/assets \
94+
LANG=ja \
95+
PARAMETERS=./defaults/webapp.cfg streamlit run st_app.py
96+
```
97+
8898
## Project Layout
8999

90100
### Application files

src/penn_chime/locales/en.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ en:
44
app-admitted-patients-title: "Admitted Patients (Census)"
55
app-admitted-patients-text: "Projected **census** of COVID-19 patients, accounting for arrivals and discharges."
66
app-PPE-title: "Personal Protective Equipment (PPE) Calculator"
7+
app-PPE-screenshot: "Show a screenshot of the tool"
8+
app-PPE-documentation: |+
9+
Refer to our <a href="{link_to_docs}">user documentation for instructions on how to use the tool</a>.
710
app-SIR-title: "Susceptible, Infected, and Recovered"
811
app-SIR-text: "The number of susceptible, infected, and recovered individuals in the hospital catchment region at any given moment"
912
charts-date: "Date"
@@ -82,6 +85,8 @@ en:
8285
presentation-copyright: "© 2020, The Trustees of the University of Pennsylvania"
8386
presentation-download: |+
8487
<a download="{filename}" href="data:file/csv;base64,{csv}">Download {filename}</a>
88+
presentation-excel-download: |+
89+
Download the PPE Calculator here: <a download="{filename}" href="data:file/xlsx;base64,{excel}">{filename}</a>.
8590
admits_hospitalized: "Hospitalized Admissions"
8691
admits_icu: "ICU Admissions"
8792
admits_ventilated: "Ventilated Admissions"

src/penn_chime/locales/ja.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ ja:
33
app-new-admissions-text: "**日毎の**COVID-19関連新規入院患者数予測"
44
app-admitted-patients-title: "累計入院患者数"
55
app-admitted-patients-text: "入院と退院を考慮したCOVID-19患者の予測**累計患者数**"
6+
app-PPE-title: "個人用防護具 (PPE) 計算機"
7+
app-PPE-screenshot: "ツールのスクリーンショットを表示"
8+
app-PPE-documentation: |+
9+
ツールの使い方については<a href="{link_to_docs}">ユーザドキュメントの説明</a>を確認してください。
610
app-SIR-title: "感受性保持者、感染者と回復者"
711
app-SIR-text: "与えられた時間範囲での、病院の担当範囲領域における感受性保持者、感染者と回復者の人数"
812
charts-date: "日付"
@@ -79,6 +83,8 @@ ja:
7983
presentation-copyright: "© 2020, The Trustees of the University of Pennsylvania"
8084
presentation-download: |+
8185
<a download="{filename}" href="data:file/csv;base64,{csv}">{filename} をダウンロード</a>
86+
presentation-excel-download: |+
87+
個人用防護具計算機のダウンロードはこちら: <a download="{filename}" href="data:file/xlsx;base64,{excel}">{filename}</a>.
8288
admits_hospitalized: "新規入院患者数"
8389
admits_icu: "新規集中治療患者数"
8490
admits_ventilated: "新規人工呼吸患者数"

src/penn_chime/view/st_app.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
import streamlit as st
77
import i18n
88

9+
lang = os.environ.get('LANG') or 'en'
910
i18n.set('filename_format', '{locale}.{format}')
10-
i18n.set('locale', 'en')
11+
i18n.set('locale', lang)
1112
i18n.set('fallback', 'en')
1213
i18n.load_path.append(os.path.dirname(__file__) + '/../locales')
1314

@@ -27,7 +28,9 @@
2728
display_sidebar,
2829
hide_menu_style,
2930
)
30-
31+
from ..constants import (
32+
DOCS_URL,
33+
)
3134

3235
def main():
3336
# This is somewhat dangerous:
@@ -75,16 +78,15 @@ def main():
7578
df=m.ppe_df,
7679
)
7780

78-
if st.checkbox("Show a screenshot of the tool"):
81+
if st.checkbox(i18n.t("app-PPE-screenshot")):
7982
st.image(
8083
image=ppe.screenshot,
8184
width=600,
8285
format='JPEG',
8386
)
84-
st.markdown("""
85-
Refer to our <a href="{link_to_docs}">user documentation for instructions on how to use the tool</a>.
86-
""".format(
87-
link_to_docs="https://code-for-philly.gitbook.io/chime/ppe-calculator",
87+
st.markdown(
88+
i18n.t("app-PPE-documentation").format(
89+
link_to_docs="{docs_url}/ppe-calculator".format(docs_url=DOCS_URL),
8890
),
8991
unsafe_allow_html=True
9092
)

src/penn_chime/view/st_display.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -473,9 +473,8 @@ def display_download_link(st, p, filename: str, df: pd.DataFrame):
473473

474474
def display_excel_download_link(st, filename: str, src: str):
475475
excel = excel_to_base64(src)
476-
st.markdown("""
477-
Download the PPE Calculator here: <a download="{filename}" href="data:file/xlsx;base64,{excel}">{filename}</a>.
478-
""".format(
476+
st.markdown(
477+
i18n.t("presentation-excel-download").format(
479478
excel=excel, filename=filename
480479
),
481480
unsafe_allow_html=True,

0 commit comments

Comments
 (0)