Skip to content

Commit 6de0a8c

Browse files
docs:26-dịch-3-basic-sveltekit-shared-modules (#60)
* docs:26-dịch-3-basic-sveltekit-shared-modules * Update content/tutorial/03-sveltekit/05-shared-modules/meta.json Co-authored-by: Quang Phan <[email protected]> * Update content/tutorial/03-sveltekit/05-shared-modules/01-lib/README.md Co-authored-by: Quang Phan <[email protected]> * Update content/tutorial/03-sveltekit/05-shared-modules/01-lib/README.md Co-authored-by: Quang Phan <[email protected]> --------- Co-authored-by: Quang Phan <[email protected]>
1 parent 90d73d3 commit 6de0a8c

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

content/tutorial/03-sveltekit/05-shared-modules/01-lib/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
---
2-
title: The $lib alias
2+
title: Tên gọi $lib
33
---
44

5-
Because SvelteKit uses directory-based routing, it's easy to place modules and components alongside the routes that use them. A good rule of thumb is 'put code close to where it's used'.
5+
Bởi vì SvelteKit sử dụng route _(định tuyến)_ dựa trên thư mục, nên việc đặt các module và components gần các route sử dụng chúng sẽ tiện hơn. Có một quy tắc là 'đặt mã gần nơi sử dụng nó'.
66

7-
Sometimes, code is used in multiple places. When this happens, it's useful to have a place to put them that can be accessed by all routes without needing to prefix imports with `../../../../`. In SvelteKit, that place is the `src/lib` directory. Anything inside this directory can be accessed by any module in `src` via the `$lib` alias.
7+
Đôi khi, mã được sử dụng ở nhiều nơi trong dự án. Trong tình huống này, Sẽ tiện hơn nếu ta đặt mã ở một nơi mà tất cả các route có thể truy cập được và không phải thêm `../../../` vào đầu lệnh import. Trong SvelteKit, đó là thư mục `src/lib`. Bất cứ thứ gì bên trong thư mục này có thể được truy cập bởi bất kỳ mô-đun nào trong `src` thông qua tên `$lib`.
88

9-
Both `+page.svelte` files in this exercise import `src/lib/message.js`. But if you navigate to `/a/deeply/nested/route`, the app breaks, because we got the prefix wrong. Update it to use `$lib/message.js` instead:
9+
Cả hai tệp `+page.svelte` trong bài tập này đều import `src/lib/message.js`. Nhưng nếu bạn chuyển đến `/a/deeply/nested/route`, ứng dụng sẽ gặp lỗi, vì chúng ta đã điền sai tiền tố. Hãy sửa nó lại thành `$lib/message.js`:
1010

1111
```svelte
1212
/// file: src/routes/a/deeply/nested/route/+page.svelte
1313
<script>
1414
import { message } from +++'$lib/message.js'+++;
1515
</script>
1616
17-
<h1>a deeply nested route</h1>
17+
<h1>một route nằm sâu</h1>
1818
<p>{message}</p>
1919
```
2020

21-
Do the same for `src/routes/+page.svelte`:
21+
Làm tương tự cho `src/routes/+page.svelte`:
2222

2323
```svelte
2424
/// file: src/routes/+page.svelte
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const message = 'hello from $lib/message';
1+
export const message = 'Xin chào từ $lib/message';
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<nav>
22
<a href="/">home</a>
3-
<a href="/a/deeply/nested/route">a deeply nested route</a>
3+
<a href="/a/deeply/nested/route">một route nằm sâu</a>
44
</nav>
55

66
<slot />

content/tutorial/03-sveltekit/05-shared-modules/01-lib/app-a/src/routes/a/deeply/nested/route/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
import { message } from '../../../../../../lib/message.js';
33
</script>
44

5-
<h1>a deeply nested route</h1>
5+
<h1>amột route nằm sâu</h1>
66
<p>{message}</p>

content/tutorial/03-sveltekit/05-shared-modules/01-lib/app-b/src/routes/a/deeply/nested/route/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
import { message } from '$lib/message.js';
33
</script>
44

5-
<h1>a deeply nested route</h1>
5+
<h1>một route nằm sâu</h1>
66
<p>{message}</p>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"title": "Shared modules"
2+
"title": "module được chia sẻ"
33
}

0 commit comments

Comments
 (0)