Skip to content

Commit e99429c

Browse files
committed
docs(docs-infra): traduccion de service-worker-getting-started.md
Realice la traduccion al español del archivo service-worker-getting-started Fix angular-hispano#177
1 parent a2aa45d commit e99429c

File tree

1 file changed

+65
-70
lines changed

1 file changed

+65
-70
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,166 +1,161 @@
1-
# Getting started with service workers
1+
# Comenzando con los Trabajadores de Servicio
22

33

4-
This document explains how to enable Angular service worker support in projects that you created with the [Angular CLI](cli). It then uses a simple example to show you a service worker in action, demonstrating loading and basic caching.
4+
Este documento explica como habilitar el soporte de Trabajadores de Servicio Angular en proyectos que creaste con [Angular CLI](cli). Luego usa un ejemplo simple para mostrarle un trabajador de servicio en acción demostrando la carga y almacenamiento en caché básico.
55

6-
#### Prerequisites
6+
#### Prerequisitos
77

8-
A basic understanding of the information in [Introduction to Angular service workers](guide/service-worker-intro).
8+
Una comprensión básica de la información en [Introduction to Angular service workers](guide/service-worker-intro).
99

1010

11-
## Adding a service worker to your project
11+
## Agregando un trabajador de servicio a tu proyecto
1212

13-
To set up the Angular service worker in your project, use the CLI command `ng add @angular/pwa`. It takes care of configuring your app to use service workers by adding the `service-worker` package along
14-
with setting up the necessary support files.
13+
Para configurar un trabajador de servicio Angular en su proyecto, use el comando CLI `ng add @angular/pwa`. Se encarga de configurar su aplicación para usar trabajador de servicio agregando el paquete `service-worker` junto con la preparación de los archivos de soporte necesarios.
1514

1615
```sh
1716
ng add @angular/pwa --project *project-name*
1817
```
1918

20-
The above command completes the following actions:
19+
El anterior comando completa las siguientes accciones:
2120

22-
1. Adds the `@angular/service-worker` package to your project.
23-
2. Enables service worker build support in the CLI.
24-
3. Imports and registers the service worker in the app module.
25-
4. Updates the `index.html` file:
26-
* Includes a link to add the `manifest.webmanifest` file.
27-
* Adds meta tags for `theme-color`.
28-
5. Installs icon files to support the installed Progressive Web App (PWA).
29-
6. Creates the service worker configuration file called [`ngsw-config.json`](/guide/service-worker-config), which specifies the caching behaviors and other settings.
21+
1. Agrega el paquete `@angular/service-worker` en su proyecto.
22+
2. Habilita el soporte de trabajador de servicio en la interfaz de línea de comandos.
23+
3. importa y registra el trabajador de servicio en el módulo de la aplicación.
24+
4. Actualiza el archivo `index.html`:
25+
* Incluye un enlace para agregar el archivo `manifest.webmanifest`.
26+
* Agrega metaetiquetas para `theme-color`.
27+
5. Instala archivos de iconos para soportar la aplición web progresiva (PWA) instalada.
28+
6. Crea el archivo de configuración de trabajador de servicio llamado [`ngsw-config.json`](/guide/service-worker-config), el cual especifica los comportamientos de almacenamiento en caché y otras configuraciones.
3029

3130

32-
Now, build the project:
31+
Ahora, crear el proyecto:
3332

3433
```sh
3534
ng build --prod
3635
```
3736

38-
The CLI project is now set up to use the Angular service worker.
37+
El proyecto CLI está ahora preparado para usar trabajador de servicio de Angular.
3938

39+
## Trabajador de servicio en acción: un recorrido
4040

41-
## Service worker in action: a tour
41+
Esta sección demuestra un trabajador de servicio en acción, usando una aplicación ejemplo.
4242

43-
This section demonstrates a service worker in action,
44-
using an example application.
43+
### Sirviendo con `http-server`
4544

46-
### Serving with `http-server`
45+
Debido a que `ng serve` no funciona con trabajador de servicios, debe usar un servidor HTTP separado para probar su proyecto localmente. Puede usar cualquier servidor HTTP. El siguiente ejemplo usa el paquete[http-server](https://www.npmjs.com/package/http-server) de npm. Para reducir la posibilidad de conflictos y evitar servir contenido obsoleto, pruebe en un puerto dedicado y deshabilite el almacenamiento en caché.
4746

48-
Because `ng serve` does not work with service workers, you must use a separate HTTP server to test your project locally. You can use any HTTP server. The example below uses the [http-server](https://www.npmjs.com/package/http-server) package from npm. To reduce the possibility of conflicts and avoid serving stale content, test on a dedicated port and disable caching.
49-
50-
To serve the directory containing your web files with `http-server`, run the following command:
47+
Para servir el directorio que contiene sus archivos web con `http-server`, ejecute el siguiente comando:
5148

5249
```sh
5350
http-server -p 8080 -c-1 dist/<project-name>
5451
```
5552

56-
### Initial load
53+
### Carga inicial
5754

58-
With the server running, you can point your browser at http://localhost:8080/. Your application should load normally.
55+
Con el servidor en ejecución, puede apuntar su navegador a http://localhost:8080/. Su aplicación debería cargarse normalmente.
5956

60-
**Tip:** When testing Angular service workers, it's a good idea to use an incognito or private window in your browser to ensure the service worker doesn't end up reading from a previous leftover state, which can cause unexpected behavior.
57+
**Consejo** Cuando pruebe trabajador de servicios de Angular, es una buena idea usar una ventana privada o de incognito en su navegador para asegurarse de que el trabajador de servicio no termine leyendo de un estado sobrante anterior, el cual puede causar un comportamiento inesperado.
6158

6259
<div class="alert is-helpful">
6360

64-
**Note:**
65-
If you are not using HTTPS, the service worker will only be registered when accessing the app on `localhost`.
61+
**Nota:*
62+
Si no está utilizando HTTPS, el trabajador de servicio solo se registrará cuando acceda a la aplicación en `localhost`.
6663

6764
</div>
6865

69-
### Simulating a network issue
66+
### Simulando un problema de red
7067

71-
To simulate a network issue, disable network interaction for your application. In Chrome:
68+
Para simular un problema de red, deshabilite la interacción de red para su aplicación: En Chrome:
7269

73-
1. Select **Tools** > **Developer Tools** (from the Chrome menu located at the top right corner).
74-
2. Go to the **Network tab**.
75-
3. Check the **Offline box**.
70+
1. Seleccione **Herramientas** > **Herramientas de desarrollador** (desde el menu de Chrome ubicado en la esquina superior derecha).
71+
2. Vaya a **pestaña red**.
72+
3. Compruebe que **caja esté desactivada**
7673

7774
<div class="lightbox">
78-
<img src="generated/images/guide/service-worker/offline-checkbox.png" alt="The offline checkbox in the Network tab is checked">
75+
<img src="generated/images/guide/service-worker/offline-checkbox.png" alt="The offline checkbox in the Network tab is checked">
7976
</div>
8077

81-
Now the app has no access to network interaction.
78+
Ahora la aplicación no tiene acceso a la interacción de red.
8279

83-
For applications that do not use the Angular service worker, refreshing now would display Chrome's Internet disconnected page that says "There is no Internet connection".
80+
Para aplicaciones que no usen trabajador de servicio de Angular, la actualización ahora mostraría la página de desconectado de Chrome que dice "No hay conexión a internet".
8481

85-
With the addition of an Angular service worker, the application behavior changes. On a refresh, the page loads normally.
82+
Con la incorporación de un trabajador de servicio Angular, el comportamiento de la aplicación cambia. En una actualización, la página carga normarmente.
8683

87-
If you look at the Network tab, you can verify that the service worker is active.
84+
Si observa la pestaña de red, puede verificar que trabajador de servicio esté activo.
8885

8986
<div class="lightbox">
9087
<img src="generated/images/guide/service-worker/sw-active.png" alt="Requests are marked as from ServiceWorker">
9188
</div>
9289

93-
Notice that under the "Size" column, the requests state is `(from ServiceWorker)`. This means that the resources are not being loaded from the network. Instead, they are being loaded from the service worker's cache.
90+
Note que debajo de la columna "Tamaño", el estado de las solicitudes es `(from ServiceWorker)`. Esto significa que los recursos no estan siendo cargados desde la red. En su lugar estan siendo cargados desde la memoria caché del service worker.
9491

9592

96-
### What's being cached?
93+
### Qué esta siendo almacenado en caché?
9794

98-
Notice that all of the files the browser needs to render this application are cached. The `ngsw-config.json` boilerplate configuration is set up to cache the specific resources used by the CLI:
95+
Note que todos los archivos que el navegador necesita para procesar esta aplicación son almacenados en caché. La configuración estándar `ngsw-config.json` está preparada para almacenar los recursos específicos usados por el CLI:
9996

10097
* `index.html`.
10198
* `favicon.ico`.
102-
* Build artifacts (JS and CSS bundles).
103-
* Anything under `assets`.
104-
* Images and fonts directly under the configured `outputPath` (by default `./dist/<project-name>/`) or `resourcesOutputPath`. See [`ng build`](cli/build) for more information about these options.
99+
* Construir artefactos (paquetes JS y CSS).
100+
* Cualquier cosa bajo `assets`.
101+
* Imagenes y fuentes directamente bajo el `outputPath` configurado (por defecto `./dist/<project-name>/`) o `resourcesOutputPath`. Mire [`ng build`](cli/build) para más información acerca de estas opciones.
105102

106103

107104
<div class="alert is-helpful">
108-
Pay attention to two key points:
105+
Preste atención a dos puntos clave:
109106

110-
1. The generated `ngsw-config.json` includes a limited list of cacheable fonts and images extentions. In some cases, you might want to modify the glob pattern to suit your needs.
107+
1. El `ngsw-config.json` generado incluye una lista limitada de fuentes almacenables en caché y extensiones de imágenes. En algunos casos podrías querer modificar el patrón global para adaptarlo a sus necesidades.
111108

112-
1. If `resourcesOutputPath` or `assets` paths are modified after the generation of configuration file, you need to change the paths manually in `ngsw-config.json`.
109+
2. Si las rutas `resourcesOutputPath` o `assets` son modificadas después de la generación del archivo de configuración, necesita cambiar las rutas manualmente en `ngsw-config.json`.
113110
</div>
114111

115-
### Making changes to your application
112+
### Haciendo cambios en su aplicación
116113

117-
Now that you've seen how service workers cache your application, the
118-
next step is understanding how updates work.
114+
Ahora que ha visto como trabajadores de servicio alamcenan su aplicación, el próximo paso es entender como funcionan las actualizaciones.
119115

120-
1. If you're testing in an incognito window, open a second blank tab. This will keep the incognito and the cache state alive during your test.
116+
1. Si esta probando en una ventana de incónito, abra una segunda pestaña en blanco. Esto mantendrá vivo el incógnito y el estado de cache durante la prueba.
121117

122-
2. Close the application tab, but not the window. This should also close the Developer Tools.
118+
2. Cierre la pestaña de la aplicación, pero no la ventana. Este también debería cerrar las herramientas de desarrollador.
123119

124-
3. Shut down `http-server`.
120+
3. Apague `http-server`.
125121

126-
4. Next, make a change to the application, and watch the service worker install the update.
122+
4. A continuación, realice un cambio en la aplicación, y observe como el trabajador de servicio instala la actualización.
127123

128-
5. Open `src/app/app.component.html` for editing.
124+
5. Abra `src/app/app.component.html` para editarlo.
129125

130-
6. Change the text `Welcome to {{title}}!` to `Bienvenue à {{title}}!`.
126+
6. Cambie el texto `Welcome to {{title}}!` a `Bienvenue à {{title}}!`.
131127

132-
7. Build and run the server again:
128+
7. Cree y ejecute el servidor nuevamente.
133129

134130
```sh
135131
ng build --prod
136132
http-server -p 8080 -c-1 dist/<project-name>
137133
```
134+
### Actualizando su aplicación en el navegador
138135

139-
### Updating your application in the browser
140-
141-
Now look at how the browser and service worker handle the updated application.
136+
Ahora observe como el navegador y el trabajador de servicio manejan la aplicación actulizada.
142137

143-
1. Open http://localhost:8080 again in the same window. What happens?
138+
1. Abra http://localhost:8080 nuevamente en la misma ventana. Qué sucede?
144139

145140
<div class="lightbox">
146141
<img src="generated/images/guide/service-worker/welcome-msg-en.png" alt="It still says Welcome to Service Workers!">
147142
</div>
148143

149-
What went wrong? Nothing, actually. The Angular service worker is doing its job and serving the version of the application that it has **installed**, even though there is an update available. In the interest of speed, the service worker doesn't wait to check for updates before it serves the application that it has cached.
144+
¿Qué salio mal? Nada en realidad. El trabajador de servicio de Angular está haciendo este trabajo y entregando la versión de la aplicación que tiene **instalada** aunque hay una actualización disponible. En aras de la velocidad, el trabajador de servicio no espera para verificar actualizaciones antes de servir la aplicación que tiene almacenado en caché.
150145

151-
If you look at the `http-server` logs, you can see the service worker requesting `/ngsw.json`. This is how the service worker checks for updates.
146+
Si observa los registros de `http-server`, puede ver el trabajador de servicio solicitando `/ngsw.json`. Así es como el trabajador de servicio busca actualizaciones.
152147

153-
2. Refresh the page.
148+
2. Recargue la página.
154149

155150
<div class="lightbox">
156151
<img src="generated/images/guide/service-worker/welcome-msg-fr.png" alt="The text has changed to say Bienvenue à app!">
157152
</div>
158153

159-
The service worker installed the updated version of your app *in the background*, and the next time the page is loaded or reloaded, the service worker switches to the latest version.
154+
El trabajador de servicio instaló la versión actualizada de su aplicación *en segundo plano*, y la próxima vez que la página es carguada o recargada, el trabajador de servicio cambia a la última versión.
160155

161156
<hr />
162157

163-
## More on Angular service workers
158+
## Más sobre trabajadores de servicio de Angular
164159

165-
You may also be interested in the following:
166-
* [Communicating with service workers](guide/service-worker-communications).
160+
También le puede interesar lo siguiente:
161+
* [Comunicarse con los trabajadores de servicio](guide/service-worker-communications).

0 commit comments

Comments
 (0)