chore(i18n,curriculum): update translations (#44227)

This commit is contained in:
camperbot
2021-11-22 09:25:21 -08:00
committed by GitHub
parent 8cab69a433
commit 2ef9ecfb4d
27 changed files with 285 additions and 237 deletions

View File

@@ -1,6 +1,6 @@
---
id: 589fc831f9fc0f352b528e76
title: Handle a Disconnect
title: Maneja una desconexión
challengeType: 2
forumTopicId: 301552
dashedName: handle-a-disconnect
@@ -8,9 +8,9 @@ dashedName: handle-a-disconnect
# --description--
You may notice that up to now you have only been increasing the user count. Handling a user disconnecting is just as easy as handling the initial connect, except you have to listen for it on each socket instead of on the whole server.
Puedes observar que hasta ahora sólo has aumentado el recuento de usuarios. Manejar la desconexión de un usuario es tan fácil como manejar la conexión inicial, excepto que tienes que escucharlo en cada socket en lugar de en todo el servidor.
To do this, add another listener inside the existing `'connect'` listener that listens for `'disconnect'` on the socket with no data passed through. You can test this functionality by just logging that a user has disconnected to the console.
Para ello, añade otro oyente (listener) dentro del oyente existente `'connect'` que escuche `'disconnect'` en el socket sin que pasen datos. Puedes probar esta funcionalidad simplemente registrando que un usuario se ha desconectado en la consola.
```js
socket.on('disconnect', () => {
@@ -18,15 +18,15 @@ socket.on('disconnect', () => {
});
```
To make sure clients continuously have the updated count of current users, you should decrease the currentUsers by 1 when the disconnect happens then emit the 'user count' event with the updated count!
Para asegurarse de que los clientes tienen continuamente el recuento actualizado de los usuarios actuales, ¡debes disminuir el currentUsers en 1 cuando se produce la desconexión y luego emitir el evento 'user count' con el recuento actualizado!
**Note:** Just like `'disconnect'`, all other events that a socket can emit to the server should be handled within the connecting listener where we have 'socket' defined.
**Nota:** Al igual que `'disconnect'`, todos los demás eventos que un socket puede emitir al servidor deben ser manejados dentro del oyente de conexión donde tenemos definido 'socket'.
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/ab1007b76069884fb45b215d3c4496fa).
Envía tu página cuando creas que lo has hecho bien. Si te encuentras con errores, puedes revisar el proyecto completado hasta este punto [aquí](https://gist.github.com/camperbot/ab1007b76069884fb45b215d3c4496fa).
# --hints--
Server should handle the event disconnect from a socket.
El servidor debe manejar la desconexión del evento de un socket.
```js
(getUserInput) =>
@@ -40,7 +40,7 @@ Server should handle the event disconnect from a socket.
);
```
Your client should be listening for 'user count' event.
Tu cliente debe estar escuchando el evento 'user count'.
```js
(getUserInput) =>

View File

@@ -1,6 +1,6 @@
---
id: 5895f70ef9fc0f352b528e6b
title: How to Put a Profile Together
title: Cómo elaborar un perfil
challengeType: 2
forumTopicId: 301554
dashedName: how-to-put-a-profile-together
@@ -8,27 +8,27 @@ dashedName: how-to-put-a-profile-together
# --description--
Now that we can ensure the user accessing the `/profile` is authenticated, we can use the information contained in `req.user` on our page!
Ahora que podemos asegurarnos de que el usuario que accede al `/profile` está autenticado, ¡podemos utilizar la información contenida en `req.user` en nuestra página!
Pass an object containing the property `username` and value of `req.user.username` as the second argument for the render method of the profile view. Then, go to your `profile.pug` view, and add the following line below the existing `h1` element, and at the same level of indentation:
Pasa un objeto que contenga la propiedad `username` y el valor de `req.user.username` como segundo argumento para el método render de la vista de perfil. Luego, ve a tu perfil `profile.pug` y agrega la siguiente línea debajo del elemento existente `h1` y al mismo nivel de indentación:
```pug
h2.center#welcome Welcome, #{username}!
```
This creates an `h2` element with the class '`center`' and id '`welcome`' containing the text '`Welcome,`' followed by the username.
Esto crea un elemento `h2` con la clase '`center`' e id '`welcome`' conteniendo el texto '`Welcome,`' seguido por el nombre de usuario.
Also, in `profile.pug`, add a link referring to the `/logout` route, which will host the logic to unauthenticate a user.
Además, en `profile.pug`, añade un enlace que haga referencia a la ruta `/logout`, que alojará la lógica para des-autentificar a un usuario.
```pug
a(href='/logout') Logout
```
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/136b3ad611cc80b41cab6f74bb460f6a).
Envía tu página cuando creas que lo has hecho bien. Si te encuentras con errores, puedes revisar el proyecto completado hasta este punto [aquí](https://gist.github.com/camperbot/136b3ad611cc80b41cab6f74bb460f6a).
# --hints--
You should correctly add a Pug render variable to /profile.
Debes agregar correctamente una variable de renderizado Pug a /profile.
```js
(getUserInput) =>

View File

@@ -1,6 +1,6 @@
---
id: 5895f70df9fc0f352b528e69
title: How to Use Passport Strategies
title: Cómo utilizar las estrategias de Passport
challengeType: 2
forumTopicId: 301555
dashedName: how-to-use-passport-strategies
@@ -8,21 +8,21 @@ dashedName: how-to-use-passport-strategies
# --description--
In the `index.pug` file supplied, there is actually a login form. It has previously been hidden because of the inline JavaScript `if showLogin` with the form indented after it. Before `showLogin` as a variable was never defined, so it never rendered the code block containing the form. Go ahead and on the `res.render` for that page add a new variable to the object `showLogin: true`. When you refresh your page, you should then see the form! This form is set up to **POST** on `/login`, so this is where we should set up to accept the POST and authenticate the user.
En el archivo `index.pug` proporcionado, hay realmente un formulario de inicio de sesión. Anteriormente ha estado oculto debido al JavaScript inline `if showLogin` con el formulario indentado después de él. Antes `showLogin` como variable nunca se definía, por lo que nunca renderizaba el bloque de código que contenía el formulario. Sigue adelante y en el `res.render` de esa página añade una nueva variable al objeto `showLogin: true`. Cuando actualices la página, ¡deberías ver el formulario! Este formulario está configurado para hacer una petición **POST** en `/login`, así que aquí es donde debemos configurar para aceptar el POST y autentificar al usuario.
For this challenge you should add the route `/login` to accept a POST request. To authenticate on this route, you need to add a middleware to do so before then sending a response. This is done by just passing another argument with the middleware before your `function(req,res)` with your response! The middleware to use is `passport.authenticate('local')`.
Para este desafío debes añadir la ruta `/login` para aceptar una petición POST. Para autentificarse en esta ruta, es necesario añadir un middleware para hacerlo antes de enviar una respuesta. ¡Esto se hace simplemente pasando otro argumento con el middleware antes de tu `function(req,res)` con tu respuesta! El middleware a usar es `passport.authenticate('local')`.
`passport.authenticate` can also take some options as an argument such as: `{ failureRedirect: '/' }` which is incredibly useful, so be sure to add that in as well. The response after using the middleware (which will only be called if the authentication middleware passes) should be to redirect the user to `/profile` and that route should render the view `profile.pug`.
`passport.authenticate` también puede tomar algunas opciones como un argumento como: `{ failureRedirect: '/' }` que es increíblemente útil, así que asegúrate de añadirlo también. La respuesta después de usar el middleware (que sólo se llamará si el middleware de autentificación pasa) debe ser redirigir al usuario a `/profile` y esa ruta debe renderizar el perfil `profile.pug`.
If the authentication was successful, the user object will be saved in `req.user`.
Si la autentificación fue exitosa, el user object se guardará en `req.user`.
At this point, if you enter a username and password in the form, it should redirect to the home page `/`, and the console of your server should display `'User {USERNAME} attempted to log in.'`, since we currently cannot login a user who isn't registered.
En este punto, si introduces un nombre de usuario y una contraseña en el formulario, debe redirigirse a la página de inicio `/`, y la consola de tu servidor debe mostrar `'User {USERNAME} attempted to log in.'`, ya que actualmente no podemos iniciar la sesión de un usuario que no está registrado.
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/7ad011ac54612ad53188b500c5e99cb9).
Envía tu página cuando creas que lo has hecho bien. Si te encuentras con errores, puedes revisar el proyecto completado hasta este punto [aquí](https://gist.github.com/camperbot/7ad011ac54612ad53188b500c5e99cb9).
# --hints--
All steps should be correctly implemented in the server.js.
Todos los pasos deben ser correctamente implementados en el server.js.
```js
(getUserInput) =>
@@ -50,7 +50,7 @@ All steps should be correctly implemented in the server.js.
);
```
A POST request to /login should correctly redirect to /.
Una solicitud POST a /login debe redirigir correctamente a /.
```js
(getUserInput) =>