Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translations #10

Merged
merged 2 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
163 changes: 92 additions & 71 deletions dashboard/app.py

Large diffs are not rendered by default.

50 changes: 50 additions & 0 deletions dashboard/assets/locale/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"app_title": "Lichens Go Dashboard",
"observation_tab_title": "Sites",
"observation_tab_tooltip": "Click on a site to discover what lichens can teach us.",
"species_tab_title": "Species",
"map_title": "Observation Map",
"map_tooltip": "Click on a point to display observation details",
"species_number_distribution_hist1_title": "Species Count Distribution",
"species_number_distribution_hist1_tooltip": "The number of lichen species (or diversity) reflects environmental quality. Generally, more species indicate less pollution. Select a site on the map to see its position (red line) relative to other Lichens GO records (blue bars).",
"vdl_distribution_hist2_title": "Lichen Diversity Value Distribution",
"vdl_distribution_hist2_tooltip": "The LDV (lichen diversity value) measures the abundance of lichens at a site. This abundance corresponds to the number of squares in which a species is present. A high LDV suggests less pollution, but other environmental factors such as climate can also influence this index. It is therefore important to consider the ecology of the species present by looking at other indicators, such as the presence of toxitolerant species. Select a site to see its position (red line) compared to other Lichens GO records (blue bars).",
"species_distribution_hist3_title": "Observed Species",
"species_distribution_hist3_tooltip": "This chart shows the percentage of squares where each species was observed on the selected site.",
"thallus_pie_chart_title": "Thallus Type",
"thallus_pie_chart_tooltip": "This chart illustrates the number of fruticose, foliose, and crustose lichens observed at the selected site.",
"toxitolerance_gauge_title": "Toxitolerant Species (%)",
"toxitolerance_gauge_tooltip": "This indicator shows the proportion of toxitolerant species at the site. Toxitolerant species are generally tolerant to air pollution. They are mainly found in highly disturbed urban environments. Generally, the higher their proportion at a site, the more it is affected by human activities.",
"eutrophication_gauge_title": "Eutrophic Species (%)",
"eutrophication_gauge_tooltip": "This indicator shows the proportion of eutrophic species at the site. Eutrophic species are favored by pollution enriched with nitrogen nutrients, mainly related to urban traffic and rural agriculture. A high proportion of eutrophic species often indicates ecological imbalance, signaling that the site is heavily affected by this form of pollution.",
"acidity_gauge_title": "Acidophilic Species (%)",
"acidity_gauge_tooltip": "Acidophilic species are favored by acidic pollution. However, this type of pollution has practically disappeared from our cities. Therefore, currently, acidophilic species are rather indicators of an absence of eutrophic pollution.",
"species_presence_map_title": "Selected Species Presence Map",
"species_presence_map_tooltip": "This map illustrates the distribution of lichen species based on the records of Lichens GO participants.",
"species_distribution_hist4_title": "Most Observed Species",
"species_distribution_hist4_tooltip": "This chart shows the number of sites where each species was observed.",
"species_dropdown_label": "Species",
"species_dropdown_description": "Select a species to display its information",
"toxitolerance_badge": "Toxitolerance",
"acidity_badge": "Acidity",
"eutrophication_badge": "Eutrophication",
"species_description1": "This lichen",
"species_description2": "is",
"species_description3": "in urban environment",
"nb_species_cat": "Species Count",
"VDL_cat": "LDV",
"deg_toxitolerance_cat": "Toxitolerant Species (%)",
"deg_eutrophication_cat": "Eutrophic Species (%)",
"deg_acidity_cat": "Acidophilic Species (%)",
"unknown": "unknown",
"acidophilous": "acidophilic",
"neutrophilous": "neutrophilic",
"basophilous": "basophilic",
"oligotrophic": "oligotrophic",
"mesotrophic": "mesotrophic",
"eutrophic": "eutrophic",
"sensitive": "sensitive",
"intermediate": "intermediate",
"tolerant": "tolerant",
"resistant": "resistant"
}
50 changes: 50 additions & 0 deletions dashboard/assets/locale/fr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"app_title": "Tableau de bord Lichens Go",
"observation_tab_title": "Sites",
"observation_tab_tooltip": "Cliquez sur un site pour découvrir ce que les lichens peuvent nous apprendre.",
"species_tab_title": "Espèces",
"map_title": "Carte des observations",
"map_tooltip": "Cliquer sur un point pour afficher les informations de l'observation",
"species_number_distribution_hist1_title": "Distribution du nombre d'espèces",
"species_number_distribution_hist1_tooltip": "Le nombre d'espèces (ou diversité) des lichens reflète la qualité de l'environnement. En règle générale, plus il y a d'espèces, moins le site est pollué. Sélectionnez un site sur la carte pour voir sa position (ligne rouge) par rapport aux autres relevés Lichens GO (barres bleues).",
"vdl_distribution_hist2_title": "Distribution de la valeur de diversité lichénique",
"vdl_distribution_hist2_tooltip": "La VDL (valeur de diversité lichénique) mesure l'abondance des lichens sur un site. Cette abondance correspond au nombre de carrés dans lesquels une espèce est présente. Une VDL élevée suggère moins de pollution, mais d'autres facteurs environnementaux comme le climat peuvent influencer cet indice. Il est donc important de considérer l'écologie des espèces présentes en s'intéressant à d'autres indicateurs, tels que la présence d'espèces toxitolérantes. Sélectionnez un site pour voir sa position (ligne rouge) par rapport aux relevés Lichens GO (barres bleues).",
"species_distribution_hist3_title": "Espèces observées",
"species_distribution_hist3_tooltip": "Ce graphique montre le pourcentage de cases où chaque espèce a été observée sur le site sélectionné.",
"thallus_pie_chart_title": "Type de thalle",
"thallus_pie_chart_tooltip": "Ce graphique illustre le nombre de lichens fruticuleux, foliacés et crustacés observés sur le site sélectionné.",
"toxitolerance_gauge_title": "Espèces toxitolérantes (%)",
"toxitolerance_gauge_tooltip": "Cet indicateur présente la proportion des espèces toxitolérantes sur le site. Les espèces toxitolérantes sont tolérantes à la pollution de l'air en général. Elles se trouvent principalement dans les environnements urbains fortement perturbés. En général, plus leur proportion sur un site est élevée, plus ce site est affecté par les activités humaines.",
"eutrophication_gauge_title": "Espèces eutrophes (%)",
"eutrophication_gauge_tooltip": "Cet indicateur présente la proportion des espèces eutrophes sur le site. Les espèces eutrophes sont favorisées par une pollution enrichie en nutriments azotés, principalement liée au trafic automobile en milieu urbain et à l'agriculture en milieu rural. Une proportion élevée d'espèces eutrophes indique souvent un déséquilibre écologique, signalant que le site est fortement affecté par cette forme de pollution.",
"acidity_gauge_title": "Espèces acidophiles (%)",
"acidity_gauge_tooltip": "Les espèces acidophiles sont favorisées par la pollution acide. Cependant, ce type de pollution a pratiquement disparu de nos villes. C'est pourquoi à l'heure actuelle, les espèces acidophiles sont plutôt indicatrices d'une absence de pollution eutrophisante.",
"species_presence_map_title": "Carte de présence de l'espèce sélectionnée",
"species_presence_map_tooltip": "Cette carte illustre la répartition des espèces de lichens sur base des relevés des participants Lichens GO.",
"species_distribution_hist4_title": "Espèces les plus observées",
"species_distribution_hist4_tooltip": "Ce graphique présente le nombre de sites où chaque espèce a été observée.",
"species_dropdown_label": "Espèce",
"species_dropdown_description": "Sélectionnez une espèce pour afficher les informations s'y rapportant",
"toxitolerance_badge": "Toxitolérance",
"acidity_badge": "Acidité",
"eutrophication_badge": "Eutrophisation",
"species_description1": "Ce lichen",
"species_description2": "est",
"species_description3": "en milieu urbain",
"nb_species_cat": "Nombre d'espèces",
"VDL_cat": "VDL",
"deg_toxitolerance_cat": "Espèces toxitolérantes (%)",
"deg_eutrophication_cat": "Espèces eutrophes (%)",
"deg_acidity_cat": "Espèces acidophiles (%)",
"unknown": "inconnu",
"acidophilous": "acidophile",
"neutrophilous": "neutrophile",
"basophilous": "basophile",
"oligotrophic": "oligotrophe",
"mesotrophic": "mésotrophe",
"eutrophic": "eutrophe",
"sensitive": "sensible",
"intermediate": "intermédiaire",
"tolerant": "tolérant",
"resistant": "résistant"
}
4 changes: 2 additions & 2 deletions dashboard/charts.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import plotly.express as px
import plotly.graph_objects as go
from dashboard.constants import BASE_COLOR_PALETTE, PASTEL_COLOR_PALETTE, PLOTLY_LAYOUT, MAP_SETTINGS
from dashboard.constants import BASE_COLOR_PALETTE, PASTEL_COLOR_PALETTE, PLOTLY_LAYOUT, MAP_COLOR_PALETTES


"""
Expand Down Expand Up @@ -28,7 +28,7 @@ def create_map(filtered_df, selected_map_column, zoom, center):
hover_name="date_obs",
hover_data=["localisation_lat", "localisation_long"],
map_style="open-street-map",
color_discrete_map=MAP_SETTINGS[selected_map_column]["color_map"],
color_discrete_map=MAP_COLOR_PALETTES[selected_map_column],
)

fig_map.update_layout(
Expand Down
48 changes: 7 additions & 41 deletions dashboard/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,33 +45,13 @@

ORIENTATIONS = list(ORIENTATIONS_MAPPING.keys())

MAP_SETTINGS = {
"nb_species_cat": {
"title": "Nombre d'espèces",
"color_map": {'<7': 'red', '7-10': 'orange', '11-14': 'yellow', '>14': 'green'}
},
"VDL_cat": {
"title": "VDL",
"color_map": {'<25': 'red', '25-50': 'orange', '50-75': 'yellow', '>75': 'green'}
},
"deg_pollution_acid_cat": {
"title": "Dégré pollution acide",
"color_map": {'0-25%': 'red', '25-50%': 'orange', '50-75%': 'yellow', '75-100%': 'green'}
},
"deg_pollution_azote_cat": {
"title": "Dégré pollution azote",
"color_map": {'0-25%': 'green', '25-50%': 'yellow', '50-75%': 'orange', '75-100%': 'red'}
},
"deg_artif_cat":
{
"title": "Dégré artificialisation",
"color_map": {'0-25%': 'green', '25-50%': 'yellow', '50-75%': 'orange', '75-100%': 'red'}
},
"selected_species_present":
{
"title": "Espèce sélectionnée présente",
"color_map": {True: BASE_COLOR_PALETTE[0], False: BASE_COLOR_PALETTE[-1]}
},
MAP_COLOR_PALETTES = {
"nb_species_cat": {'<7': 'red', '7-10': 'orange', '11-14': 'yellow', '>14': 'green'},
"VDL_cat": {'<25': 'red', '25-50': 'orange', '50-75': 'yellow', '>75': 'green'},
"deg_acidity_cat": {'0-25%': 'red', '25-50%': 'orange', '50-75%': 'yellow', '75-100%': 'green'},
"deg_eutrophication_cat": {'0-25%': 'green', '25-50%': 'yellow', '50-75%': 'orange', '75-100%': 'red'},
"deg_toxitolerance_cat": {'0-25%': 'green', '25-50%': 'yellow', '50-75%': 'orange', '75-100%': 'red'},
"selected_species_present": {True: BASE_COLOR_PALETTE[0], False: BASE_COLOR_PALETTE[-1]},
}


Expand Down Expand Up @@ -111,17 +91,3 @@
"plot_bgcolor": "rgba(0, 0, 0, 0)", # Transparent plot background
"paper_bgcolor": "rgba(0, 0, 0, 0)", # Transparent paper background
}

TRANSLATIONS_EN_FR = {
"unknown": "inconnu",
"acidophilous": "acidophile",
"neutrophilous": "neutrophile",
"basophilous": "basophile",
"oligotrophic": "oligotrophe",
"mesotrophic": "mésotrophe",
"eutrophic": "eutrophe",
"sensitive": "sensible",
"intermediate": "intermédiaire",
"tolerant": "tolérant",
"resistant": "résistant",
}
40 changes: 0 additions & 40 deletions dashboard/demo_dash.py

This file was deleted.

20 changes: 0 additions & 20 deletions dashboard/demo_streamlit.py

This file was deleted.

23 changes: 23 additions & 0 deletions dashboard/utils/translations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import json
import os

def load_translations(lang):
try:
parent_dir = os.path.dirname(os.path.dirname(__file__))
file_path = os.path.join(parent_dir, 'assets', 'locale', f'{lang}.json')
with open(file_path, 'r') as file:
return json.load(file)
except FileNotFoundError:
print(f"Translation file for language '{lang}' not found.")
return {}
except json.JSONDecodeError:
print(f"Error decoding JSON from translation file for language '{lang}'.")
return {}

def get_translation(key, lang='fr'):
try:
translations = load_translations(lang)
return translations.get(key, key)
except Exception as e:
print(f"Error getting translation for key '{key}' in language '{lang}': {e}")
return key
File renamed without changes.
9 changes: 4 additions & 5 deletions my_data/computed_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,17 +199,16 @@ def calc_degrees_pollution(merged_table_with_nb_lichen_df, lichen_df, merged_lic
merged_df = merged_df.fillna(0)

# Calculate the ratio of resistant nb_lichen to total nb_lichen
merged_df['deg_artif'] = merged_df['nb_lichen_resistant'] / merged_df['nb_lichen']
# Add a categorical column based on the number of lichen
merged_df['deg_toxitolerance'] = merged_df['nb_lichen_resistant'] / merged_df['nb_lichen']

# Calculate the degree of acid pollution
merged_df['deg_pollution_acid'] = merged_df['nb_lichen_acid'] / merged_df['nb_lichen']
merged_df['deg_acidity'] = merged_df['nb_lichen_acid'] / merged_df['nb_lichen']

# Calculate the degree of nitrogen (azote in french) pollution
merged_df['deg_pollution_azote'] = merged_df['nb_lichen_eutrophic'] / merged_df['nb_lichen']
merged_df['deg_eutrophication'] = merged_df['nb_lichen_eutrophic'] / merged_df['nb_lichen']

# Add categorical columns
for col in ['deg_artif', 'deg_pollution_acid', 'deg_pollution_azote']:
for col in ['deg_toxitolerance', 'deg_acidity', 'deg_eutrophication']:
merged_df[col + '_cat'] = pd.cut(merged_df[col], bins=[-0.1, 0.25, 0.5, 0.75, np.inf], labels=["0-25%", "25-50%", "50-75%", "75-100%"])

return merged_df
Loading