Skip to content

Commit ce1a165

Browse files
ricardochlSplaktar
authored andcommitted
translate: translations for services workers & pwa guides
- Translate ecosystem/service-workers guides to Spanish and update navigation labels Fixes #69
1 parent 6be1468 commit ce1a165

17 files changed

+1994
-881
lines changed

adev-es/src/app/routing/sub-navigation-data.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,7 +1060,7 @@ const DOCS_SUB_NAVIGATION_DATA: NavigationItem[] = [
10601060
],
10611061
},
10621062
{
1063-
label: 'Extended Ecosystem',
1063+
label: 'Ecosistema Extendido',
10641064
children: [
10651065
{
10661066
label: 'NgModules',
@@ -1121,42 +1121,42 @@ const DOCS_SUB_NAVIGATION_DATA: NavigationItem[] = [
11211121
label: 'Service Workers & PWAs',
11221122
children: [
11231123
{
1124-
label: 'Overview',
1124+
label: 'Visión general',
11251125
path: 'ecosystem/service-workers',
11261126
contentPath: 'ecosystem/service-workers/overview',
11271127
},
11281128
{
1129-
label: 'Getting started',
1129+
label: 'Empezando',
11301130
path: 'ecosystem/service-workers/getting-started',
11311131
contentPath: 'ecosystem/service-workers/getting-started',
11321132
},
11331133
{
1134-
label: 'Custom service worker scripts',
1134+
label: 'Scripts de service worker personalizados',
11351135
path: 'ecosystem/service-workers/custom-service-worker-scripts',
11361136
contentPath: 'ecosystem/service-workers/custom-service-worker-scripts',
11371137
},
11381138
{
1139-
label: 'Configuration file',
1139+
label: 'Archivo de configuración',
11401140
path: 'ecosystem/service-workers/config',
11411141
contentPath: 'ecosystem/service-workers/config',
11421142
},
11431143
{
1144-
label: 'Communicating with the service worker',
1144+
label: 'Comunicación con el service worker',
11451145
path: 'ecosystem/service-workers/communications',
11461146
contentPath: 'ecosystem/service-workers/communications',
11471147
},
11481148
{
1149-
label: 'Push notifications',
1149+
label: 'Notificaciones push',
11501150
path: 'ecosystem/service-workers/push-notifications',
11511151
contentPath: 'ecosystem/service-workers/push-notifications',
11521152
},
11531153
{
1154-
label: 'Service worker devops',
1154+
label: 'Devops del service worker',
11551155
path: 'ecosystem/service-workers/devops',
11561156
contentPath: 'ecosystem/service-workers/devops',
11571157
},
11581158
{
1159-
label: 'App shell pattern',
1159+
label: 'Patrón App shell',
11601160
path: 'ecosystem/service-workers/app-shell',
11611161
contentPath: 'ecosystem/service-workers/app-shell',
11621162
},
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# App shell pattern
2+
3+
The [App shell pattern](https://developer.chrome.com/blog/app-shell) is a way to render a portion of your application using a route at build time.
4+
It can improve the user experience by quickly launching a static rendered page (a skeleton common to all pages) while the browser downloads the full client version and switches to it automatically after the code loads.
5+
6+
This gives users a meaningful first paint of your application that appears quickly because the browser can render the HTML and CSS without the need to initialize any JavaScript.
7+
8+
<docs-workflow>
9+
<docs-step title="Prepare the application">
10+
Do this with the following Angular CLI command:
11+
12+
```shell
13+
ng new my-app
14+
```
15+
16+
For an existing application, you have to manually add the `Router` and defining a `<router-outlet>` within your application.
17+
</docs-step>
18+
<docs-step title="Create the application shell">
19+
Use the Angular CLI to automatically create the application shell.
20+
21+
```shell
22+
ng generate app-shell
23+
```
24+
25+
For more information about this command, see [App shell command](cli/generate/app-shell).
26+
27+
The command updates the application code and adds extra files to the project structure.
28+
29+
<docs-code language="text">
30+
src
31+
├── app
32+
│ ├── app.config.server.ts # server application configuration
33+
│ └── app-shell # app-shell component
34+
│ ├── app-shell.component.html
35+
│ ├── app-shell.component.scss
36+
│ ├── app-shell.component.spec.ts
37+
│ └── app-shell.component.ts
38+
└── main.server.ts # main server application bootstrapping
39+
</docs-code>
40+
41+
<docs-step title="Verify the application is built with the shell content">
42+
43+
```shell
44+
ng build --configuration=development
45+
```
46+
47+
Or to use the production configuration.
48+
49+
```shell
50+
ng build
51+
```
52+
53+
To verify the build output, open <code class="no-auto-link">dist/my-app/browser/index.html</code>.
54+
Look for default text `app-shell works!` to show that the application shell route was rendered as part of the output.
55+
</docs-step>
56+
</docs-workflow>
Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,56 @@
1-
# App shell pattern
1+
# Patrón App shell
22

3-
The [App shell pattern](https://developer.chrome.com/blog/app-shell) is a way to render a portion of your application using a route at build time.
4-
It can improve the user experience by quickly launching a static rendered page (a skeleton common to all pages) while the browser downloads the full client version and switches to it automatically after the code loads.
3+
El [patrón App shell](https://developer.chrome.com/blog/app-shell) es una forma de renderizar una parte de tu aplicación usando una ruta en tiempo de compilación.
4+
Puede mejorar la experiencia de usuario al lanzar rápidamente una página estática renderizada (un esqueleto común a todas las páginas) mientras el navegador descarga la versión completa del cliente y cambia a ella automáticamente cuando el código termina de cargar.
55

6-
This gives users a meaningful first paint of your application that appears quickly because the browser can render the HTML and CSS without the need to initialize any JavaScript.
6+
Esto brinda a las personas usuarias un primer render significativo de tu aplicación que aparece rápidamente porque el navegador puede mostrar el HTML y el CSS sin necesidad de inicializar JavaScript.
77

88
<docs-workflow>
9-
<docs-step title="Prepare the application">
10-
Do this with the following Angular CLI command:
9+
<docs-step title="Preparar la aplicación">
10+
Hazlo con el siguiente comando de Angular CLI:
1111

1212
```shell
1313
ng new my-app
1414
```
1515

16-
For an existing application, you have to manually add the `Router` and defining a `<router-outlet>` within your application.
16+
Para una aplicación existente, debes agregar manualmente el `Router` y definir un `<router-outlet>` dentro de tu aplicación.
1717
</docs-step>
18-
<docs-step title="Create the application shell">
19-
Use the Angular CLI to automatically create the application shell.
18+
<docs-step title="Crear el shell de la aplicación">
19+
Usa Angular CLI para crear automáticamente el shell de la aplicación.
2020

2121
```shell
2222
ng generate app-shell
2323
```
2424

25-
For more information about this command, see [App shell command](cli/generate/app-shell).
25+
Para obtener más información sobre este comando, consulta [App shell command](cli/generate/app-shell).
2626

27-
The command updates the application code and adds extra files to the project structure.
27+
El comando actualiza el código de la aplicación y agrega archivos adicionales a la estructura del proyecto.
2828

2929
<docs-code language="text">
3030
src
3131
├── app
32-
│ ├── app.config.server.ts # server application configuration
33-
│ └── app-shell # app-shell component
32+
│ ├── app.config.server.ts # configuración de la aplicación del servidor
33+
│ └── app-shell # componente app-shell
3434
│ ├── app-shell.component.html
3535
│ ├── app-shell.component.scss
3636
│ ├── app-shell.component.spec.ts
3737
│ └── app-shell.component.ts
38-
└── main.server.ts # main server application bootstrapping
38+
└── main.server.ts # arranque principal de la aplicación del servidor
3939
</docs-code>
4040

41-
<docs-step title="Verify the application is built with the shell content">
41+
<docs-step title="Verificar que la aplicación se construye con el contenido del shell">
4242

4343
```shell
4444
ng build --configuration=development
4545
```
4646

47-
Or to use the production configuration.
47+
O usa la configuración de producción.
4848

4949
```shell
5050
ng build
5151
```
5252

53-
To verify the build output, open <code class="no-auto-link">dist/my-app/browser/index.html</code>.
54-
Look for default text `app-shell works!` to show that the application shell route was rendered as part of the output.
53+
Para verificar el resultado de la compilación, abre <code class="no-auto-link">dist/my-app/browser/index.html</code>.
54+
Busca el texto predeterminado `app-shell works!` para confirmar que la ruta del shell de la aplicación se renderizó como parte de la salida.
5555
</docs-step>
5656
</docs-workflow>
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# Communicating with the Service Worker
2+
3+
Enabling service worker support does more than just register the service worker; it also provides services you can use to interact with the service worker and control the caching of your application.
4+
5+
## `SwUpdate` service
6+
7+
The `SwUpdate` service gives you access to events that indicate when the service worker discovers and installs an available update for your application.
8+
9+
The `SwUpdate` service supports three separate operations:
10+
11+
- Receiving notifications when an updated version is _detected_ on the server, _installed and ready_ to be used locally or when an _installation fails_.
12+
- Asking the service worker to check the server for new updates.
13+
- Asking the service worker to activate the latest version of the application for the current tab.
14+
15+
### Version updates
16+
17+
The `versionUpdates` is an `Observable` property of `SwUpdate` and emits five event types:
18+
19+
| Event types | Details |
20+
| :------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
21+
| `VersionDetectedEvent` | Emitted when the service worker has detected a new version of the app on the server and is about to start downloading it. |
22+
| `NoNewVersionDetectedEvent` | Emitted when the service worker has checked the version of the app on the server and did not find a new version. |
23+
| `VersionReadyEvent` | Emitted when a new version of the app is available to be activated by clients. It may be used to notify the user of an available update or prompt them to refresh the page. |
24+
| `VersionInstallationFailedEvent` | Emitted when the installation of a new version failed. It may be used for logging/monitoring purposes. |
25+
| `VersionFailedEvent` | Emitted when a version encounters a critical failure (such as broken hash errors) that affects all clients using that version. Provides error details for debugging and transparency. |
26+
27+
<docs-code header="log-update.service.ts" path="adev/src/content/examples/service-worker-getting-started/src/app/log-update.service.ts" visibleRegion="sw-update"/>
28+
29+
### Checking for updates
30+
31+
It's possible to ask the service worker to check if any updates have been deployed to the server.
32+
The service worker checks for updates during initialization and on each navigation request —that is, when the user navigates from a different address to your application.
33+
However, you might choose to manually check for updates if you have a site that changes frequently or want updates to happen on a schedule.
34+
35+
Do this with the `checkForUpdate()` method:
36+
37+
<docs-code header="check-for-update.service.ts" path="adev/src/content/examples/service-worker-getting-started/src/app/check-for-update.service.ts"/>
38+
39+
This method returns a `Promise<boolean>` which indicates if an update is available for activation.
40+
The check might fail, which will cause a rejection of the `Promise`.
41+
42+
<docs-callout important title="Stabilization and service worker registration">
43+
In order to avoid negatively affecting the initial rendering of the page, by default the Angular service worker service waits for up to 30 seconds for the application to stabilize before registering the ServiceWorker script.
44+
45+
Constantly polling for updates, for example, with [setInterval()](https://developer.mozilla.org/docs/Web/API/WindowOrWorkerGlobalScope/setInterval) or RxJS' [interval()](https://rxjs.dev/api/index/function/interval), prevents the application from stabilizing and the ServiceWorker script is not registered with the browser until the 30 seconds upper limit is reached.
46+
47+
This is true for any kind of polling done by your application.
48+
Check the [isStable](api/core/ApplicationRef#isStable) documentation for more information.
49+
50+
Avoid that delay by waiting for the application to stabilize first, before starting to poll for updates, as shown in the preceding example.
51+
Alternatively, you might want to define a different [registration strategy](api/service-worker/SwRegistrationOptions#registrationStrategy) for the ServiceWorker.
52+
</docs-callout>
53+
54+
### Updating to the latest version
55+
56+
You can update an existing tab to the latest version by reloading the page as soon as a new version is ready.
57+
To avoid disrupting the user's progress, it is generally a good idea to prompt the user and let them confirm that it is OK to reload the page and update to the latest version:
58+
59+
<docs-code header="prompt-update.service.ts" path="adev/src/content/examples/service-worker-getting-started/src/app/prompt-update.service.ts" visibleRegion="sw-version-ready"/>
60+
61+
<docs-callout important title="Safety of updating without reloading">
62+
Calling `activateUpdate()` updates a tab to the latest version without reloading the page, but this could break the application.
63+
64+
Updating without reloading can create a version mismatch between the application shell and other page resources, such as lazy-loaded chunks, whose filenames may change between versions.
65+
66+
You should only use `activateUpdate()`, if you are certain it is safe for your specific use case.
67+
</docs-callout>
68+
69+
### Handling an unrecoverable state
70+
71+
In some cases, the version of the application used by the service worker to serve a client might be in a broken state that cannot be recovered from without a full page reload.
72+
73+
For example, imagine the following scenario:
74+
75+
1. A user opens the application for the first time and the service worker caches the latest version of the application.
76+
Assume the application's cached assets include `index.html`, `main.<main-hash-1>.js` and `lazy-chunk.<lazy-hash-1>.js`.
77+
78+
1. The user closes the application and does not open it for a while.
79+
1. After some time, a new version of the application is deployed to the server.
80+
This newer version includes the files `index.html`, `main.<main-hash-2>.js` and `lazy-chunk.<lazy-hash-2>.js`.
81+
82+
IMPORTANT: The hashes are different now, because the content of the files changed. The old version is no longer available on the server.
83+
84+
1. In the meantime, the user's browser decides to evict `lazy-chunk.<lazy-hash-1>.js` from its cache.
85+
Browsers might decide to evict specific (or all) resources from a cache in order to reclaim disk space.
86+
87+
1. The user opens the application again.
88+
The service worker serves the latest version known to it at this point, namely the old version (`index.html` and `main.<main-hash-1>.js`).
89+
90+
1. At some later point, the application requests the lazy bundle, `lazy-chunk.<lazy-hash-1>.js`.
91+
1. The service worker is unable to find the asset in the cache (remember that the browser evicted it).
92+
Nor is it able to retrieve it from the server (because the server now only has `lazy-chunk.<lazy-hash-2>.js` from the newer version).
93+
94+
In the preceding scenario, the service worker is not able to serve an asset that would normally be cached.
95+
That particular application version is broken and there is no way to fix the state of the client without reloading the page.
96+
In such cases, the service worker notifies the client by sending an `UnrecoverableStateEvent` event.
97+
Subscribe to `SwUpdate#unrecoverable` to be notified and handle these errors.
98+
99+
<docs-code header="handle-unrecoverable-state.service.ts" path="adev/src/content/examples/service-worker-getting-started/src/app/handle-unrecoverable-state.service.ts" visibleRegion="sw-unrecoverable-state"/>
100+
101+
## More on Angular service workers
102+
103+
You might also be interested in the following:
104+
105+
<docs-pill-row>
106+
<docs-pill href="ecosystem/service-workers/push-notifications" title="Push notifications"/>
107+
<docs-pill href="ecosystem/service-workers/devops" title="Service Worker devops"/>
108+
</docs-pill-row>

0 commit comments

Comments
 (0)