rafaldembski commited on
Commit
a53b184
verified
1 Parent(s): 0da5dab

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +77 -23
app.py CHANGED
@@ -23,14 +23,65 @@ st.set_page_config(
23
  # 2. Inicjalizacja pliku statystyk
24
  init_stats_file()
25
 
26
- # 3. Dodanie niestandardowego CSS
27
- custom_css = """
28
- <style>
29
- /* Ukryj boczne menu Streamlit */
30
- [data-testid="stSidebar"] {
31
- display: none;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
 
 
 
 
 
 
 
 
 
 
34
  /* Stylizacja poziomego menu */
35
  .streamlit-option-menu {
36
  display: flex;
@@ -42,19 +93,19 @@ custom_css = """
42
  }
43
 
44
  /* Pod艣wietlenie wybranej zak艂adki */
45
- .option-menu-item.selected {
46
  background-color: #02ab21 !important; /* Zielone t艂o dla wybranej zak艂adki */
47
  color: #ffffff !important; /* Bia艂y tekst dla wybranej zak艂adki */
48
  }
49
 
50
  /* Efekt hover dla element贸w menu */
51
- .option-menu-item:hover {
52
  background-color: #02ab21 !important; /* Zielone t艂o podczas hover */
53
  color: #ffffff !important; /* Bia艂y tekst podczas hover */
54
  }
55
 
56
  /* Zmiana koloru ikon w menu */
57
- .option-menu-item .icon {
58
  color: inherit !important;
59
  }
60
 
@@ -63,7 +114,7 @@ custom_css = """
63
  .streamlit-option-menu {
64
  flex-direction: column;
65
  }
66
- .option-menu-item {
67
  margin: 5px 0;
68
  width: 100%;
69
  text-align: center;
@@ -73,11 +124,11 @@ custom_css = """
73
  """
74
  st.markdown(custom_css, unsafe_allow_html=True)
75
 
76
- # 4. Tworzenie poziomego menu w kontenerze
77
  with st.container():
78
  selected = option_menu(
79
  menu_title=None, # Brak tytu艂u menu
80
- options=["Analiza SMS", "O Projekcie", "Edukacja", "Statystyki", "Kontakt"],
81
  icons=["shield-check", "info-circle", "book", "bar-chart", "envelope"],
82
  menu_icon=None, # Usuni臋cie ikony menu
83
  default_index=0,
@@ -98,19 +149,22 @@ with st.container():
98
  }
99
  )
100
 
101
- # 5. Importowanie i wywo艂ywanie modu艂贸w dla ka偶dej zak艂adki
102
- if selected == "Analiza SMS":
 
 
 
103
  from pages.Analysis import show_analysis
104
- show_analysis()
105
- elif selected == "O Projekcie":
106
  from pages.About import main as show_about
107
- show_about()
108
- elif selected == "Edukacja":
109
  from pages.Education import main as show_education
110
- show_education()
111
- elif selected == "Statystyki":
112
  from pages.Statistics import main as show_statistics
113
- show_statistics()
114
- elif selected == "Kontakt":
115
  from pages.Contact import main as show_contact
116
- show_contact()
 
23
  # 2. Inicjalizacja pliku statystyk
24
  init_stats_file()
25
 
26
+ # 3. Definiowanie t艂umacze艅
27
+ translations = {
28
+ 'Polish': {
29
+ 'menu_analysis_sms': 'Analiza SMS',
30
+ 'menu_about': 'O Projekcie',
31
+ 'menu_education': 'Edukacja',
32
+ 'menu_statistics': 'Statystyki',
33
+ 'menu_contact': 'Kontakt',
34
+ 'language_select': 'Wybierz j臋zyk',
35
+ 'separator': '---'
36
+ # ... dodaj inne t艂umaczenia
37
+ },
38
+ 'German': {
39
+ 'menu_analysis_sms': 'SMS-Analyse',
40
+ 'menu_about': '脺ber das Projekt',
41
+ 'menu_education': 'Bildung',
42
+ 'menu_statistics': 'Statistiken',
43
+ 'menu_contact': 'Kontakt',
44
+ 'language_select': 'Sprache ausw盲hlen',
45
+ 'separator': '---'
46
+ # ... dodaj inne t艂umaczenia
47
+ },
48
+ 'English': {
49
+ 'menu_analysis_sms': 'SMS Analysis',
50
+ 'menu_about': 'About the Project',
51
+ 'menu_education': 'Education',
52
+ 'menu_statistics': 'Statistics',
53
+ 'menu_contact': 'Contact',
54
+ 'language_select': 'Select Language',
55
+ 'separator': '---'
56
+ # ... dodaj inne t艂umaczenia
57
  }
58
+ }
59
+
60
+ # 4. Language selection
61
+ if 'language' not in st.session_state:
62
+ st.session_state.language = 'Polish'
63
+
64
+ def set_language():
65
+ st.session_state.language = st.session_state.language_select
66
+
67
+ # Wy艣wietlenie wyboru j臋zyka na g贸rze aplikacji
68
+ st.radio(
69
+ translations['Polish']['language_select'],
70
+ ('Polish', 'German', 'English'),
71
+ key='language_select',
72
+ index=['Polish', 'German', 'English'].index(st.session_state.language),
73
+ on_change=set_language
74
+ )
75
 
76
+ selected_language = st.session_state.language
77
+
78
+ # 5. Fetch translated menu options
79
+ menu_keys = ['menu_analysis_sms', 'menu_about', 'menu_education', 'menu_statistics', 'menu_contact']
80
+ menu_options = [translations[selected_language][key] for key in menu_keys]
81
+
82
+ # 6. Dodanie niestandardowego CSS do wzmocnienia styl贸w menu
83
+ custom_css = """
84
+ <style>
85
  /* Stylizacja poziomego menu */
86
  .streamlit-option-menu {
87
  display: flex;
 
93
  }
94
 
95
  /* Pod艣wietlenie wybranej zak艂adki */
96
+ .streamlit-option-menu .selected {
97
  background-color: #02ab21 !important; /* Zielone t艂o dla wybranej zak艂adki */
98
  color: #ffffff !important; /* Bia艂y tekst dla wybranej zak艂adki */
99
  }
100
 
101
  /* Efekt hover dla element贸w menu */
102
+ .streamlit-option-menu .menu-item:hover {
103
  background-color: #02ab21 !important; /* Zielone t艂o podczas hover */
104
  color: #ffffff !important; /* Bia艂y tekst podczas hover */
105
  }
106
 
107
  /* Zmiana koloru ikon w menu */
108
+ .streamlit-option-menu .menu-item .icon {
109
  color: inherit !important;
110
  }
111
 
 
114
  .streamlit-option-menu {
115
  flex-direction: column;
116
  }
117
+ .streamlit-option-menu .menu-item {
118
  margin: 5px 0;
119
  width: 100%;
120
  text-align: center;
 
124
  """
125
  st.markdown(custom_css, unsafe_allow_html=True)
126
 
127
+ # 7. Tworzenie poziomego menu w kontenerze
128
  with st.container():
129
  selected = option_menu(
130
  menu_title=None, # Brak tytu艂u menu
131
+ options=menu_options,
132
  icons=["shield-check", "info-circle", "book", "bar-chart", "envelope"],
133
  menu_icon=None, # Usuni臋cie ikony menu
134
  default_index=0,
 
149
  }
150
  )
151
 
152
+ # 8. Dodanie separatora
153
+ st.markdown("---") # Dodaje poziom膮 lini臋
154
+
155
+ # 9. Importowanie i wywo艂ywanie modu艂贸w dla ka偶dej zak艂adki
156
+ if selected == translations[selected_language]['menu_analysis_sms']:
157
  from pages.Analysis import show_analysis
158
+ show_analysis(selected_language)
159
+ elif selected == translations[selected_language]['menu_about']:
160
  from pages.About import main as show_about
161
+ show_about(selected_language)
162
+ elif selected == translations[selected_language]['menu_education']:
163
  from pages.Education import main as show_education
164
+ show_education(selected_language)
165
+ elif selected == translations[selected_language]['menu_statistics']:
166
  from pages.Statistics import main as show_statistics
167
+ show_statistics(selected_language)
168
+ elif selected == translations[selected_language]['menu_contact']:
169
  from pages.Contact import main as show_contact
170
+ show_contact(selected_language)