From b98a6307e95a1b72b4f3d5f4fc14c3f856c7e273 Mon Sep 17 00:00:00 2001 From: TheOafidian Date: Fri, 31 Jan 2025 19:04:52 +0100 Subject: [PATCH 1/6] Add English readme --- README.Rmd | 2 ++ README.en.Rmd | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++ README.en.md | 44 ++++++++++++++++++++++++++++++++++++++++++ README.md | 2 ++ 4 files changed, 101 insertions(+) create mode 100644 README.en.Rmd create mode 100644 README.en.md diff --git a/README.Rmd b/README.Rmd index 0e64e1b..02dc505 100644 --- a/README.Rmd +++ b/README.Rmd @@ -16,6 +16,8 @@ knitr::opts_chunk$set( # VTOOL +[![es](https://img.shields.io/badge/lang-es-yellow.svg)](https://github.com/mticlla/VTOOL/blob/master/README.md) +[![en](https://img.shields.io/badge/lang-en-red.svg)](https://github.com/mticlla/VTOOL/blob/master/README.en.md)

diff --git a/README.en.Rmd b/README.en.Rmd new file mode 100644 index 0000000..799b819 --- /dev/null +++ b/README.en.Rmd @@ -0,0 +1,53 @@ +--- +output: github_document +--- + + + +```{r, include = FALSE} +knitr::opts_chunk$set( + collapse = TRUE, + comment = "#>", + fig.path = "man/figures/README-", + out.width = "100%" +) +``` + +# VTOOL + + +[![es](https://img.shields.io/badge/lang-es-yellow.svg)](https://github.com/jonatasemidio/multilanguage-readme-pattern/blob/master/README.md) + +

+ +VTOOL is a shiny application designed to explore microbial sequencing data with a focus on vaginal microbiota in relation to socio-demographic, clinical or lifestyle factors. + +VTOOL has been developed following a user-centered-design (UCD) approach. + +The initial conceptual approach of VTOOL is as follows: + +![](man/figures/vtool_ventana_1_1.png) + +![](man/figures/vtool_ventana_2_1.png) + +![](man/figures/vtool_ventana_3.png) + +![](man/figures/vtool_ventana_4.png) + +## Install + +To install the development version of VTOOL in R, you can use the following command: + +``` +# install.packages("devtools") #un-comment if devtools not installed already +devtools::install_github("mticlla/VTOOL") +``` + +## Usage + +Once installed, VTOOL can be accessed through a web application or run locally. + +``` +library(VTOOL) +VTOOL::run_app() +``` diff --git a/README.en.md b/README.en.md new file mode 100644 index 0000000..d0d008b --- /dev/null +++ b/README.en.md @@ -0,0 +1,44 @@ + + + +# VTOOL + + +[![es](https://img.shields.io/badge/lang-es-yellow.svg)](https://github.com/jonatasemidio/multilanguage-readme-pattern/blob/master/README.md) + +

+ +

+ +VTOOL is a shiny application designed to explore microbial sequencing +data with a focus on vaginal microbiota in relation to +socio-demographic, clinical or lifestyle factors. + +VTOOL has been developed following a user-centered-design (UCD) +approach. + +The initial conceptual approach of VTOOL is as follows: + +![](man/figures/vtool_ventana_1_1.png) + +![](man/figures/vtool_ventana_2_1.png) + +![](man/figures/vtool_ventana_3.png) + +![](man/figures/vtool_ventana_4.png) + +## Install + +To install the development version of VTOOL in R, you can use the +following command: + + # install.packages("devtools") #un-comment if devtools not installed already + devtools::install_github("mticlla/VTOOL") + +## Usage + +Once installed, VTOOL can be accessed through a web application or run +locally. + + library(VTOOL) + VTOOL::run_app() diff --git a/README.md b/README.md index fe04ab7..e3856af 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ # VTOOL +[![es](https://img.shields.io/badge/lang-es-yellow.svg)](https://github.com/mticlla/VTOOL/blob/master/README.md) +[![en](https://img.shields.io/badge/lang-en-red.svg)](https://github.com/mticlla/VTOOL/blob/master/README.en.md)

From 61600615111212271bffb1ea69ae081b0e504b03 Mon Sep 17 00:00:00 2001 From: TheOaphidian Date: Fri, 7 Feb 2025 17:42:23 +0100 Subject: [PATCH 2/6] Add translator at server and ui side Still need to figure out why it doesn't update the tagged strings! --- DESCRIPTION | 4 +++- NAMESPACE | 1 + R/server.R | 8 ++++++++ R/ui.R | 27 ++++++++++++++++++++++++--- inst/app/translation.json | 18 ++++++++++++++++++ 5 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 inst/app/translation.json diff --git a/DESCRIPTION b/DESCRIPTION index 8d95086..e4fcf10 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -38,4 +38,6 @@ Imports: tidytacos Remotes: github::LebeerLab/tidytacos, - github::daattali/shinycssloaders + github::daattali/shinycssloaders, + github::Appsilon/shiny.i18n + diff --git a/NAMESPACE b/NAMESPACE index 4654a4a..f777895 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -4,4 +4,5 @@ export(run_app) import(ggplot2) import(magrittr) import(shiny) +import(shiny.i18n) importFrom(shiny,shinyApp) diff --git a/R/server.R b/R/server.R index 1cb7edc..665c3a9 100644 --- a/R/server.R +++ b/R/server.R @@ -1,4 +1,12 @@ +translator <- Translator$new(translation_json_path = "inst/app/translation.json") + server <- function(input, output, session){ + + observeEvent(input$selected_language, { + cat("Lang updated to:", input$selected_language, "\n") + shiny.i18n::update_lang(input$selected_language) + }) + my_color_palette <- c("#00719A","#FCD0BE","#413647","#FF9A73","#063547", "#992B00","#F3D9AE","#6991B3","#B8062F","#BDECFC", "#D3D3D3") diff --git a/R/ui.R b/R/ui.R index f4000df..cac6e59 100644 --- a/R/ui.R +++ b/R/ui.R @@ -1,10 +1,16 @@ +i18n <- shiny.i18n::Translator$new(translation_json_path = "inst/app/translation.json") +i18n$set_translation_language("es") + #' The Application User-Interface #' #' @param request Internal parameter for `{shiny}`. #' -#' @import shiny magrittr +#' @import shiny magrittr shiny.i18n +#' @importFrom shiny.i18n t #' @noRd ui <- function(request){ + shiny.i18n::usei18n(i18n) + #shiny::addResourcePath('www', fs::path_package("app/www", package='VTOOL')) # Value boxes my_data_value_boxes <- list( @@ -101,10 +107,11 @@ ui <- function(request){ )), # The tabs inside the navigation bar #################################### + # First tab #---------- bslib::nav_panel( - title = "Inicio", + title = i18n$t("Inicio"), value = "start", # The card with content bslib::card_body(fillable = FALSE, @@ -117,7 +124,7 @@ ui <- function(request){ style="margin-left:0px;padding-left:0px"), tags$h3(class = 'jumbotron-heading', stye = 'margin-bottom:0px;margin-top:0px', - 'Un explorador de datos para estudiar el microbioma vaginal'), + i18n$t('Un explorador de datos para estudiar el microbioma vaginal')), #p(lorem::ipsum(paragraphs = 2, sentences = 5)) br(), p("VTOOL es una herramienta basada en Shiny para el análisis @@ -535,6 +542,20 @@ ui <- function(request){ ) ) ) + ), + # LANG + # LANG TAB + bslib::nav_spacer(), + bslib::nav_item( + align="right", + shinyWidgets::pickerInput("selected_language", + i18n$t("Cambiar idioma"), + choices = i18n$get_languages(), + selected = i18n$get_key_translation(), + multiple = FALSE, + options = list(container = "nav") + #TODO: figure out how to make this select act normal + ) ) ) } diff --git a/inst/app/translation.json b/inst/app/translation.json new file mode 100644 index 0000000..1d64b57 --- /dev/null +++ b/inst/app/translation.json @@ -0,0 +1,18 @@ +{ + "languages" : ["es", "en", "nl"], + "translation" : [ + { "en": "Start", + "es": "Inicio", + "nl": "Begin" + }, + { "en": "Change language", + "es": "Cambiar idioma", + "nl": "Verander taal" + }, + { + "es": "Un explorador de datos para estudiar el microbioma vaginal", + "en": "A tool to explore data to study the vaginal microbiome", + "nl": "Een dataverkenner om het vaginale microbioom te bestuderen" + } + ] +} From f97acf11eaede34477c17048fe81905688e957e5 Mon Sep 17 00:00:00 2001 From: TheOaphidian Date: Mon, 10 Feb 2025 12:04:52 +0100 Subject: [PATCH 3/6] Add usei18n to components to pass on language --- DESCRIPTION | 1 - R/run_app.R | 11 +++- R/server.R | 7 +-- R/ui.R | 37 ++++++++------ inst/app/translation.json | 65 ++++++++++++++++++++++++ inst/app/translation/translation_en.csv | 3 ++ inst/app/www/favicon.ico | Bin 0 -> 3902 bytes man/run_app.Rd | 8 ++- 8 files changed, 109 insertions(+), 23 deletions(-) create mode 100644 inst/app/translation/translation_en.csv create mode 100644 inst/app/www/favicon.ico diff --git a/DESCRIPTION b/DESCRIPTION index e4fcf10..8e57c7a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -40,4 +40,3 @@ Remotes: github::LebeerLab/tidytacos, github::daattali/shinycssloaders, github::Appsilon/shiny.i18n - diff --git a/R/run_app.R b/R/run_app.R index 2b3c29f..d6e0042 100644 --- a/R/run_app.R +++ b/R/run_app.R @@ -2,6 +2,13 @@ #' #' @export #' @importFrom shiny shinyApp -run_app <- function(){ - shinyApp(ui = ui, server = server) +#' @importFrom golem with_golem_options +run_app <- function(onStart=NULL, options=list(), enableBookmarking=NULL){ + shinyApp( + ui = ui, + server = server, + onStart = onStart, + options = options, + enableBookmarking = enableBookmarking, + ) } diff --git a/R/server.R b/R/server.R index 665c3a9..9adaad4 100644 --- a/R/server.R +++ b/R/server.R @@ -1,10 +1,11 @@ -translator <- Translator$new(translation_json_path = "inst/app/translation.json") +i18n <- shiny.i18n::Translator$new(translation_json_path = "inst/app/translation.json") +i18n$set_translation_language("es") server <- function(input, output, session){ observeEvent(input$selected_language, { - cat("Lang updated to:", input$selected_language, "\n") - shiny.i18n::update_lang(input$selected_language) + shiny.i18n::update_lang(input$selected_language, session = session) + #cat("Lang updated to:", input$selected_language, "\n") }) my_color_palette <- c("#00719A","#FCD0BE","#413647","#FF9A73","#063547", diff --git a/R/ui.R b/R/ui.R index cac6e59..f304479 100644 --- a/R/ui.R +++ b/R/ui.R @@ -9,13 +9,12 @@ i18n$set_translation_language("es") #' @importFrom shiny.i18n t #' @noRd ui <- function(request){ - shiny.i18n::usei18n(i18n) - - #shiny::addResourcePath('www', fs::path_package("app/www", package='VTOOL')) + # Value boxes my_data_value_boxes <- list( bslib::value_box( - title = "Nr. de Muestras", + shiny.i18n::usei18n(i18n), + title = i18n$t("Nr. de Muestras"), value = textOutput("total_sample"), showcase = icon("vial")#, #p("Some text"), @@ -24,14 +23,16 @@ ui <- function(request){ #theme = "success" ), bslib::value_box( - title = "Nr. de Taxones", + shiny.i18n::usei18n(i18n), + title = i18n$t("Nr. de Taxones"), value = textOutput("total_taxa"), showcase = icon("bacteria")#, #p("Some text"), #p("More text ...") ), bslib::value_box( - title = "Lecturas Totales", + shiny.i18n::usei18n(i18n), + title = i18n$t("Lecturas Totales"), value = textOutput("total_reads"), showcase = icon("dna")#, #p("Some text"), @@ -47,14 +48,15 @@ ui <- function(request){ theme = bslib::bs_theme(version = 5, preset = "yeti", primary = "#00719a"), # The Main sidebar sidebar = bslib::sidebar( + shiny.i18n::usei18n(i18n), id = "my_sidebar", - title = span(bsicons::bs_icon("funnel"), "Filtrar Datos", class = "sidebar-title"), + title = span(bsicons::bs_icon("funnel"), i18n$t("Filtrar Datos"), class = "sidebar-title"), open = FALSE, bg = "white", bslib::accordion( open = FALSE, bslib::accordion_panel( - title ="Filtrar muestras", + title = "Filtrar muestras", icon = icon("vial"), sliderInput( "sample_total_count", @@ -99,11 +101,11 @@ ui <- function(request){ ), actionButton( "input_apply_filter", - label = "Filtrar" + label = i18n$t("Filtrar") ), actionButton( "input_clean_filter", - label = "Remover filtros" + label = i18n$t("Remover filtros") )), # The tabs inside the navigation bar #################################### @@ -111,6 +113,7 @@ ui <- function(request){ # First tab #---------- bslib::nav_panel( + #shiny.i18n::usei18n(i18n), title = i18n$t("Inicio"), value = "start", # The card with content @@ -186,7 +189,7 @@ ui <- function(request){ )) ), bslib::nav_panel( - title = "Datos", + title = i18n$t("Datos"), value = "my_data", # the card with content bslib::layout_column_wrap( @@ -200,7 +203,7 @@ ui <- function(request){ id="my_data_tabs", # Muestras y metadata bslib::nav_panel( - title = "Muestras y metadata", + title = i18n$t("Muestras y metadata"), bslib::navset_underline(id="my_samples_navbar", bslib::nav_panel("Explorar Tabla", bslib::card( @@ -255,7 +258,7 @@ ui <- function(request){ bslib::nav_spacer()) ), bslib::nav_panel( - title = "Taxones y metadata", + title = i18n$t("Taxones y metadata"), bslib::card( full_screen = TRUE, bslib::layout_sidebar( @@ -277,7 +280,7 @@ ui <- function(request){ )) ), bslib::nav_panel( - title = "Abundancias", + title = i18n$t("Abundancias"), bslib::card( full_screen = TRUE, bslib::layout_sidebar( @@ -296,14 +299,15 @@ ui <- function(request){ # 3rd tab #---------- bslib::nav_panel( - title = "Composición", + title = i18n$t("Composición"), value = "my_community", bslib::navset_pill( id="my_community_tabs", # Dominant taxa #-------------- bslib::nav_panel( - title = "Taxón dominante", + #shiny.i18n::usei18n(i18n), + title = i18n$t("Taxón dominante"), bslib::layout_sidebar( border = FALSE, sidebar = bslib::sidebar(id="my_dominant_taxa_sidebar", @@ -547,6 +551,7 @@ ui <- function(request){ # LANG TAB bslib::nav_spacer(), bslib::nav_item( + #shiny.i18n::usei18n(i18n), align="right", shinyWidgets::pickerInput("selected_language", i18n$t("Cambiar idioma"), diff --git a/inst/app/translation.json b/inst/app/translation.json index 1d64b57..1905d6e 100644 --- a/inst/app/translation.json +++ b/inst/app/translation.json @@ -13,6 +13,71 @@ "es": "Un explorador de datos para estudiar el microbioma vaginal", "en": "A tool to explore data to study the vaginal microbiome", "nl": "Een dataverkenner om het vaginale microbioom te bestuderen" + }, + { + "es" : "Filtrar muestras", + "en" : "Filter samples", + "nl" : "Filter stalen" + }, + { + "es": "Nr. de Muestras", + "en" : "Amount of samples", + "nl": "Aantal stalen" + }, + { + "es" : "Nr. de Taxones", + "en" : "Amount of taxa", + "nl" : "Aantal taxa" + }, + { + "es" : "Lecturas Totales", + "en" : "Total reads", + "nl" : "Totaal aantal sequenties" + }, + { + "es" : "Datos", + "en" : "Data", + "nl" : "Data" + }, + { + "es" : "Muestras y metadata", + "en" : "Samples and metadata", + "nl" : "Stalen en metadata" + }, + { + "es" : "Taxones y metadata", + "en" : "Taxa and metadata", + "nl" : "Taxa en metadata" + }, + { + "es" : "Abundancias", + "en" : "Abundancy", + "nl" : "Abundantie" + }, + { + "es" : "Composición", + "en" : "Composition", + "nl" : "Compositie" + }, + { + "es" : "Taxón dominante", + "en" : "Dominant taxa", + "nl" : "Dominante taxa" + }, + { + "es" : "Filtrar Datos", + "en" : "Filter Data", + "nl" : "Data Filteren" + }, + { + "es" : "Filtrar", + "en": "Filter", + "nl" : "Filteren" + }, + { + "es" : "Remover filtros", + "en" : "Remove filters", + "nl" : "Verwijder filters" } ] } diff --git a/inst/app/translation/translation_en.csv b/inst/app/translation/translation_en.csv new file mode 100644 index 0000000..668e3fa --- /dev/null +++ b/inst/app/translation/translation_en.csv @@ -0,0 +1,3 @@ +es,en +Inicio,Start +Cambiar idioma,Change language diff --git a/inst/app/www/favicon.ico b/inst/app/www/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..6f7aa1e39847cb72c03614766fba1e3448dc4485 GIT binary patch literal 3902 zcmdT{2~d?)6#l`~Y!pI^vDC7~(weX)%a+M#tZ}9qr>3T9+Gkp)#S{faLC|suF%6f; z^4LLT-&a{g2o)4H1rc0OmSh##_pfu#&wGG8S|yV2fKi@v_zf5qdb`inRm zYm102b8$RvBifp-+%nwGwyP-0bw}9d$KbKl1Rg&s@LXn!=xy_H{&)zwyIOA=c5hE7 z%FiStLGv2CmX9So#u}K6?QJ^&`~BWU^~GHD_4fR8?7luURGq@XkT2kCZ{8o*0M=k! z-ZOT9qowfPRDWUAxNS{;O0M>-zhA|=F1G9Obl;f+<~?-t92EVo0q0|+(cRgKa|L@5 zwe4BS)c}vC@Uj^*gi{@kp_QNGJS1pd#pN?e;QS09eW)%wg#EtnNN!Yps62Yv+=l4w z&tdORGvQ}%W*E1h2k~*x-ktdNSvd(=`#wj*mBJygT^-Gc-LU}fONQo)vEz3y#F1D# z(U7;@9m6!lar&*klYAYIK&Pn)aF`;#1+SYkJS(+^Az^WcJh108;^`&iC#(@pa-)_K zz7ujHz7w7_-z!Kp0+VyWyf)RHM^5;+2zH*1FqbC~zsnj`=MJEvBn_dP=12^B%tXSB zvx8tJtC$Izg)kPAbIDvbHY7eqfCXZ)^LkQ=##Fk8rn*WtfrGW9Am zig_Y@NZZ;K<3+Pt+i_xp>%o|OGA8FVBj_VE)|@3>KSP)gitmXYi-d2!&$xEkrqm`q zqwf*KlWxy;jKyR-LC(`qUwIM*DeIBu{~l>+8pUNHe6}@JBizMmSdHnhbn9p^)n`ml zlIM?0g>htmuJk}H^|e1TU4`2e@5TB!y=+W{OYMrW@YLUTDqqIN$(Zb8exf7Q=@E)= zig4()d<@mTjl3&dt1ZQ;tnJj(cT4Us7bW1ri7=eZa3S3<5FbaAPsZe$DM)X!0PaJq=NPva#fH&wl6{|*6T!ac#oOyO zq03W%!(GxdS<@jKA3>nw-J)T>58`&djPNa1bY@A~;PGIo(5jdY8Vx>o)xUSamKF$=WwXd%mm8r3V;#2O7%7KphS~XB}`}GO506 z%a8r-dnwcd0!Qg?;GV!f8-vAo zAsc2%?R2!%jfi3B2mGF1S5Y8$FY|OGY(D4O Date: Mon, 10 Feb 2025 13:46:36 +0100 Subject: [PATCH 4/6] Add xlsx::json conversion tool --- inst/app/conversion.py | 44 ++++++ inst/app/translation.json | 305 ++++++++++++++++++++++++++++---------- 2 files changed, 267 insertions(+), 82 deletions(-) create mode 100644 inst/app/conversion.py diff --git a/inst/app/conversion.py b/inst/app/conversion.py new file mode 100644 index 0000000..087a564 --- /dev/null +++ b/inst/app/conversion.py @@ -0,0 +1,44 @@ +import json +import pandas as pd + +def excel_to_json(filepath): + df = pd.read_excel(filepath) + df = df.fillna("TODO") + outf = "/".join(filepath.split(".")[:-1]) + ".json" + translations = df.to_dict(orient="records") + + data = dict( + languages = df.columns.to_list(), + translation = translations + ) + with open(outf, "w", encoding="utf-8") as f: + json.dump(data, f, ensure_ascii=False, indent=4) + + +def json_to_excel(filepath): + with open(filepath) as f: + data = json.load(f) + df = pd.DataFrame(data["translation"]) + outf = "/".join(filepath.split(".")[:-1]) + ".xlsx" + df.to_excel(outf, index=False) + +if __name__ == "__main__": + import sys + import os + if len(sys.argv) < 2: + print("Please choose a file to convert") + exit(0) + filepath = sys.argv[1] + if not os.path.exists(filepath): + print(f"File {filepath} does not exist") + exit(0) + + ext = filepath.split(".")[-1] + + if ext == 'json': + json_to_excel(filepath) + elif ext == "xlsx": + excel_to_json(filepath) + else: + raise ValueError(f"Filetype {ext} not supported") + \ No newline at end of file diff --git a/inst/app/translation.json b/inst/app/translation.json index 1905d6e..3b1fc9a 100644 --- a/inst/app/translation.json +++ b/inst/app/translation.json @@ -1,83 +1,224 @@ { - "languages" : ["es", "en", "nl"], - "translation" : [ - { "en": "Start", - "es": "Inicio", - "nl": "Begin" - }, - { "en": "Change language", - "es": "Cambiar idioma", - "nl": "Verander taal" - }, - { - "es": "Un explorador de datos para estudiar el microbioma vaginal", - "en": "A tool to explore data to study the vaginal microbiome", - "nl": "Een dataverkenner om het vaginale microbioom te bestuderen" - }, - { - "es" : "Filtrar muestras", - "en" : "Filter samples", - "nl" : "Filter stalen" - }, - { - "es": "Nr. de Muestras", - "en" : "Amount of samples", - "nl": "Aantal stalen" - }, - { - "es" : "Nr. de Taxones", - "en" : "Amount of taxa", - "nl" : "Aantal taxa" - }, - { - "es" : "Lecturas Totales", - "en" : "Total reads", - "nl" : "Totaal aantal sequenties" - }, - { - "es" : "Datos", - "en" : "Data", - "nl" : "Data" - }, - { - "es" : "Muestras y metadata", - "en" : "Samples and metadata", - "nl" : "Stalen en metadata" - }, - { - "es" : "Taxones y metadata", - "en" : "Taxa and metadata", - "nl" : "Taxa en metadata" - }, - { - "es" : "Abundancias", - "en" : "Abundancy", - "nl" : "Abundantie" - }, - { - "es" : "Composición", - "en" : "Composition", - "nl" : "Compositie" - }, - { - "es" : "Taxón dominante", - "en" : "Dominant taxa", - "nl" : "Dominante taxa" - }, - { - "es" : "Filtrar Datos", - "en" : "Filter Data", - "nl" : "Data Filteren" - }, - { - "es" : "Filtrar", - "en": "Filter", - "nl" : "Filteren" - }, - { - "es" : "Remover filtros", - "en" : "Remove filters", - "nl" : "Verwijder filters" - } - ] -} + "languages": [ + "en", + "es", + "nl" + ], + "translation": [ + { + "en": "Select the format of the input", + "es": "1. Selecciona el formato del archivo:", + "nl": "Selecteer het formaat van de input" + }, + { + "en": "TODO", + "es": "2. Encuentra tu(s) archivos:", + "nl": "TODO" + }, + { + "en": "Abundancy", + "es": "Abundancias", + "nl": "Abundantie" + }, + { + "en": "Change language", + "es": "Cambiar idioma", + "nl": "Verander taal" + }, + { + "en": "Composition", + "es": "Composición", + "nl": "Compositie" + }, + { + "en": "Data", + "es": "Datos", + "nl": "Data" + }, + { + "en": "Let's start with uploading your data", + "es": "Empezemos cargando tus datos", + "nl": "Laten we beginnen met de upload van jouw data" + }, + { + "en": "Filter", + "es": "Filtrar", + "nl": "Filteren" + }, + { + "en": "Filter Data", + "es": "Filtrar Datos", + "nl": "Data Filteren" + }, + { + "en": "Filter samples", + "es": "Filtrar muestras", + "nl": "Filter stalen" + }, + { + "en": "Format", + "es": "Formato:", + "nl": "Formaat" + }, + { + "en": "Start", + "es": "Inicio", + "nl": "Begin" + }, + { + "en": "Total reads", + "es": "Lecturas Totales", + "nl": "Totaal aantal sequenties" + }, + { + "en": "Samples", + "es": "Muestras", + "nl": "Stalen" + }, + { + "en": "Samples and metadata", + "es": "Muestras y metadata", + "nl": "Stalen en metadata" + }, + { + "en": "Amount of samples", + "es": "Nr. de Muestras", + "nl": "Aantal stalen" + }, + { + "en": "Amount of taxa", + "es": "Nr. de Taxones", + "nl": "Aantal taxa" + }, + { + "en": "Remove filters", + "es": "Remover filtros", + "nl": "Verwijder filters" + }, + { + "en": "Dominant taxa", + "es": "Taxón dominante", + "nl": "Dominante taxa" + }, + { + "en": "Taxa and metadata", + "es": "Taxones y metadata", + "nl": "Taxa en metadata" + }, + { + "en": "A tool to explore data to study the vaginal microbiome", + "es": "Un explorador de datos para estudiar el microbioma vaginal", + "nl": "Een dataverkenner om het vaginale microbioom te bestuderen" + }, + { + "en": "Taxonomy", + "es": "Taxonomia", + "nl": "Taxonomie" + }, + { + "en": "Import data", + "es": "Importar datos", + "nl": "Importeer data" + }, + { + "en": "Or load an example dataset", + "es": "O carga un dataset ejemplo", + "nl": "Of laad een voorbeel dataset in" + }, + { + "en": "Load example", + "es": "Cargar ejemplo", + "nl": "Laad voorbeeld" + }, + { + "en": "VTOOL is a tool for exploratory data analysis based on Shiny. Through an interactive and intuitive interface, this tool aims to facilitate the exploration and visualization of data associated with the study of the vaginal microbiome.", + "es": "VTOOL es una herramienta basada en Shiny para el análisis exploratorio de datos. A través de una interface interactiva e intuitiva, esta herramienta busca facilitar la exploración y visualización de datos asociados al estudio del microbioma vaginal.", + "nl": "VTOOL is een applicatie voor de visualisatie en verkenning van data gebaseerd op Shiny. Met behulp van een intuitieve en interactieve interface, wil deze tool het verkennen en weergeven van data geassocieerd met het bestuderen van het vaginale microbioom faciliteren." + }, + { + "en": "VTOOL is an open source project, developed in collaboration with researchers and bioninformaticians, who seek to further the study of the vaginal microbiome. If you are interested in contributing, reporting bugs, or learning more about this project please visit our GitHub repository.", + "es": "VTOOL es un proyecto de código abierto (open source), desarrollado en colaboración con investigadores y bioninformáticos, quienes buscan fomentar el estudio del microbioma vaginal. Si te interesa contribuir, reportar errores, o saber más de este proyecto, por favor visita nuestro repositorio en GitHub .", + "nl": "VTOOL is een open source project, ontwikkeld in nauwe samenwerking met onderzoekers en bio-informatici, die de studie van het vaginale microbioom willen bevorderen. Als je geïnteresseerd bent om bij te dragen, bugs te rapporteren of meer te weten te komen over dit project, bezoek dan onze GitHub repository." + }, + { + "en": "No file selected", + "es": "Ningun archivo seleccionado", + "nl": "Geen bestand geselecteerd" + }, + { + "en": "Explore table", + "es": "Explorar Tabla", + "nl": "Verken de tabel" + }, + { + "en": "TODO", + "es": "Data Faltante", + "nl": "TODO" + }, + { + "en": "TODO", + "es": "Esta vista te permite explorar las muestras y su metadata.", + "nl": "TODO" + }, + { + "en": "TODO", + "es": "Esta vista permite explorar patrones de valores faltantes (NA) en la tabla de muestras. El gráfico que mostramos es una representación gráfica de la tabla, donde las celdas que contienen valores son de color gris claro y las celdas con valores faltantes son de color gris oscuro .\n", + "nl": "TODO" + }, + { + "en": "TODO", + "es": "Además, el orden de las filas y las columnas ha sido re-organizado de tal modo que muestras con valores faltantes en las mismas columnas son agrupadas. De igual manera, columnas con valores faltantes en las mismas muestras son agrupadas.", + "nl": "TODO" + }, + { + "en": "TODO", + "es": "Esta vista te permite explorar las taxa y su metadata.", + "nl": "TODO" + }, + { + "en": "TODO", + "es": "Esta vista te permite explorar la abundancia de cada taxón en cada muestra.", + "nl": "TODO" + }, + { + "en": "Profiles", + "es": "Perfiles", + "nl": "Profielen" + }, + { + "en": "Show legend", + "es": "Mostrar legend", + "nl": "Toon legende" + }, + { + "en": "Group participants by variable", + "es": "Agrupar participantes según variable", + "nl": "Groepeer participanten adhv variabele" + }, + { + "en": "Group by taxonomical categorie", + "es": "Agrupar por categoría taxonómica", + "nl": "Groepeer obv taxonomie" + }, + { + "en": "Stratify by variable", + "es": "Estratificar por variable", + "nl": "Stratificeer adhv variabele" + }, + { + "en": "Upload the table 'samples.csv'", + "es": "Carga la tabla 'samples.csv'", + "nl": "Laad de tabel 'samples.csv' op" + }, + { + "en": "Upload the table 'counts.csv' or 'abundances.csv'", + "es": "Carga la tabla 'counts.csv' o 'abundances.csv'", + "nl": "Laad de tabel 'counts.csv' of 'abundances.csv' op" + }, + { + "en": "Upload the table 'taxa.csv'", + "es": "Carga la table 'taxa.csv'", + "nl": "Laad de tabel 'taxa.csv' op" + } + ] +} \ No newline at end of file From f305c3f242d37423f41106756dbab9b9ffff40cd Mon Sep 17 00:00:00 2001 From: TheOaphidian Date: Mon, 10 Feb 2025 14:00:14 +0100 Subject: [PATCH 5/6] ES needs to be first in list --- inst/app/conversion.py | 9 ++++++--- inst/app/translation.json | 28 ++++++++++++++-------------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/inst/app/conversion.py b/inst/app/conversion.py index 087a564..7b855a0 100644 --- a/inst/app/conversion.py +++ b/inst/app/conversion.py @@ -6,9 +6,12 @@ def excel_to_json(filepath): df = df.fillna("TODO") outf = "/".join(filepath.split(".")[:-1]) + ".json" translations = df.to_dict(orient="records") - + lang = df.columns.to_list() + lang.pop("es") + # needs to be first! + lang.insert(0, "es") data = dict( - languages = df.columns.to_list(), + languages = lang, translation = translations ) with open(outf, "w", encoding="utf-8") as f: @@ -41,4 +44,4 @@ def json_to_excel(filepath): excel_to_json(filepath) else: raise ValueError(f"Filetype {ext} not supported") - \ No newline at end of file + diff --git a/inst/app/translation.json b/inst/app/translation.json index 3b1fc9a..4cab94c 100644 --- a/inst/app/translation.json +++ b/inst/app/translation.json @@ -1,7 +1,7 @@ { "languages": [ - "en", "es", + "en", "nl" ], "translation": [ @@ -11,9 +11,9 @@ "nl": "Selecteer het formaat van de input" }, { - "en": "TODO", + "en": "2. Search for your file(s):", "es": "2. Encuentra tu(s) archivos:", - "nl": "TODO" + "nl": "2. Zoek je bestand(en):" }, { "en": "Abundancy", @@ -151,34 +151,34 @@ "nl": "Verken de tabel" }, { - "en": "TODO", + "en": "Missing values", "es": "Data Faltante", - "nl": "TODO" + "nl": "Ontbrekende gegevens" }, { - "en": "TODO", + "en": "Here you can view the samples and their metadata", "es": "Esta vista te permite explorar las muestras y su metadata.", - "nl": "TODO" + "nl": "Hier kan je de stalen en metadata bekijken" }, { - "en": "TODO", + "en": "This view allows you to explore patterns of missing values (NA) in the sample table. The graph shown is a graphical representation of the table, where cells containing values are light gray and cells with missing values are dark gray.", "es": "Esta vista permite explorar patrones de valores faltantes (NA) en la tabla de muestras. El gráfico que mostramos es una representación gráfica de la tabla, donde las celdas que contienen valores son de color gris claro y las celdas con valores faltantes son de color gris oscuro .\n", - "nl": "TODO" + "nl": "Met deze weergave kun je patronen van ontbrekende waarden (NA) in de voorbeeldtabel onderzoeken. De weergegeven grafiek is een grafische weergave van de tabel, waarbij cellen met waarden lichtgrijs zijn en cellen met ontbrekende waarden donkergrijs." }, { - "en": "TODO", + "en": "In addition, the order of the rows and columns has been rearranged so that samples with missing values in the same columns are grouped together. Similarly, columns with missing values in the same samples are grouped together.", "es": "Además, el orden de las filas y las columnas ha sido re-organizado de tal modo que muestras con valores faltantes en las mismas columnas son agrupadas. De igual manera, columnas con valores faltantes en las mismas muestras son agrupadas.", - "nl": "TODO" + "nl": "Daarnaast is de volgorde van rijen en kolommen herschikt, zodat steekproeven met ontbrekende waarden in dezelfde kolommen zijn gegroepeerd. Op dezelfde manier zijn kolommen met ontbrekende waarden in dezelfde steekproeven gegroepeerd." }, { - "en": "TODO", + "en": "Here you can view the taxa and their metadata", "es": "Esta vista te permite explorar las taxa y su metadata.", "nl": "TODO" }, { - "en": "TODO", + "en": "In this view you can explore the abundance of each taxa in each sample", "es": "Esta vista te permite explorar la abundancia de cada taxón en cada muestra.", - "nl": "TODO" + "nl": "In dit venster kan je de aanwezigheid van specifieke taxa in elk staal visualizeren" }, { "en": "Profiles", From c164ad9fbf404c37e80daf6f6c4e58abded7f8b3 Mon Sep 17 00:00:00 2001 From: TheOaphidian Date: Mon, 10 Feb 2025 14:33:19 +0100 Subject: [PATCH 6/6] Add a few more translations --- R/server.R | 14 ++++++--- R/ui.R | 63 ++++++++++++++------------------------- inst/app/translation.json | 41 ++++++++++++++++++++----- 3 files changed, 65 insertions(+), 53 deletions(-) diff --git a/R/server.R b/R/server.R index 9adaad4..6f53456 100644 --- a/R/server.R +++ b/R/server.R @@ -3,8 +3,13 @@ i18n$set_translation_language("es") server <- function(input, output, session){ + # i18n_r <- reactive({ + # i18n + # }) + observeEvent(input$selected_language, { shiny.i18n::update_lang(input$selected_language, session = session) + #i18n_r()$set_translation_language(input$selected_language) #cat("Lang updated to:", input$selected_language, "\n") }) @@ -30,11 +35,12 @@ server <- function(input, output, session){ ) my_data_sidebar_fileinput_tables <- bslib::card_body( + shiny.i18n::usei18n(i18n), fillable = FALSE, fileInput("my_data_samples", - label = span("Muestras", + label = span(i18n$t("Muestras"), bslib::tooltip(bsicons::bs_icon("info-circle"), - "Carga la tabla 'samples.csv'", + i18n$t("Carga la tabla 'samples.csv'"), placement = "right")), #buttonLabel = "Buscar 'samples.csv'", buttonLabel = bsicons::bs_icon("upload"), @@ -76,7 +82,7 @@ server <- function(input, output, session){ buttonLabel = bsicons::bs_icon("upload"), accept = c(".biom"), width = "100%", - placeholder = "Ningún archivo seleccionado" + placeholder = i18n$t("Ningún archivo seleccionado") ) ) ) @@ -1132,7 +1138,7 @@ server <- function(input, output, session){ xref="paper", xanchor="left", showarrow=FALSE) %>% plotly::layout(barmode = "stack", - xaxis = list(title = "Muestras", showticklabels=FALSE), + xaxis = list(title = i18n$t("Muestras"), showticklabels=FALSE), yaxis = list(title = "Abundancia Relativa"), legend = list(title = list(text = "Taxón"))) }) diff --git a/R/ui.R b/R/ui.R index f304479..84ee0a0 100644 --- a/R/ui.R +++ b/R/ui.R @@ -60,7 +60,7 @@ ui <- function(request){ icon = icon("vial"), sliderInput( "sample_total_count", - label = "Lecturas totales mínimo", + label = i18n$t("Lecturas totales mínimo"), min = 1, max = 10000, value = 1 @@ -74,7 +74,7 @@ ui <- function(request){ placeholder = "Enter Sample_ID")) ), bslib::accordion_panel( - title = "Filtrar taxones", + title = "Filtrar taxones", # can't wrap this in i18n$t()... icon = icon("bacteria"), sliderInput( inputId = "taxa_mean_ra", @@ -130,47 +130,38 @@ ui <- function(request){ i18n$t('Un explorador de datos para estudiar el microbioma vaginal')), #p(lorem::ipsum(paragraphs = 2, sentences = 5)) br(), - p("VTOOL es una herramienta basada en Shiny para el análisis - exploratorio de datos. A través de una interface - interactiva e intuitiva, esta herramienta busca facilitar - la exploración y visualización de datos asociados al estudio - del microbioma vaginal."), + p(i18n$t("VTOOL es una herramienta basada en Shiny para el análisis exploratorio de datos. A través de una interface interactiva e intuitiva, esta herramienta busca facilitar la exploración y visualización de datos asociados al estudio del microbioma vaginal.")), br(), - p("VTOOL es un proyecto de código abierto (open source), - desarrollado en colaboración con investigadores y bioninformáticos, - quienes buscan fomentar el estudio del microbioma vaginal. - Si te interesa contribuir, reportar errores, o saber más de - este proyecto, por favor", - tags$a(href="https://github.com/mticlla/vtool", "visita nuestro - repositorio en GitHub"), ".", .noWS = "outside") + p(i18n$t("VTOOL es un proyecto de código abierto (open source), esarrollado en colaboración con investigadores y bioninformáticos, quienes buscan fomentar el estudio del microbioma vaginal. Si te interesa contribuir, reportar errores, o saber más de este proyecto, por favor"), + tags$a(href="https://github.com/mticlla/vtool", i18n$t("visita nuestro repositorio en GitHub")), ".", .noWS = "outside") ), # Second element bslib::card_body( fillable = FALSE, fill = FALSE, tags$h3(class = 'jumbotron-heading', 'Empezemos cargando tus datos'), - p("1. Selecciona el formato del archivo:"), + p(i18n$t("1. Selecciona el formato del archivo:")), shinyWidgets::awesomeRadio( "input_format", label = "Formato:", choices = c("Tidytacos", "Biom"), selected = "Tidytacos", inline = T), # tags$br(), - p("2. Encuentra tu(s) archivos:"), + p(i18n$t("2. Encuentra tu(s) archivos:")), uiOutput("load_file_options"), tags$br(), actionButton( "input_my_data", - label = "Importar datos", + label = i18n$t("Importar datos"), width = "100%", disabled = FALSE ) %>% bslib::tooltip("¡No olvides cargar tus archivos antes de presionar este botón!"), tags$br(), tags$br(), - tags$h3(class = 'jumbotron-heading', 'O carga un dataset ejemplo'), + tags$h3(class = 'jumbotron-heading', i18n$t('O carga un dataset ejemplo')), actionButton( "input_example", - label = "Cargar ejemplo", + label = i18n$t("Cargar ejemplo"), width = "100%" ), tags$br(), tags$br() @@ -205,7 +196,7 @@ ui <- function(request){ bslib::nav_panel( title = i18n$t("Muestras y metadata"), bslib::navset_underline(id="my_samples_navbar", - bslib::nav_panel("Explorar Tabla", + bslib::nav_panel(i18n$t("Explorar Tabla"), bslib::card( class="table-responsive", full_screen = TRUE, @@ -214,7 +205,7 @@ ui <- function(request){ position = "right", width = 400, open = FALSE, - tags$span(strong("Variable seleccionada: "), + tags$span(strong(i18n$t("Variable seleccionada: ")), textOutput("my_col_name")), #textOutput("my_col_name"), uiOutput("my_sample_col_plot_options"), @@ -224,31 +215,21 @@ ui <- function(request){ caption = "Cargando gráfico")) ), - p("Esta vista te permite explorar las muestras y su metadata."), + p(i18n$t("Esta vista te permite explorar las muestras y su metadata.")), DT::dataTableOutput(outputId = "my_samples", width = "100%") %>% shinycssloaders::withSpinner(color="#00719a", caption = "Cargando tabla") )) ), - bslib::nav_panel("Data Faltante", value = "my_samples_na_tab", + bslib::nav_panel(i18n$t("Data Faltante"), value = "my_samples_na_tab", bslib::card( full_screen = TRUE, #card_header("Data Faltante"), tags$span(class = "text-left", - p("Esta vista permite explorar patrones - de valores faltantes (NA) en la tabla de - muestras. El gráfico que mostramos es - una representación gráfica de la tabla, - donde las celdas que contienen valores son - de color ", - span("gris claro", style="color:#333333;"), - " y las celdas con valores faltantes son - de color", - span("gris oscuro", style="color:#cccccc;"),"."), - p("Además, el orden de las filas y las columnas - ha sido re-organizado de tal modo que muestras - con valores faltantes en las mismas columnas son - agrupadas. De igual manera, columnas con valores - faltantes en las mismas muestras son agrupadas.") + p(i18n$t("Esta vista permite explorar patrones de valores faltantes (NA) en la tabla de muestras. El gráfico que mostramos es una representación gráfica de la tabla, donde las celdas que contienen valores son de color"), + span(i18n$t("gris claro"), style="color:#333333;"), + i18n$t("y las celdas con valores faltantes son de color"), " ", + span(i18n$t("gris oscuro"), style="color:#cccccc;"),"."), + p(i18n$t("Además, el orden de las filas y las columnas ha sido re-organizado de tal modo que muestras con valores faltantes en las mismas columnas son agrupadas. De igual manera, columnas con valores faltantes en las mismas muestras son agrupadas.")) ), plotly::plotlyOutput("my_samples_nas") %>% shinycssloaders::withSpinner(color="#00719a", @@ -266,7 +247,7 @@ ui <- function(request){ position = "right", width = 400, open = FALSE, - tags$span(strong("Variable seleccionada: "), + tags$span(strong(i18n$t("Variable seleccionada: ")), textOutput("my_taxa_col_name")), #textOutput("my_taxa_col_name"), uiOutput("my_taxa_col_plot_options"), @@ -274,7 +255,7 @@ ui <- function(request){ shinycssloaders::withSpinner(color="#00719a", caption = "Cargando gráfico") ), - p("Esta vista te permite explorar las taxa y su metadata."), + p(i18n$t("Esta vista te permite explorar las taxa y su metadata.")), DT::DTOutput(outputId = "my_taxa", width = "100%") %>% shinycssloaders::withSpinner(color="#00719a", caption = "Cargando tabla") )) @@ -288,7 +269,7 @@ ui <- function(request){ position = "right", width = 400, open = FALSE), - p("Esta vista te permite explorar la abundancia de cada taxón en cada muestra."), + p(i18n$t("Esta vista te permite explorar la abundancia de cada taxón en cada muestra.")), DT::DTOutput(outputId = "my_counts", width = "100%") %>% shinycssloaders::withSpinner(color="#00719a", caption = "Cargando tabla") ) diff --git a/inst/app/translation.json b/inst/app/translation.json index 4cab94c..9584c94 100644 --- a/inst/app/translation.json +++ b/inst/app/translation.json @@ -6,9 +6,9 @@ ], "translation": [ { - "en": "Select the format of the input", + "en": "1. Select the format of the input", "es": "1. Selecciona el formato del archivo:", - "nl": "Selecteer het formaat van de input" + "nl": "1. Selecteer het formaat van de input" }, { "en": "2. Search for your file(s):", @@ -136,9 +136,14 @@ "nl": "VTOOL is een applicatie voor de visualisatie en verkenning van data gebaseerd op Shiny. Met behulp van een intuitieve en interactieve interface, wil deze tool het verkennen en weergeven van data geassocieerd met het bestuderen van het vaginale microbioom faciliteren." }, { - "en": "VTOOL is an open source project, developed in collaboration with researchers and bioninformaticians, who seek to further the study of the vaginal microbiome. If you are interested in contributing, reporting bugs, or learning more about this project please visit our GitHub repository.", - "es": "VTOOL es un proyecto de código abierto (open source), desarrollado en colaboración con investigadores y bioninformáticos, quienes buscan fomentar el estudio del microbioma vaginal. Si te interesa contribuir, reportar errores, o saber más de este proyecto, por favor visita nuestro repositorio en GitHub .", - "nl": "VTOOL is een open source project, ontwikkeld in nauwe samenwerking met onderzoekers en bio-informatici, die de studie van het vaginale microbioom willen bevorderen. Als je geïnteresseerd bent om bij te dragen, bugs te rapporteren of meer te weten te komen over dit project, bezoek dan onze GitHub repository." + "en": "VTOOL is an open source project, developed in collaboration with researchers and bioninformaticians, who seek to further the study of the vaginal microbiome. If you are interested in contributing, reporting bugs, or learning more about this project, please", + "es": "VTOOL es un proyecto de código abierto (open source), esarrollado en colaboración con investigadores y bioninformáticos, quienes buscan fomentar el estudio del microbioma vaginal. Si te interesa contribuir, reportar errores, o saber más de este proyecto, por favor", + "nl": "VTOOL is een open source project, ontwikkeld in nauwe samenwerking met onderzoekers en bio-informatici, die de studie van het vaginale microbioom willen bevorderen. Als je geïnteresseerd bent om bij te dragen, bugs te rapporteren of meer te weten te komen over dit project" + }, + { + "es": "visita nuestro repositorio en GitHub", + "en":"visit our repository on GitHub", + "nl":"bezoek onze repository op Github" }, { "en": "No file selected", @@ -161,9 +166,24 @@ "nl": "Hier kan je de stalen en metadata bekijken" }, { - "en": "This view allows you to explore patterns of missing values (NA) in the sample table. The graph shown is a graphical representation of the table, where cells containing values are light gray and cells with missing values are dark gray.", - "es": "Esta vista permite explorar patrones de valores faltantes (NA) en la tabla de muestras. El gráfico que mostramos es una representación gráfica de la tabla, donde las celdas que contienen valores son de color gris claro y las celdas con valores faltantes son de color gris oscuro .\n", - "nl": "Met deze weergave kun je patronen van ontbrekende waarden (NA) in de voorbeeldtabel onderzoeken. De weergegeven grafiek is een grafische weergave van de tabel, waarbij cellen met waarden lichtgrijs zijn en cellen met ontbrekende waarden donkergrijs." + "en": "This view allows you to explore patterns of missing values (NA) in the sample table. The graph shown is a graphical representation of the table, where cells containing values are light gray", + "es": "Esta vista permite explorar patrones de valores faltantes (NA) en la tabla de muestras. El gráfico que mostramos es una representación gráfica de la tabla, donde las celdas que contienen valores son de color", + "nl": "Met deze weergave kun je patronen van ontbrekende waarden (NA) in de voorbeeldtabel onderzoeken. De weergegeven grafiek is een grafische weergave van de tabel, waarbij cellen met waarden" + }, + { + "es": "y las celdas con valores faltantes son de color", + "en": "and cells with missing values are", + "nl": "zijn en cellen met ontbrekende waarden" + }, + { + "es":"gris claro", + "en":"light gray", + "nl":"lichtgrijs" + }, + { + "es":"gris oscuro", + "en":"dark grey", + "nl":"donkergrijs" }, { "en": "In addition, the order of the rows and columns has been rearranged so that samples with missing values in the same columns are grouped together. Similarly, columns with missing values in the same samples are grouped together.", @@ -195,6 +215,11 @@ "es": "Agrupar participantes según variable", "nl": "Groepeer participanten adhv variabele" }, + { + "es": "Variable seleccionada: ", + "en": "Variable selected: ", + "nl": "Gekozen variabele: " + }, { "en": "Group by taxonomical categorie", "es": "Agrupar por categoría taxonómica",