chore(i8n,learn): processed translations

This commit is contained in:
Crowdin Bot
2021-02-06 04:42:36 +00:00
committed by Mrugesh Mohapatra
parent 15047f2d90
commit e5c44a3ae5
3274 changed files with 172122 additions and 14164 deletions

View File

@@ -1,6 +1,6 @@
---
id: 589fc832f9fc0f352b528e78
title: 宣布新用户
title: Announce New Users
challengeType: 2
forumTopicId: 301546
dashedName: announce-new-users
@@ -8,7 +8,9 @@ dashedName: announce-new-users
# --description--
许多聊天室都有这个功能:所有已连接到服务器的在线用户都会看到有人加入或退出的提醒。我们已经写好了处理连接和断开事件的代码,只要对这个方法稍作修改就可以实现这个功能。在事件中,我们需要发送这三条信息:连接或断开的用户名、当前用户数量、事件类型(即需要知道用户究竟是连接还是断开)。 请将事件名称更改为 `'user'`,其中应包含如下字段:'name'、'currentUsers'、'connected'(布尔值,连接上即为 `true`,断开则是 `false`)。记得要修改之前我们写好的处理 'user count' 的那部分代码,现在我们应在用户连接时传入布尔值 `true`;在用户断开连接是传入布尔值 `false`
Many chat rooms are able to announce when a user connects or disconnects and then display that to all of the connected users in the chat. Seeing as though you already are emitting an event on connect and disconnect, you will just have to modify this event to support such a feature. The most logical way of doing so is sending 3 pieces of data with the event: the name of the user who connected/disconnected, the current user count, and if that name connected or disconnected.
Change the event name to `'user'`, and pass an object along containing the fields 'name', 'currentUsers', and 'connected' (to be `true` in case of connection, or `false` for disconnection of the user sent). Be sure to change both 'user count' events and set the disconnect one to send `false` for the field 'connected' instead of `true` like the event emitted on connect.
```js
io.emit('user', {
@@ -18,7 +20,9 @@ io.emit('user', {
});
```
现在,我们的客户端已经有足够的信息显示现有用户数量和发送用户上下线通知。接下来我们需要在客户端监听 'user' 事件,然后使用 jQuery 把 `#num-users` 节点的文本内容更新为 '{NUMBER} users online'。同时,我们需要为 `<ul>` 添加一个 id 为 'messages' 且带有 '{NAME} has {joined/left} the chat.' 文本的`<li>`。 一种实现方式如下:
Now your client will have all the necessary information to correctly display the current user count and announce when a user connects or disconnects! To handle this event on the client side we should listen for `'user'`, then update the current user count by using jQuery to change the text of `#num-users` to `'{NUMBER} users online'`, as well as append a `<li>` to the unordered list with id `messages` with `'{NAME} has {joined/left} the chat.'`.
An implementation of this could look like the following:
```js
socket.on('user', data => {
@@ -30,11 +34,11 @@ socket.on('user', data => {
});
```
完成上述要求后,你可以在下方提交你的页面链接。如果你遇到了问题,可以参考 [这里](https://gist.github.com/camperbot/bf95a0f74b756cf0771cd62c087b8286) 的答案。
Submit your page when you think you've got it right. If you're running into errors, you can check out the project completed up to this point [here](https://gist.github.com/camperbot/bf95a0f74b756cf0771cd62c087b8286).
# --hints--
`'user'` 事件应发送包含 namecurrentUsersconnected 字段的对象。
Event `'user'` should be emitted with name, currentUsers, and connected.
```js
(getUserInput) =>
@@ -52,7 +56,7 @@ socket.on('user', data => {
);
```
客户端应处理和显示 `'user'` 对象中的信息
Client should properly handle and display the new data from event `'user'`.
```js
(getUserInput) =>