Spaces:
Sleeping
Sleeping
Commit ·
c4a4c9c
1
Parent(s): e286985
Fix Malaysian language translations for Step 6 PDF titles and chart labels
Browse files- modules/results.py +6 -3
- utils/pdf_utils.py +6 -6
- utils/translations.py +14 -0
modules/results.py
CHANGED
|
@@ -16587,10 +16587,13 @@ def _extract_first_float(value, default_value=0.0):
|
|
| 16587 |
def display_forecast_graph_content(analysis_data, step_number=None, step_title=None):
|
| 16588 |
"""Display Forecast Graph content with baseline - works for any step with yield forecast data"""
|
| 16589 |
# Dynamic header based on step information
|
|
|
|
| 16590 |
if step_number and step_title:
|
| 16591 |
-
|
|
|
|
|
|
|
| 16592 |
else:
|
| 16593 |
-
header_title = "📈
|
| 16594 |
|
| 16595 |
# Styled header with updated background color
|
| 16596 |
st.markdown(
|
|
@@ -16767,7 +16770,7 @@ def display_forecast_graph_content(analysis_data, step_number=None, step_title=N
|
|
| 16767 |
))
|
| 16768 |
|
| 16769 |
fig.update_layout(
|
| 16770 |
-
title='5-Year Yield Projection from Current Baseline',
|
| 16771 |
xaxis_title='Years',
|
| 16772 |
yaxis_title='Yield (tons/ha)',
|
| 16773 |
xaxis=dict(
|
|
|
|
| 16587 |
def display_forecast_graph_content(analysis_data, step_number=None, step_title=None):
|
| 16588 |
"""Display Forecast Graph content with baseline - works for any step with yield forecast data"""
|
| 16589 |
# Dynamic header based on step information
|
| 16590 |
+
forecast_text = t('pdf_5_year_yield_forecast_projections', '5-Year Yield Forecast & Projections')
|
| 16591 |
if step_number and step_title:
|
| 16592 |
+
# Translate step title if needed
|
| 16593 |
+
translated_step_title = translate_step_title(step_title, step_number)
|
| 16594 |
+
header_title = f"📈 STEP {step_number} — {translated_step_title}: {forecast_text}"
|
| 16595 |
else:
|
| 16596 |
+
header_title = f"📈 {forecast_text}"
|
| 16597 |
|
| 16598 |
# Styled header with updated background color
|
| 16599 |
st.markdown(
|
|
|
|
| 16770 |
))
|
| 16771 |
|
| 16772 |
fig.update_layout(
|
| 16773 |
+
title=t('pdf_5_year_yield_projection_baseline', '5-Year Yield Projection from Current Baseline'),
|
| 16774 |
xaxis_title='Years',
|
| 16775 |
yaxis_title='Yield (tons/ha)',
|
| 16776 |
xaxis=dict(
|
utils/pdf_utils.py
CHANGED
|
@@ -4339,7 +4339,7 @@ class PDFReportGenerator:
|
|
| 4339 |
|
| 4340 |
return {
|
| 4341 |
'type': 'line_chart',
|
| 4342 |
-
'title': '5-Year Yield Forecast by Investment Scenario',
|
| 4343 |
'subtitle': 'Projected yield increase over 5 years with different investment levels',
|
| 4344 |
'data': {
|
| 4345 |
'categories': [f'Year {year}' for year in years],
|
|
@@ -7006,7 +7006,7 @@ class PDFReportGenerator:
|
|
| 7006 |
story = []
|
| 7007 |
|
| 7008 |
# 5-Year Yield Forecast header
|
| 7009 |
-
story.append(Paragraph(
|
| 7010 |
story.append(Spacer(1, 12))
|
| 7011 |
|
| 7012 |
# Find yield forecast data from multiple possible locations
|
|
@@ -7134,7 +7134,7 @@ class PDFReportGenerator:
|
|
| 7134 |
# Customize the graph
|
| 7135 |
ax.set_xlabel('Years', fontsize=12, fontweight='bold')
|
| 7136 |
ax.set_ylabel('Yield (tons/ha)', fontsize=12, fontweight='bold')
|
| 7137 |
-
ax.set_title('5-Year Yield Forecast from Current Baseline', fontsize=14, fontweight='bold')
|
| 7138 |
ax.legend(fontsize=10)
|
| 7139 |
ax.grid(True, alpha=0.3)
|
| 7140 |
ax.set_xticks(years)
|
|
@@ -7189,7 +7189,7 @@ class PDFReportGenerator:
|
|
| 7189 |
# Customize the graph
|
| 7190 |
ax.set_xlabel('Years', fontsize=12, fontweight='bold')
|
| 7191 |
ax.set_ylabel('Yield (tons/ha)', fontsize=12, fontweight='bold')
|
| 7192 |
-
ax.set_title('5-Year Yield Forecast - Sample Projections', fontsize=14, fontweight='bold')
|
| 7193 |
ax.legend(fontsize=10)
|
| 7194 |
ax.grid(True, alpha=0.3)
|
| 7195 |
ax.set_xticks(years)
|
|
@@ -8069,7 +8069,7 @@ class PDFReportGenerator:
|
|
| 8069 |
# Set chart properties - IMPROVED TO MATCH RESULTS PAGE
|
| 8070 |
ax.set_xlabel('Years', fontsize=12, fontweight='bold')
|
| 8071 |
ax.set_ylabel('Yield (tons/ha)', fontsize=12, fontweight='bold')
|
| 8072 |
-
ax.set_title('5-Year Yield Projection from Current Baseline', fontsize=14, fontweight='bold', pad=20)
|
| 8073 |
|
| 8074 |
# Position legend at top right - EXACT SAME AS RESULTS PAGE
|
| 8075 |
ax.legend(loc='upper right', bbox_to_anchor=(1.0, 1.0), framealpha=0.8)
|
|
@@ -8243,7 +8243,7 @@ class PDFReportGenerator:
|
|
| 8243 |
|
| 8244 |
ax.set_xlabel('Year')
|
| 8245 |
ax.set_ylabel('Yield (tonnes/hectare)')
|
| 8246 |
-
ax.set_title('5-Year Yield Forecast (t/ha)')
|
| 8247 |
ax.legend()
|
| 8248 |
ax.grid(True, alpha=0.3)
|
| 8249 |
|
|
|
|
| 4339 |
|
| 4340 |
return {
|
| 4341 |
'type': 'line_chart',
|
| 4342 |
+
'title': self._t('pdf_5_year_yield_forecast_scenario', '5-Year Yield Forecast by Investment Scenario'),
|
| 4343 |
'subtitle': 'Projected yield increase over 5 years with different investment levels',
|
| 4344 |
'data': {
|
| 4345 |
'categories': [f'Year {year}' for year in years],
|
|
|
|
| 7006 |
story = []
|
| 7007 |
|
| 7008 |
# 5-Year Yield Forecast header
|
| 7009 |
+
story.append(Paragraph(self._t('pdf_5_year_yield_forecast', '5-Year Yield Forecast'), self.styles['Heading1']))
|
| 7010 |
story.append(Spacer(1, 12))
|
| 7011 |
|
| 7012 |
# Find yield forecast data from multiple possible locations
|
|
|
|
| 7134 |
# Customize the graph
|
| 7135 |
ax.set_xlabel('Years', fontsize=12, fontweight='bold')
|
| 7136 |
ax.set_ylabel('Yield (tons/ha)', fontsize=12, fontweight='bold')
|
| 7137 |
+
ax.set_title(self._t('pdf_5_year_yield_forecast_baseline', '5-Year Yield Forecast from Current Baseline'), fontsize=14, fontweight='bold')
|
| 7138 |
ax.legend(fontsize=10)
|
| 7139 |
ax.grid(True, alpha=0.3)
|
| 7140 |
ax.set_xticks(years)
|
|
|
|
| 7189 |
# Customize the graph
|
| 7190 |
ax.set_xlabel('Years', fontsize=12, fontweight='bold')
|
| 7191 |
ax.set_ylabel('Yield (tons/ha)', fontsize=12, fontweight='bold')
|
| 7192 |
+
ax.set_title(self._t('pdf_5_year_yield_forecast_sample', '5-Year Yield Forecast - Sample Projections'), fontsize=14, fontweight='bold')
|
| 7193 |
ax.legend(fontsize=10)
|
| 7194 |
ax.grid(True, alpha=0.3)
|
| 7195 |
ax.set_xticks(years)
|
|
|
|
| 8069 |
# Set chart properties - IMPROVED TO MATCH RESULTS PAGE
|
| 8070 |
ax.set_xlabel('Years', fontsize=12, fontweight='bold')
|
| 8071 |
ax.set_ylabel('Yield (tons/ha)', fontsize=12, fontweight='bold')
|
| 8072 |
+
ax.set_title(self._t('pdf_5_year_yield_projection_baseline', '5-Year Yield Projection from Current Baseline'), fontsize=14, fontweight='bold', pad=20)
|
| 8073 |
|
| 8074 |
# Position legend at top right - EXACT SAME AS RESULTS PAGE
|
| 8075 |
ax.legend(loc='upper right', bbox_to_anchor=(1.0, 1.0), framealpha=0.8)
|
|
|
|
| 8243 |
|
| 8244 |
ax.set_xlabel('Year')
|
| 8245 |
ax.set_ylabel('Yield (tonnes/hectare)')
|
| 8246 |
+
ax.set_title(self._t('pdf_5_year_yield_forecast_tonnes', '5-Year Yield Forecast (t/ha)'))
|
| 8247 |
ax.legend()
|
| 8248 |
ax.grid(True, alpha=0.3)
|
| 8249 |
|
utils/translations.py
CHANGED
|
@@ -390,6 +390,13 @@ TRANSLATIONS = {
|
|
| 390 |
'pdf_additional_recommendations': 'Additional Recommendations',
|
| 391 |
'pdf_specific_recommendations_rates': 'Specific Recommendations (Rates)',
|
| 392 |
'pdf_forecast_graph_title': 'Forecast Graph: 5-Year Yield Forecast & Projections',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 393 |
'pdf_comprehensive_analysis_results': 'Comprehensive Analysis Results:',
|
| 394 |
'pdf_summary': 'Summary',
|
| 395 |
'pdf_detailed_analysis': 'Detailed Analysis',
|
|
@@ -799,6 +806,13 @@ TRANSLATIONS = {
|
|
| 799 |
'pdf_additional_recommendations': 'Cadangan Tambahan',
|
| 800 |
'pdf_specific_recommendations_rates': 'Cadangan Khusus (Kadar)',
|
| 801 |
'pdf_forecast_graph_title': 'Graf Ramalan: Ramalan & Unjuran Hasil 5 Tahun',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 802 |
'pdf_comprehensive_analysis_results': 'Keputusan Analisis Komprehensif:',
|
| 803 |
'pdf_summary': 'Ringkasan',
|
| 804 |
'pdf_detailed_analysis': 'Analisis Terperinci',
|
|
|
|
| 390 |
'pdf_additional_recommendations': 'Additional Recommendations',
|
| 391 |
'pdf_specific_recommendations_rates': 'Specific Recommendations (Rates)',
|
| 392 |
'pdf_forecast_graph_title': 'Forecast Graph: 5-Year Yield Forecast & Projections',
|
| 393 |
+
'pdf_5_year_yield_forecast_projections': '5-Year Yield Forecast & Projections',
|
| 394 |
+
'pdf_5_year_yield_projection_baseline': '5-Year Yield Projection from Current Baseline',
|
| 395 |
+
'pdf_5_year_yield_forecast': '5-Year Yield Forecast',
|
| 396 |
+
'pdf_5_year_yield_forecast_baseline': '5-Year Yield Forecast from Current Baseline',
|
| 397 |
+
'pdf_5_year_yield_forecast_sample': '5-Year Yield Forecast - Sample Projections',
|
| 398 |
+
'pdf_5_year_yield_forecast_tonnes': '5-Year Yield Forecast (t/ha)',
|
| 399 |
+
'pdf_5_year_yield_forecast_scenario': '5-Year Yield Forecast by Investment Scenario',
|
| 400 |
'pdf_comprehensive_analysis_results': 'Comprehensive Analysis Results:',
|
| 401 |
'pdf_summary': 'Summary',
|
| 402 |
'pdf_detailed_analysis': 'Detailed Analysis',
|
|
|
|
| 806 |
'pdf_additional_recommendations': 'Cadangan Tambahan',
|
| 807 |
'pdf_specific_recommendations_rates': 'Cadangan Khusus (Kadar)',
|
| 808 |
'pdf_forecast_graph_title': 'Graf Ramalan: Ramalan & Unjuran Hasil 5 Tahun',
|
| 809 |
+
'pdf_5_year_yield_forecast_projections': 'Ramalan & Unjuran Hasil 5 Tahun',
|
| 810 |
+
'pdf_5_year_yield_projection_baseline': 'Unjuran Hasil 5 Tahun dari Garis Dasar Semasa',
|
| 811 |
+
'pdf_5_year_yield_forecast': 'Ramalan Hasil 5 Tahun',
|
| 812 |
+
'pdf_5_year_yield_forecast_baseline': 'Ramalan Hasil 5 Tahun dari Garis Dasar Semasa',
|
| 813 |
+
'pdf_5_year_yield_forecast_sample': 'Ramalan Hasil 5 Tahun - Unjuran Sampel',
|
| 814 |
+
'pdf_5_year_yield_forecast_tonnes': 'Ramalan Hasil 5 Tahun (t/ha)',
|
| 815 |
+
'pdf_5_year_yield_forecast_scenario': 'Ramalan Hasil 5 Tahun mengikut Senario Pelaburan',
|
| 816 |
'pdf_comprehensive_analysis_results': 'Keputusan Analisis Komprehensif:',
|
| 817 |
'pdf_summary': 'Ringkasan',
|
| 818 |
'pdf_detailed_analysis': 'Analisis Terperinci',
|