mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-01 21:21:15 -03:00
printf: simplify conversion specifiers
This is another case where we can don't need to use complicated formatting specifiers. There is also no need to use `wgettext_fmt` for messages which don't contain any localizable parts. The instances using `sprintf` could be kept as is, but I think it's better to keep the width computation at the place where it can sensibly be done, even though it is not done correctly at the moment because it does not use grapheme widths. Removing complicated conversion specifiers from localized messages helps with the transition to Fluent. Closes #12119
This commit is contained in:
committed by
danielrainer
parent
8a75bccf00
commit
5210c16bfa
4
po/de.po
4
po/de.po
@@ -155,10 +155,6 @@ msgstr ""
|
||||
msgid "%s, version %s\n"
|
||||
msgstr "%s, version %s\n"
|
||||
|
||||
#, c-format
|
||||
msgid "%s: %*s\n"
|
||||
msgstr ""
|
||||
|
||||
#, c-format
|
||||
msgid "%s: %s\n"
|
||||
msgstr ""
|
||||
|
||||
4
po/en.po
4
po/en.po
@@ -153,10 +153,6 @@ msgstr ""
|
||||
msgid "%s, version %s\n"
|
||||
msgstr "%s, version %s\n"
|
||||
|
||||
#, c-format
|
||||
msgid "%s: %*s\n"
|
||||
msgstr ""
|
||||
|
||||
#, c-format
|
||||
msgid "%s: %s\n"
|
||||
msgstr ""
|
||||
|
||||
4
po/fr.po
4
po/fr.po
@@ -284,10 +284,6 @@ msgstr "%s, version %s"
|
||||
msgid "%s, version %s\n"
|
||||
msgstr "%s, version %s\n"
|
||||
|
||||
#, c-format
|
||||
msgid "%s: %*s\n"
|
||||
msgstr "%s : %*s\n"
|
||||
|
||||
#, c-format
|
||||
msgid "%s: %s\n"
|
||||
msgstr "%s : %s\n"
|
||||
|
||||
4
po/pl.po
4
po/pl.po
@@ -149,10 +149,6 @@ msgstr ""
|
||||
msgid "%s, version %s\n"
|
||||
msgstr "%s, wersja %s\n"
|
||||
|
||||
#, c-format
|
||||
msgid "%s: %*s\n"
|
||||
msgstr ""
|
||||
|
||||
#, c-format
|
||||
msgid "%s: %s\n"
|
||||
msgstr ""
|
||||
|
||||
@@ -154,10 +154,6 @@ msgstr ""
|
||||
msgid "%s, version %s\n"
|
||||
msgstr "%s, versão %s\n"
|
||||
|
||||
#, c-format
|
||||
msgid "%s: %*s\n"
|
||||
msgstr ""
|
||||
|
||||
#, c-format
|
||||
msgid "%s: %s\n"
|
||||
msgstr ""
|
||||
|
||||
4
po/sv.po
4
po/sv.po
@@ -150,10 +150,6 @@ msgstr ""
|
||||
msgid "%s, version %s\n"
|
||||
msgstr "%s, version %s\n"
|
||||
|
||||
#, c-format
|
||||
msgid "%s: %*s\n"
|
||||
msgstr ""
|
||||
|
||||
#, c-format
|
||||
msgid "%s: %s\n"
|
||||
msgstr ""
|
||||
|
||||
@@ -176,10 +176,6 @@ msgstr "%s,版本 %s"
|
||||
msgid "%s, version %s\n"
|
||||
msgstr "%s,版本 %s\n"
|
||||
|
||||
#, c-format
|
||||
msgid "%s: %*s\n"
|
||||
msgstr "%s: %*s\n"
|
||||
|
||||
#, c-format
|
||||
msgid "%s: %s\n"
|
||||
msgstr "%s: %s\n"
|
||||
|
||||
@@ -149,10 +149,6 @@ msgstr "%s,%s 版"
|
||||
msgid "%s, version %s\n"
|
||||
msgstr "%s,%s 版\n"
|
||||
|
||||
#, c-format
|
||||
msgid "%s: %*s\n"
|
||||
msgstr "%s:%*s\n"
|
||||
|
||||
#, c-format
|
||||
msgid "%s: %s\n"
|
||||
msgstr "%s:%s\n"
|
||||
|
||||
@@ -353,8 +353,12 @@ fn abbr_add(opts: &Options, streams: &mut IoStreams) -> BuiltinResult {
|
||||
if let Some(offset) = error.offset() {
|
||||
streams
|
||||
.err
|
||||
.append(wgettext_fmt!("%s: %s\n", CMD, regex_pattern.as_utfstr()));
|
||||
streams.err.append(sprintf!("%s: %*s\n", CMD, offset, "^"));
|
||||
.append(sprintf!("%s: %s\n", CMD, regex_pattern.as_utfstr()));
|
||||
// TODO: This is misaligned if `regex_pattern` contains characters which are not
|
||||
// exactly 1 terminal cell wide.
|
||||
let mut marker = " ".repeat(offset.saturating_sub(1));
|
||||
marker.push('^');
|
||||
streams.err.append(sprintf!("%s: %s\n", CMD, marker));
|
||||
}
|
||||
return Err(STATUS_INVALID_ARGS);
|
||||
}
|
||||
|
||||
@@ -187,7 +187,11 @@ fn print_error(&self, args: &[&wstr], streams: &mut IoStreams) {
|
||||
&WString::from(e.error_message())
|
||||
);
|
||||
string_error!(streams, "%s: %s\n", cmd, pattern);
|
||||
string_error!(streams, "%s: %*s\n", cmd, e.offset().unwrap_or(0), "^");
|
||||
// TODO: This is misaligned if `pattern` contains characters which are not exactly 1
|
||||
// terminal cell wide.
|
||||
let mut marker = " ".repeat(e.offset().unwrap_or(0).saturating_sub(1));
|
||||
marker.push('^');
|
||||
string_error!(streams, "%s: %s\n", cmd, marker);
|
||||
}
|
||||
InvalidCaptureGroupName(name) => {
|
||||
streams.err.append(wgettext_fmt!(
|
||||
|
||||
Reference in New Issue
Block a user