un-fao / calipseo-shiny

Calipseo is FAO web- based platform for national Fisheries Authorities to streamline management of fisheries data and the production, analysis and reporting of fishery statistics.
1 stars 0 forks source link

[CALR-55] i18n multi-lingual support - retrieval of DB i18n labels #55

Closed eblondel closed 6 months ago

eblondel commented 6 months ago

Issue migrated from JIRA: https://sdlc.review.fao.org/jira/browse/CALR-55 Creator/Reporter: Emmanuel Blondel @eblondel Assignee: Brian Ojok @brianandy Priority: Medium Status: Done Date of creation: 2022-01-14T09:32:34.000+0000

This task is in continuity of CALR-49 (i18n static labels). Here we want to retrieve i18n labels that are stored in the Calipseo/openfismis DB model. In the latter, all tables containing names have a standard structure with a NAME, DESCRIPTION and I18N columns starting with a default one I18N_DEFAULT, and followed by columns specific to each language, eg I18N_EN, I18N_FR, etc

On R Shiny side, currently, we do SQL queries, in which the NAME column is retrieved, in general it can be the species name, vessel name, etc. 

The task will consist in making the SQL queries I18N compatible, so in principle, given a language specified in the configuration, we will pick up the right language I18N_ column in the DB for all queries:

Logic/Proposal to test:


applyI18nColumnName <- function(sql, language = NULL){

    if(is.null(language) return(sql)

    new_sql <- gsub("I18N_DEFAULT", sprintf("I18N_%s", toupper(language)), sql)

    return(new_sql)

}

 

eblondel commented 6 months ago

Author: Emmanuel Blondel @eblondel Date of creation: 2022-01-25T16:54:45.940+0000 Last update: 2022-01-25T16:54:45.940+0000

[~brian.ojok] great work, many thanks