mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-03-05 08:25:26 +02:00
ko: refresh translation for error-handling (#948)
* ko: refresh translation for error-handling Part of #925. * ko: move translations back to where they belong Moving them back helps avoid conflicts. The outdated messages can be cleaned up with `msgmerge` at a later point.
This commit is contained in:
parent
ebbb696703
commit
0234886c67
245
po/ko.po
245
po/ko.po
@ -10062,6 +10062,12 @@ msgid ""
|
||||
"}\n"
|
||||
"```"
|
||||
msgstr ""
|
||||
"```rust,editable,should_panic\n"
|
||||
"fn main() {\n"
|
||||
" let v = vec![10, 20, 30];\n"
|
||||
" println!(\"v[100]: {}\", v[100]);\n"
|
||||
"}\n"
|
||||
"```"
|
||||
|
||||
#: src/error-handling/panics.md:12
|
||||
msgid ""
|
||||
@ -10098,6 +10104,36 @@ msgid ""
|
||||
"```"
|
||||
msgstr ""
|
||||
|
||||
#: src/error-handling/panic-unwind.md:5
|
||||
msgid ""
|
||||
"```rust,editable\n"
|
||||
"use std::panic;\n"
|
||||
"\n"
|
||||
"let result = panic::catch_unwind(|| {\n"
|
||||
" println!(\"hello!\");\n"
|
||||
"});\n"
|
||||
"assert!(result.is_ok());\n"
|
||||
"\n"
|
||||
"let result = panic::catch_unwind(|| {\n"
|
||||
" panic!(\"oh no!\");\n"
|
||||
"});\n"
|
||||
"assert!(result.is_err());\n"
|
||||
"```"
|
||||
msgstr ""
|
||||
"```rust,editable\n"
|
||||
"use std::panic;\n"
|
||||
"\n"
|
||||
"let result = panic::catch_unwind(|| {\n"
|
||||
" println!(\"hello!\");\n"
|
||||
"});\n"
|
||||
"assert!(result.is_ok());\n"
|
||||
"\n"
|
||||
"let result = panic::catch_unwind(|| {\n"
|
||||
" panic!(\"oh no!\");\n"
|
||||
"});\n"
|
||||
"assert!(result.is_err());\n"
|
||||
"```"
|
||||
|
||||
#: src/error-handling/panic-unwind.md:19
|
||||
msgid ""
|
||||
"* This can be useful in servers which should keep running even if a single\n"
|
||||
@ -10139,6 +10175,46 @@ msgid ""
|
||||
"```"
|
||||
msgstr ""
|
||||
|
||||
#: src/error-handling/result.md:6
|
||||
msgid ""
|
||||
"```rust,editable\n"
|
||||
"use std::fs::File;\n"
|
||||
"use std::io::Read;\n"
|
||||
"\n"
|
||||
"fn main() {\n"
|
||||
" let file = File::open(\"diary.txt\");\n"
|
||||
" match file {\n"
|
||||
" Ok(mut file) => {\n"
|
||||
" let mut contents = String::new();\n"
|
||||
" file.read_to_string(&mut contents);\n"
|
||||
" println!(\"Dear diary: {contents}\");\n"
|
||||
" },\n"
|
||||
" Err(err) => {\n"
|
||||
" println!(\"The diary could not be opened: {err}\");\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
"}\n"
|
||||
"```"
|
||||
msgstr ""
|
||||
"```rust,editable\n"
|
||||
"use std::fs::File;\n"
|
||||
"use std::io::Read;\n"
|
||||
"\n"
|
||||
"fn main() {\n"
|
||||
" let file = File::open(\"diary.txt\");\n"
|
||||
" match file {\n"
|
||||
" Ok(mut file) => {\n"
|
||||
" let mut contents = String::new();\n"
|
||||
" file.read_to_string(&mut contents);\n"
|
||||
" println!(\"Dear diary: {contents}\");\n"
|
||||
" },\n"
|
||||
" Err(err) => {\n"
|
||||
" println!(\"The diary could not be opened: {err}\");\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
"}\n"
|
||||
"```"
|
||||
|
||||
#: src/error-handling/result.md:27
|
||||
msgid ""
|
||||
" * As with `Option`, the successful value sits inside of `Result`, forcing the developer to\n"
|
||||
@ -10171,6 +10247,12 @@ msgid ""
|
||||
"}\n"
|
||||
"```"
|
||||
msgstr ""
|
||||
"```rust,ignore\n"
|
||||
"match some_expression {\n"
|
||||
" Ok(value) => value,\n"
|
||||
" Err(err) => return Err(err),\n"
|
||||
"}\n"
|
||||
"```"
|
||||
|
||||
#: src/error-handling/try-operator.md:13
|
||||
msgid "into the much simpler"
|
||||
@ -10182,6 +10264,9 @@ msgid ""
|
||||
"some_expression?\n"
|
||||
"```"
|
||||
msgstr ""
|
||||
"```rust,ignore\n"
|
||||
"some_expression?\n"
|
||||
"```"
|
||||
|
||||
#: src/error-handling/try-operator.md:19
|
||||
msgid "We can use this to simplify our error handing code:"
|
||||
@ -10241,6 +10326,9 @@ msgid ""
|
||||
"expression?\n"
|
||||
"```"
|
||||
msgstr ""
|
||||
"```rust,ignore\n"
|
||||
"expression?\n"
|
||||
"```"
|
||||
|
||||
#: src/error-handling/converting-error-types.md:9
|
||||
msgid "works the same as"
|
||||
@ -10255,6 +10343,12 @@ msgid ""
|
||||
"}\n"
|
||||
"```"
|
||||
msgstr ""
|
||||
"```rust,ignore\n"
|
||||
"match expression {\n"
|
||||
" Ok(value) => value,\n"
|
||||
" Err(err) => return Err(From::from(err)),\n"
|
||||
"}\n"
|
||||
"```"
|
||||
|
||||
#: src/error-handling/converting-error-types.md:18
|
||||
msgid ""
|
||||
@ -10310,6 +10404,100 @@ msgid ""
|
||||
"```"
|
||||
msgstr ""
|
||||
|
||||
#: src/error-handling/converting-error-types-example.md:3
|
||||
msgid ""
|
||||
"```rust,editable\n"
|
||||
"use std::error::Error;\n"
|
||||
"use std::fmt::{self, Display, Formatter};\n"
|
||||
"use std::fs::{self, File};\n"
|
||||
"use std::io::{self, Read};\n"
|
||||
"\n"
|
||||
"#[derive(Debug)]\n"
|
||||
"enum ReadUsernameError {\n"
|
||||
" IoError(io::Error),\n"
|
||||
" EmptyUsername(String),\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"impl Error for ReadUsernameError {}\n"
|
||||
"\n"
|
||||
"impl Display for ReadUsernameError {\n"
|
||||
" fn fmt(&self, f: &mut Formatter) -> fmt::Result {\n"
|
||||
" match self {\n"
|
||||
" Self::IoError(e) => write!(f, \"IO error: {e}\"),\n"
|
||||
" Self::EmptyUsername(filename) => write!(f, \"Found no username "
|
||||
"in {filename}\"),\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"impl From<io::Error> for ReadUsernameError {\n"
|
||||
" fn from(err: io::Error) -> ReadUsernameError {\n"
|
||||
" ReadUsernameError::IoError(err)\n"
|
||||
" }\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"fn read_username(path: &str) -> Result<String, ReadUsernameError> {\n"
|
||||
" let mut username = String::with_capacity(100);\n"
|
||||
" File::open(path)?.read_to_string(&mut username)?;\n"
|
||||
" if username.is_empty() {\n"
|
||||
" return Err(ReadUsernameError::EmptyUsername(String::from(path)));\n"
|
||||
" }\n"
|
||||
" Ok(username)\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"fn main() {\n"
|
||||
" //fs::write(\"config.dat\", \"\").unwrap();\n"
|
||||
" let username = read_username(\"config.dat\");\n"
|
||||
" println!(\"username or error: {username:?}\");\n"
|
||||
"}\n"
|
||||
"```"
|
||||
msgstr ""
|
||||
"```rust,editable\n"
|
||||
"use std::error::Error;\n"
|
||||
"use std::fmt::{self, Display, Formatter};\n"
|
||||
"use std::fs::{self, File};\n"
|
||||
"use std::io::{self, Read};\n"
|
||||
"\n"
|
||||
"#[derive(Debug)]\n"
|
||||
"enum ReadUsernameError {\n"
|
||||
" IoError(io::Error),\n"
|
||||
" EmptyUsername(String),\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"impl Error for ReadUsernameError {}\n"
|
||||
"\n"
|
||||
"impl Display for ReadUsernameError {\n"
|
||||
" fn fmt(&self, f: &mut Formatter) -> fmt::Result {\n"
|
||||
" match self {\n"
|
||||
" Self::IoError(e) => write!(f, \"IO error: {e}\"),\n"
|
||||
" Self::EmptyUsername(filename) => write!(f, \"Found no username "
|
||||
"in {filename}\"),\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"impl From<io::Error> for ReadUsernameError {\n"
|
||||
" fn from(err: io::Error) -> ReadUsernameError {\n"
|
||||
" ReadUsernameError::IoError(err)\n"
|
||||
" }\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"fn read_username(path: &str) -> Result<String, ReadUsernameError> {\n"
|
||||
" let mut username = String::with_capacity(100);\n"
|
||||
" File::open(path)?.read_to_string(&mut username)?;\n"
|
||||
" if username.is_empty() {\n"
|
||||
" return Err(ReadUsernameError::EmptyUsername(String::from(path)));\n"
|
||||
" }\n"
|
||||
" Ok(username)\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"fn main() {\n"
|
||||
" //fs::write(\"config.dat\", \"\").unwrap();\n"
|
||||
" let username = read_username(\"config.dat\");\n"
|
||||
" println!(\"username or error: {username:?}\");\n"
|
||||
"}\n"
|
||||
"```"
|
||||
|
||||
#: src/error-handling/converting-error-types-example.md:55
|
||||
msgid ""
|
||||
"It is good practice for all error types to implement `std::error::Error`, which requires `Debug` and\n"
|
||||
@ -10361,6 +10549,36 @@ msgid ""
|
||||
"}\n"
|
||||
"```"
|
||||
msgstr ""
|
||||
"```rust,editable,compile_fail\n"
|
||||
"use std::{fs, io};\n"
|
||||
"use std::io::Read;\n"
|
||||
"use thiserror::Error;\n"
|
||||
"\n"
|
||||
"#[derive(Debug, Error)]\n"
|
||||
"enum ReadUsernameError {\n"
|
||||
" #[error(\"Could not read: {0}\")]\n"
|
||||
" IoError(#[from] io::Error),\n"
|
||||
" #[error(\"Found no username in {0}\")]\n"
|
||||
" EmptyUsername(String),\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"fn read_username(path: &str) -> Result<String, ReadUsernameError> {\n"
|
||||
" let mut username = String::with_capacity(100);\n"
|
||||
" fs::File::open(path)?.read_to_string(&mut username)?;\n"
|
||||
" if username.is_empty() {\n"
|
||||
" return Err(ReadUsernameError::EmptyUsername(String::from(path)));\n"
|
||||
" }\n"
|
||||
" Ok(username)\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"fn main() {\n"
|
||||
" //fs::write(\"config.dat\", \"\").unwrap();\n"
|
||||
" match read_username(\"config.dat\") {\n"
|
||||
" Ok(username) => println!(\"Username: {username}\"),\n"
|
||||
" Err(err) => println!(\"Error: {err}\"),\n"
|
||||
" }\n"
|
||||
"}\n"
|
||||
"```"
|
||||
|
||||
#: src/error-handling/deriving-error-enums.md:39
|
||||
msgid ""
|
||||
@ -10413,6 +10631,33 @@ msgid ""
|
||||
"}\n"
|
||||
"```"
|
||||
msgstr ""
|
||||
"```rust,editable,compile_fail\n"
|
||||
"use std::fs::{self, File};\n"
|
||||
"use std::io::Read;\n"
|
||||
"use thiserror::Error;\n"
|
||||
"use std::error::Error;\n"
|
||||
"\n"
|
||||
"#[derive(Clone, Debug, Eq, Error, PartialEq)]\n"
|
||||
"#[error(\"Found no username in {0}\")]\n"
|
||||
"struct EmptyUsernameError(String);\n"
|
||||
"\n"
|
||||
"fn read_username(path: &str) -> Result<String, Box<dyn Error>> {\n"
|
||||
" let mut username = String::with_capacity(100);\n"
|
||||
" File::open(path)?.read_to_string(&mut username)?;\n"
|
||||
" if username.is_empty() {\n"
|
||||
" return Err(EmptyUsernameError(String::from(path)).into());\n"
|
||||
" }\n"
|
||||
" Ok(username)\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"fn main() {\n"
|
||||
" //fs::write(\"config.dat\", \"\").unwrap();\n"
|
||||
" match read_username(\"config.dat\") {\n"
|
||||
" Ok(username) => println!(\"Username: {username}\"),\n"
|
||||
" Err(err) => println!(\"Error: {err}\"),\n"
|
||||
" }\n"
|
||||
"}\n"
|
||||
"```"
|
||||
|
||||
#: src/error-handling/dynamic-errors.md:36
|
||||
msgid ""
|
||||
|
Loading…
x
Reference in New Issue
Block a user