1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-04-15 05:22:12 +02:00

vi: Day 1 Morning - Types and Values translation (#2020)

Here is the translation of *Day 1 Morning: Type and Values* translation.

It seems like there is no corresponding definition of *hygienic macros*
in Vietnamese, so I think keeping its English word is fine.

---------

Co-authored-by: Martin Geisler <mgeisler@google.com>
This commit is contained in:
Tuslipid 2024-08-21 14:46:24 +07:00 committed by GitHub
parent 0b4e2a8813
commit ea1209336b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

158
po/vi.po
View File

@ -79,27 +79,27 @@ msgstr "Sân chơi (*Playground*)"
#: src/SUMMARY.md src/running-the-course/course-structure.md
#: src/welcome-day-1.md src/types-and-values.md
msgid "Types and Values"
msgstr ""
msgstr "Kiểu Dữ Liệu Và Giá Trị"
#: src/SUMMARY.md src/types-and-values.md src/types-and-values/variables.md
msgid "Variables"
msgstr ""
msgstr "Biến"
#: src/SUMMARY.md src/types-and-values.md src/types-and-values/values.md
msgid "Values"
msgstr ""
msgstr "Giá trị"
#: src/SUMMARY.md src/types-and-values.md src/types-and-values/arithmetic.md
msgid "Arithmetic"
msgstr ""
msgstr "Số Học"
#: src/SUMMARY.md src/types-and-values.md src/types-and-values/inference.md
msgid "Type Inference"
msgstr ""
msgstr "Suy Luận Kiểu"
#: src/SUMMARY.md src/types-and-values.md src/types-and-values/exercise.md
msgid "Exercise: Fibonacci"
msgstr ""
msgstr "Thực Hành: Fibonacci"
#: src/SUMMARY.md src/types-and-values/solution.md
#: src/control-flow-basics/solution.md src/tuples-and-arrays/solution.md
@ -112,7 +112,7 @@ msgstr ""
#: src/testing/solution.md src/error-handling/solution.md
#: src/unsafe-rust/solution.md
msgid "Solution"
msgstr ""
msgstr "Đáp Án"
#: src/SUMMARY.md src/running-the-course/course-structure.md
#: src/welcome-day-1.md src/control-flow-basics.md
@ -2894,41 +2894,45 @@ msgstr ""
#: src/types-and-values.md src/control-flow-basics.md src/generics.md
#: src/modules.md
msgid "This segment should take about 40 minutes. It contains:"
msgstr "Phn này sẽ kéo dài khoảng 40 phút, bao gồm:"
msgstr "Phân đoạn này sẽ kéo dài khoảng 40 phút, bao gồm:"
#: src/types-and-values/hello-world.md
msgid ""
"Let us jump into the simplest possible Rust program, a classic Hello World "
"program:"
msgstr ""
"Chúng ta hãy cùng bước vào chương trình Rust đơn giản nhất, một chương trình "
"Hello World điển hình:"
#: src/types-and-values/hello-world.md
msgid "\"Hello 🌍!\""
msgstr ""
msgstr "\"Hello 🌍!\""
#: src/types-and-values/hello-world.md
msgid "What you see:"
msgstr ""
msgstr "Những gì bạn thấy được:"
#: src/types-and-values/hello-world.md
msgid "Functions are introduced with `fn`."
msgstr ""
msgstr "Khái niệm hàm được giới thiệu với `fn`."
#: src/types-and-values/hello-world.md
msgid "Blocks are delimited by curly braces like in C and C++."
msgstr ""
msgstr "Các khối code được phân tách theo ngoặc nhọn y như C và C++."
#: src/types-and-values/hello-world.md
msgid "The `main` function is the entry point of the program."
msgstr ""
msgstr "Hàm `main` là điểm bắt đầu của cả chương trình."
#: src/types-and-values/hello-world.md
msgid "Rust has hygienic macros, `println!` is an example of this."
msgstr ""
msgstr "Rust có các hygienic macros, ví dụ như `println!`."
#: src/types-and-values/hello-world.md
msgid "Rust strings are UTF-8 encoded and can contain any Unicode character."
msgstr ""
"Các chuỗi của Rust được mã hóa theo chuẩn UTF-8 và có thể chứa bất kỳ ký tự "
"Unicode nào."
#: src/types-and-values/hello-world.md
msgid ""
@ -2936,22 +2940,33 @@ msgid ""
"see a ton of it over the next four days so we start small with something "
"familiar."
msgstr ""
"Slide này là nhằm cố gắng giúp các học viên thấy thoải mái với Rust code. Họ "
"sẽ được thấy hàng tấn đoạn code tương tự trong bốn ngày tiếp theo nên ta có "
"thể bắt đầu với những thứ nhỏ bé quen thuộc trước."
#: src/types-and-values/hello-world.md
msgid ""
"Rust is very much like other languages in the C/C++/Java tradition. It is "
"imperative and it doesn't try to reinvent things unless absolutely necessary."
msgstr ""
"Rust khá giống với các ngôn ngữ truyền thống như C/C++/Java, đó là điều bắt "
"buộc. Nó cũng cố tránh sáng tạo lại những thứ đã có trừ khi thực sự cần "
"thiết."
#: src/types-and-values/hello-world.md
msgid "Rust is modern with full support for things like Unicode."
msgstr ""
"Rust là ngôn ngữ hiện đại với khả năng hỗ trợ đầy đủ các tính năng như là "
"Unicode."
#: src/types-and-values/hello-world.md
msgid ""
"Rust uses macros for situations where you want to have a variable number of "
"arguments (no function [overloading](../control-flow-basics/functions.md))."
msgstr ""
"Rust sử dụng các macro trong các tình huống như khi bạn muốn có số lượng đối "
"số thay đổi (không bao gồm [nạp chồng hàm](../control-flow-basics/functions."
"md))."
#: src/types-and-values/hello-world.md
msgid ""
@ -2960,6 +2975,9 @@ msgid ""
"hygienic](https://veykril.github.io/tlborm/decl-macros/minutiae/hygiene."
"html)."
msgstr ""
"Macros được gọi là 'hygienic' khi chúng không vô tình bắt các định danh từ "
"phạm vi mà chúng được sử dụng. Rust macros thực chất chỉ là [hygienic từng "
"phần](https://veykril.github.io/tlborm/decl-macros/minutiae/hygiene.html)."
#: src/types-and-values/hello-world.md
msgid ""
@ -2968,12 +2986,19 @@ msgid ""
"while it is not a functional language, it includes a range of [functional "
"concepts](https://doc.rust-lang.org/book/ch13-00-functional-features.html)."
msgstr ""
"Rust là ngôn ngữ đa mô hình. Ví dụ, nó có các [tính năng hướng đối tượng]"
"(https://doc.rust-lang.org/book/ch17-00-oop.html) mạnh mẽ, và dù cho nó "
"không phải là một ngôn ngữ lập trình chức năng, nó vẫn bao gồm nhiều [khái "
"niệm lập trình hàm](https://doc.rust-lang.org/book/ch13-00-functional-"
"features.html)."
#: src/types-and-values/variables.md
msgid ""
"Rust provides type safety via static typing. Variable bindings are made with "
"`let`:"
msgstr ""
"Rust cung cấp tính năng an toàn kiểu thông qua kiểu dữ liệu tĩnh. Việc liên "
"kết biến được thực thi bằng `let`:"
#: src/types-and-values/variables.md src/control-flow-basics/loops/for.md
#: src/control-flow-basics/blocks-and-scopes.md
@ -2985,12 +3010,16 @@ msgid ""
"// x = 20;\n"
" // println!(\"x: {x}\");\n"
msgstr ""
"// x = 20;\n"
" // println!(\"x: {x}\");\n"
#: src/types-and-values/variables.md
msgid ""
"Uncomment the `x = 20` to demonstrate that variables are immutable by "
"default. Add the `mut` keyword to allow changes."
msgstr ""
"Hãy thử loại bỏ ghi chú `x = 20` để cho thấy các biến theo mặc định là bất "
"biến. Thêm từ khóa `mut` để cho các biến được chấp nhận thay đổi."
#: src/types-and-values/variables.md
msgid ""
@ -2998,104 +3027,109 @@ msgid ""
"time, but type inference (covered later) allows the programmer to omit it in "
"many cases."
msgstr ""
"Ở đây, từ khóa `i32` chỉ kiểu dữ liệu của biến. Từ khóa này là bắt buộc cho "
"việc biên dịch, nhưng trong nhiều trường hợp, suy luận kiểu (sẽ được thảo "
"luận sau) cho phép lập trình viên bỏ qua nó."
#: src/types-and-values/values.md
msgid ""
"Here are some basic built-in types, and the syntax for literal values of "
"each type."
msgstr ""
"Dưới đây là các kiểu dữ liệu được định nghĩa sẵn, và nguyên văn cú pháp cho "
"các giá trị của từng loại."
#: src/types-and-values/values.md src/unsafe-rust/exercise.md
msgid "Types"
msgstr ""
msgstr "Kiểu Dữ Liệu"
#: src/types-and-values/values.md
msgid "Literals"
msgstr ""
msgstr "Nguyên Văn Cú Pháp"
#: src/types-and-values/values.md
msgid "Signed integers"
msgstr ""
msgstr "Số nguyên có dấu"
#: src/types-and-values/values.md
msgid "`i8`, `i16`, `i32`, `i64`, `i128`, `isize`"
msgstr ""
msgstr "`i8`, `i16`, `i32`, `i64`, `i128`, `isize`"
#: src/types-and-values/values.md
msgid "`-10`, `0`, `1_000`, `123_i64`"
msgstr ""
msgstr "`-10`, `0`, `1_000`, `123_i64`"
#: src/types-and-values/values.md
msgid "Unsigned integers"
msgstr ""
msgstr "Số nguyên không dấu"
#: src/types-and-values/values.md
msgid "`u8`, `u16`, `u32`, `u64`, `u128`, `usize`"
msgstr ""
msgstr "`u8`, `u16`, `u32`, `u64`, `u128`, `usize`"
#: src/types-and-values/values.md
msgid "`0`, `123`, `10_u16`"
msgstr ""
msgstr "`0`, `123`, `10_u16`"
#: src/types-and-values/values.md
msgid "Floating point numbers"
msgstr ""
msgstr "Số thực dấu phẩy động"
#: src/types-and-values/values.md
msgid "`f32`, `f64`"
msgstr ""
msgstr "`f32`, `f64`"
#: src/types-and-values/values.md
msgid "`3.14`, `-10.0e20`, `2_f32`"
msgstr ""
msgstr "`3.14`, `-10.0e20`, `2_f32`"
#: src/types-and-values/values.md
msgid "Unicode scalar values"
msgstr ""
msgstr "Giá trị vô hướng Unicode"
#: src/types-and-values/values.md src/android/aidl/types/primitives.md
msgid "`char`"
msgstr ""
msgstr "`char`"
#: src/types-and-values/values.md
msgid "`'a'`, `'α'`, `'∞'`"
msgstr ""
msgstr "`'a'`, `'α'`, `'∞'`"
#: src/types-and-values/values.md
msgid "Booleans"
msgstr ""
msgstr "Boolean"
#: src/types-and-values/values.md src/android/aidl/types/primitives.md
msgid "`bool`"
msgstr ""
msgstr "`bool`"
#: src/types-and-values/values.md
msgid "`true`, `false`"
msgstr ""
msgstr "`true`, `false`"
#: src/types-and-values/values.md
msgid "The types have widths as follows:"
msgstr ""
msgstr "Các kiểu dữ liệu có độ lớn như sau:"
#: src/types-and-values/values.md
msgid "`iN`, `uN`, and `fN` are _N_ bits wide,"
msgstr ""
msgstr "`iN`, `uN`, và `fN` tương đương _N_ bit,"
#: src/types-and-values/values.md
msgid "`isize` and `usize` are the width of a pointer,"
msgstr ""
msgstr "`isize` và `usize` tương đương một pointer,"
#: src/types-and-values/values.md
msgid "`char` is 32 bits wide,"
msgstr ""
msgstr "`char` tương đương 32 bit,"
#: src/types-and-values/values.md
msgid "`bool` is 8 bits wide."
msgstr ""
msgstr "`bool` tương đương 8 bit."
#: src/types-and-values/values.md
msgid "There are a few syntaxes which are not shown above:"
msgstr ""
msgstr "Ngoài ra, còn có một vài cú pháp không được kể đến ở trên:"
#: src/types-and-values/values.md
msgid ""
@ -3103,10 +3137,13 @@ msgid ""
"`1_000` can be written as `1000` (or `10_00`), and `123_i64` can be written "
"as `123i64`."
msgstr ""
"Tất cả dấu gạch dưới trong số đều có thể bỏ qua, chúng chỉ nhằm cho mục "
"đích dễ đọc mã. Vậy nên, `1_000` có thể được viết thành `1000` (hoặc "
"`10_00`), và `123_i64` có thể được viết thành `123i64`."
#: src/types-and-values/arithmetic.md
msgid "\"result: {}\""
msgstr ""
msgstr "\"kết quả: {}\""
#: src/types-and-values/arithmetic.md
msgid ""
@ -3114,10 +3151,15 @@ msgid ""
"meaning should be clear: it takes three integers, and returns an integer. "
"Functions will be covered in more detail later."
msgstr ""
"Đây là lần đầu tiên ta thấy một hàm mới ngoài hàm `main`, nhưng hàm này cũng "
"có logic rõ ràng dễ hiểu: nó nhận ba số nguyên, và trả lại một số nguyên. "
"Chi tiết về hàm sẽ được bao quát sau."
#: src/types-and-values/arithmetic.md
msgid "Arithmetic is very similar to other languages, with similar precedence."
msgstr ""
"Số học trong Rust cũng rất giống với các ngôn ngữ khác, với tiền đề giống "
"nhau."
#: src/types-and-values/arithmetic.md
msgid ""
@ -3125,6 +3167,10 @@ msgid ""
"actually undefined, and might do different things on different platforms or "
"compilers. In Rust, it's defined."
msgstr ""
"Vậy còn hiên tượng tràn số nguyên thì sao? Trong C và C++, vấn đề tràn số "
"nguyên _có dấu_ thực ra lại không được xác định, và nó có thể xảy ra theo "
"các cách khác nhau trên các nền tảng hoặc trình biên dịch khác nhau. Còn "
"trong Rust, nó được xác định rõ ràng."
#: src/types-and-values/arithmetic.md
msgid ""
@ -3134,22 +3180,35 @@ msgid ""
"with method syntax, e.g., `(a * b).saturating_add(b * c).saturating_add(c * "
"a)`."
msgstr ""
"Để xem cách tràn số nguyên xảy ra, hãy thử đổi `i32` sang `i16`. Việc này "
"sẽ gây ra lỗi (đã được kiểm tra) trong bản debug build và được điều chỉnh "
"lại kiểu phù hợp trong bản release build. Ngoài ra, còn có các tùy chọn số "
"học khác như tính số tràn (overflowing), tính số bão hòa (saturating), và "
"tính giữ phần dư (carrying). Chúng được truy cập bằng cú pháp riêng, ví dụ, "
"`(a * b).saturating_add(b * c).saturating_add(c * a)`."
#: src/types-and-values/arithmetic.md
msgid ""
"In fact, the compiler will detect overflow of constant expressions, which is "
"why the example requires a separate function."
msgstr ""
"Trên thực tế, trình biên dịch sẽ phát hiện ra tràn số nguyên trong các biểu "
"thức hằng số, vì thế nên ta cần phải tách ra các hàm riêng ở trong ví dụ "
"trên."
#: src/types-and-values/inference.md
msgid "Rust will look at how the variable is _used_ to determine the type:"
msgstr ""
"Rust sẽ kiểm tra xem biến được _sử dụng_ như thế nào để xác định kiểu dữ "
"liệu:"
#: src/types-and-values/inference.md
msgid ""
"This slide demonstrates how the Rust compiler infers types based on "
"constraints given by variable declarations and usages."
msgstr ""
"Slide này cho ta thấy cách mà trình biên dịch Rust đoán kiểu dữ liệu dựa "
"trên các ràng buộc từ việc khai báo và sử dụng biến."
#: src/types-and-values/inference.md
msgid ""
@ -3159,6 +3218,11 @@ msgid ""
"of a type. The compiler does the job for us and helps us write more concise "
"code."
msgstr ""
"Một điều quan trọng cần lưu ý đó là việc khai báo các biến như trên không "
"phải là một dạng khai báo động theo kiểu \"any\" mà có thể gán được bất kỳ "
"dữ liệu nào. Mã máy được sinh ra từ cách khai báo này cũng giống như cách "
"khai báo một kiểu dữ liệu cụ thể. Trình biên dịch sẽ lo liệu những việc này "
"cho ta và giúp ta viết những đoạn mã ngắn gọn hơn."
#: src/types-and-values/inference.md
msgid ""
@ -3166,10 +3230,14 @@ msgid ""
"`i32`. This sometimes appears as `{integer}` in error messages. Similarly, "
"floating-point literals default to `f64`."
msgstr ""
"Khi không có bất cứ ràng buộc nào cho khai báo kiểu số nguyên, Rust sẽ mặc "
"định sử dụng `i32`. Đôi khi trong thông báo lỗi biến sẽ được hiển thị dưới "
"dạng `{integer}`. Tương tự, với các số thực dấu phẩy động, Rust mặc định là "
"`f64`."
#: src/types-and-values/inference.md
msgid "// ERROR: no implementation for `{float} == {integer}`\n"
msgstr ""
msgstr "// ERROR: no implementation for `{float} == {integer}`\n"
#: src/types-and-values/exercise.md
msgid ""
@ -3177,28 +3245,32 @@ msgid ""
"number is calculated recursively as the sum of the n-1'th and n-2'th "
"Fibonacci numbers."
msgstr ""
"Hai số Fibonacci đầu tiên mang giá trị `1`. Với n > 2, số Fibonacci thứ n sẽ "
"được tính đệ quy bằng với tổng của số Fibonacci thứ n - 1 và n - 2."
#: src/types-and-values/exercise.md
msgid ""
"Write a function `fib(n)` that calculates the n'th Fibonacci number. When "
"will this function panic?"
msgstr ""
"Hãy viết một hàm `fib(n)` để tính số Fibonacci thứ n. Khi nào thì hàm này sẽ "
"gây lỗi?"
#: src/types-and-values/exercise.md
msgid "// The base case.\n"
msgstr ""
msgstr "// Trường hợp dừng.\n"
#: src/types-and-values/exercise.md src/control-flow-basics/exercise.md
msgid "\"Implement this\""
msgstr ""
msgstr "\"Triển khai ở đây\""
#: src/types-and-values/exercise.md
msgid "// The recursive case.\n"
msgstr ""
msgstr "// Trường hợp đệ quy.\n"
#: src/types-and-values/exercise.md src/types-and-values/solution.md
msgid "\"fib({n}) = {}\""
msgstr ""
msgstr "\"fib({n}) = {}\""
#: src/control-flow-basics.md
msgid "if Expressions"