Skip to content

Conversation

@squell
Copy link
Member

@squell squell commented Dec 10, 2025

Principle followed: only "ordinary" user-facing messages need to be translated; that is stuff that is helpful or indicates error conditions outside of our or the system administrator's control.

I.e. a parse error in /etc/sudoers does not fall in that category, and neither do runtime errors or other obscure error conditions that indicate an error condition in operating system, etc.

To achieve this, I followed the algorithm:

  • Display impl's for Error types are user facing

  • Anything that goes into user_error/info/warn is user facing. There might be some false positives here (i.e. things that are really "obscure errors")

  • Looked at strings in the code base that go into an "Error" object, println, format, and of course anything dealing with the CLI.

  • Looked at al the remaining string literals to see what was missed. 😵‍💫

I'm pleased to report the xlat!() mechanism seems to work well.

Side-catch: in user-facing strings wherever I saw them I replaced "`" with "'", and tried to make capitalization consistent with the rest of the class.

we don't intend to translate sudoers-related error messages at this
point; the existence of this error message is a bit of a kludge: it
should end up in the "diagnostic" list we compile in sudoers/mod.rs
so visudo can handle it.
@squell squell added this to the i18n milestone Dec 10, 2025
@squell squell linked an issue Dec 10, 2025 that may be closed by this pull request
@squell squell force-pushed the l10n-tag branch 3 times, most recently from 2bd30d6 to 8c860a4 Compare December 10, 2025 22:21
@squell squell force-pushed the l10n-tag branch 4 times, most recently from 28307ca to 2e8790f Compare December 11, 2025 19:30
@squell squell requested a review from bjorn3 December 15, 2025 14:21
@squell
Copy link
Member Author

squell commented Dec 15, 2025

Note: the visudo ask_response function has been changed to use Lines for reading input. I don't know why this wasn't done before (maybe some fear of buffering?) but it works; I felt like correctly handling multibyte input at this stage would really be re-inventing the wheel.

Ok(b'y') => {}
Ok(val) if answers.starts_with(val) => {}
// a fallback: also accept 'yes' based on Debian's apt behaviour
Ok('y') => if !answers.contains('y') {},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Ok('y') => if !answers.contains('y') {},
Ok('y') if !answers.contains('y') {},

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now this would have been a useful clippy linr

answers,
) {
Ok(b'y') => {}
Ok(val) if answers.starts_with(val) => {}
Copy link
Collaborator

@bjorn3 bjorn3 Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the answer is n this would cause it to be interpreted as yes, right? The first letter of answers is now an n.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦

let stdin_handle = stdin.lock();
let mut stdout_handle = stdout.lock();

let mut lines = stdin_handle.lines();
Copy link
Collaborator

@bjorn3 bjorn3 Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can read more than a single line. It just buffers the rest. I don't know if that is an issue.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That might be the reason for the original approach. This part of visudo isn’t meant to be used in a pipeline though and interactive input should normally be line-buffered.

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

Successfully merging this pull request may close these issues.

Add localization support

3 participants