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

Implement translated template string formatting in Rust #4338

Open
obrusvit opened this issue Nov 11, 2024 · 0 comments
Open

Implement translated template string formatting in Rust #4338

obrusvit opened this issue Nov 11, 2024 · 0 comments
Labels
code Code improvements core Trezor Core firmware. Runs on Trezor Model T and T2B1. translations Put this label on a PR to run tests in all languages

Comments

@obrusvit
Copy link
Contributor

obrusvit commented Nov 11, 2024

Moving forward, we'd like to have the capability to format translation strings directly in Rust and we don't want to count on MicroPython and pass pre-formatted strings to Rust layouts.

Currently, we have to do something like this (not real code):

text = TR.reset__words_written_down_template.format(words_count)
layout = trezorui_api.show_share_words_mercury(words, text=text)

If the text is not influenced by uPy app, we should be able to pass just words to Rust and format the text there.


What we can do right now is to format using uformat! from ufmt crate, but the drawback is that the format string can only be a string literal:

uformat!("{}. {}", self.page_index + 1, w)

I.e. something like this is not possible using ufmt:

// reset__word_x_of_y: "Word {0} of {1}"
uformat!(TR::reset__word_x_of_y, n, words.len())

The task is to find, test, integrate and review an external crate which can do that, or develop our own.

@obrusvit obrusvit added core Trezor Core firmware. Runs on Trezor Model T and T2B1. code Code improvements translations Put this label on a PR to run tests in all languages labels Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code Code improvements core Trezor Core firmware. Runs on Trezor Model T and T2B1. translations Put this label on a PR to run tests in all languages
Projects
Status: No status
Development

No branches or pull requests

1 participant