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

[Feature]: Support regex wildcards in text substitution #130

Open
1 task done
yogat3ch opened this issue Sep 15, 2023 · 0 comments
Open
1 task done

[Feature]: Support regex wildcards in text substitution #130

yogat3ch opened this issue Sep 15, 2023 · 0 comments

Comments

@yogat3ch
Copy link

Guidelines

  • I agree to follow this project's Contributing Guidelines.

Description

It's often necessary to dynamically render values in the UI:
tags$div(glue::glue("Your model has {accuracy} accuracy"))
With present implementation, this must be parsed into two translation strings:

tags$div(tags$span(i18n$t("Your model has "), accuracy, i18n$t(" accuracy")))

Problem

This can grow to be extremely cumbersome the more dynamic substitution is necessary. Reflexive verbs and prepositions often need special treatment relative to the sentence subject in other languages so sentence fragments may have the same key in english, but multiple keys in other languages, further complicating implementation.

Proposed Solution

The key lookup logic could use regex lookup flags IE the key might look like:

"Your model has $x/\\d+\\.\\d+\\%/ accuracy"

which would leave the regex as is while replacing the language around it. I guess this also could be complicated depending on changes to sentence structure in other languages, but c'est la vie.

Alternatives Considered

Not really, it's a complex problem to solve.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant