From 85e8e814e8f83315ecb1358816f168f38b986c71 Mon Sep 17 00:00:00 2001 From: Matthijs Berends Date: Wed, 7 Jan 2026 13:30:54 +0100 Subject: [PATCH] (v3.0.1.9013) fix translations --- DESCRIPTION | 2 +- NEWS.md | 2 +- R/translate.R | 9 +++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 9c54ab616..95d01d65e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 3.0.1.9012 +Version: 3.0.1.9013 Date: 2026-01-07 Title: Antimicrobial Resistance Data Analysis Description: Functions to simplify and standardise antimicrobial resistance (AMR) diff --git a/NEWS.md b/NEWS.md index 8ee26a8e8..46bdb3904 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# AMR 3.0.1.9012 +# AMR 3.0.1.9013 ### New * Integration with the **tidymodels** framework to allow seamless use of SIR, MIC and disk data in modelling pipelines via `recipes` diff --git a/R/translate.R b/R/translate.R index 245fac1da..cb5da72d1 100755 --- a/R/translate.R +++ b/R/translate.R @@ -263,16 +263,17 @@ translate_into_language <- function(from, df_trans$pattern[df_trans$regular_expr == TRUE] <- gsub("$$", "$", df_trans$pattern[df_trans$regular_expr == TRUE], fixed = TRUE) } + df_trans_regex <- df_trans[which(df_trans$regular_expr == TRUE), ] # regex part lapply( # starting with longest pattern, since more general translations are shorter, such as 'Group' - order(nchar(df_trans$pattern), decreasing = TRUE)[df_trans$regular_expr == TRUE], + order(nchar(df_trans_regex$pattern), decreasing = TRUE), function(i) { from_unique_translated <<- gsub( - pattern = df_trans$pattern[i], - replacement = df_trans[i, lang, drop = TRUE], + pattern = df_trans_regex$pattern[i], + replacement = df_trans_regex[i, lang, drop = TRUE], x = from_unique_translated, - ignore.case = !df_trans$case_sensitive[i], + ignore.case = !df_trans_regex$case_sensitive[i], fixed = FALSE, perl = TRUE )