Skip to content

Commit 0332ade

Browse files
committed
translate: translations for services workers & pwa guides
- Translate ecosystem/service-workers guides to Spanish and update navigation labels Fixes #69
1 parent 1ed589d commit 0332ade

17 files changed

+2194
-677
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
@@ -915,7 +915,7 @@ const DOCS_SUB_NAVIGATION_DATA: NavigationItem[] = [
915915
],
916916
},
917917
{
918-
label: 'Extended Ecosystem',
918+
label: 'Ecosistema extendido',
919919
children: [
920920
{
921921
label: 'NgModules',
@@ -976,42 +976,42 @@ const DOCS_SUB_NAVIGATION_DATA: NavigationItem[] = [
976976
label: 'Service Workers & PWAs',
977977
children: [
978978
{
979-
label: 'Overview',
979+
label: 'Visión general',
980980
path: 'ecosystem/service-workers',
981981
contentPath: 'ecosystem/service-workers/overview',
982982
},
983983
{
984-
label: 'Getting started',
984+
label: 'Empezando',
985985
path: 'ecosystem/service-workers/getting-started',
986986
contentPath: 'ecosystem/service-workers/getting-started',
987987
},
988988
{
989-
label: 'Custom service worker scripts',
989+
label: 'Scripts de service worker personalizados',
990990
path: 'ecosystem/service-workers/custom-service-worker-scripts',
991991
contentPath: 'ecosystem/service-workers/custom-service-worker-scripts',
992992
},
993993
{
994-
label: 'Configuration file',
994+
label: 'Archivo de configuración',
995995
path: 'ecosystem/service-workers/config',
996996
contentPath: 'ecosystem/service-workers/config',
997997
},
998998
{
999-
label: 'Communicating with the service worker',
999+
label: 'Comunicación con el service worker',
10001000
path: 'ecosystem/service-workers/communications',
10011001
contentPath: 'ecosystem/service-workers/communications',
10021002
},
10031003
{
1004-
label: 'Push notifications',
1004+
label: 'Notificaciones push',
10051005
path: 'ecosystem/service-workers/push-notifications',
10061006
contentPath: 'ecosystem/service-workers/push-notifications',
10071007
},
10081008
{
1009-
label: 'Service worker devops',
1009+
label: 'Devops del service worker',
10101010
path: 'ecosystem/service-workers/devops',
10111011
contentPath: 'ecosystem/service-workers/devops',
10121012
},
10131013
{
1014-
label: 'App shell pattern',
1014+
label: 'Patrón App shell',
10151015
path: 'ecosystem/service-workers/app-shell',
10161016
contentPath: 'ecosystem/service-workers/app-shell',
10171017
},
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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+
<docs-code language="shell">
13+
14+
ng new my-app
15+
16+
</docs-code>
17+
18+
For an existing application, you have to manually add the `Router` and defining a `<router-outlet>` within your application.
19+
</docs-step>
20+
<docs-step title="Create the application shell">
21+
Use the Angular CLI to automatically create the application shell.
22+
23+
<docs-code language="shell">
24+
25+
ng generate app-shell
26+
27+
</docs-code>
28+
29+
For more information about this command, see [App shell command](cli/generate/app-shell).
30+
31+
The command updates the application code and adds extra files to the project structure.
32+
33+
<docs-code language="text">
34+
src
35+
├── app
36+
│ ├── app.config.server.ts # server application configuration
37+
│ └── app-shell # app-shell component
38+
│ ├── app-shell.component.html
39+
│ ├── app-shell.component.scss
40+
│ ├── app-shell.component.spec.ts
41+
│ └── app-shell.component.ts
42+
└── main.server.ts # main server application bootstrapping
43+
</docs-code>
44+
45+
<docs-step title="Verify the application is built with the shell content">
46+
47+
<docs-code language="shell">
48+
49+
ng build --configuration=development
50+
51+
</docs-code>
52+
53+
Or to use the production configuration.
54+
55+
<docs-code language="shell">
56+
57+
ng build
58+
59+
</docs-code>
60+
61+
To verify the build output, open <code class="no-auto-link">dist/my-app/browser/index.html</code>.
62+
Look for default text `app-shell works!` to show that the application shell route was rendered as part of the output.
63+
</docs-step>
64+
</docs-workflow>
Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,64 @@
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
<docs-code language="shell">
1313

1414
ng new my-app
1515

1616
</docs-code>
1717

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

2323
<docs-code language="shell">
2424

2525
ng generate app-shell
2626

2727
</docs-code>
2828

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

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

3333
<docs-code language="text">
3434
src
3535
├── app
36-
│ ├── app.config.server.ts # server application configuration
37-
│ └── app-shell # app-shell component
36+
│ ├── app.config.server.ts # configuración de la aplicación del servidor
37+
│ └── app-shell # componente app-shell
3838
│ ├── app-shell.component.html
3939
│ ├── app-shell.component.scss
4040
│ ├── app-shell.component.spec.ts
4141
│ └── app-shell.component.ts
42-
└── main.server.ts # main server application bootstrapping
42+
└── main.server.ts # arranque principal de la aplicación del servidor
4343
</docs-code>
4444

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

4747
<docs-code language="shell">
4848

4949
ng build --configuration=development
5050

5151
</docs-code>
5252

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

5555
<docs-code language="shell">
5656

5757
ng build
5858

5959
</docs-code>
6060

61-
To verify the build output, open <code class="no-auto-link">dist/my-app/browser/index.html</code>.
62-
Look for default text `app-shell works!` to show that the application shell route was rendered as part of the output.
61+
Para verificar el resultado de la compilación, abre <code class="no-auto-link">dist/my-app/browser/index.html</code>.
62+
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.
6363
</docs-step>
6464
</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)