Skip to content

Commit 6bd3b4c

Browse files
oidacraSplaktar
authored andcommitted
translate: add translations for Angular libraries documentation
This commit includes translations for the Angular libraries overview, creating libraries, and using libraries sections, enhancing accessibility for Spanish-speaking developers.
1 parent 9d60fa7 commit 6bd3b4c

File tree

8 files changed

+1284
-380
lines changed

8 files changed

+1284
-380
lines changed

adev-es/src/content/tools/libraries/angular-package-format.en.md

Lines changed: 385 additions & 0 deletions
Large diffs are not rendered by default.

adev-es/src/content/tools/libraries/angular-package-format.md

Lines changed: 163 additions & 163 deletions
Large diffs are not rendered by default.

adev-es/src/content/tools/libraries/creating-libraries.en.md

Lines changed: 291 additions & 0 deletions
Large diffs are not rendered by default.

adev-es/src/content/tools/libraries/creating-libraries.md

Lines changed: 137 additions & 138 deletions
Large diffs are not rendered by default.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Overview of Angular libraries
2+
3+
Many applications need to solve the same general problems, such as presenting a unified user interface, presenting data, and allowing data entry.
4+
Developers can create general solutions for particular domains that can be adapted for re-use in different applications.
5+
Such a solution can be built as Angular *libraries* and these libraries can be published and shared as *npm packages*.
6+
7+
An Angular library is an Angular project that differs from an application in that it cannot run on its own.
8+
A library must be imported and used in an application.
9+
10+
Libraries extend Angular's base features.
11+
For example, to add [reactive forms](guide/forms/reactive-forms) to an application, add the library package using `ng add @angular/forms`, then import the `ReactiveFormsModule` from the `@angular/forms` library in your application code.
12+
Similarly, adding the [service worker](ecosystem/service-workers) library to an Angular application is one of the steps for turning an application into a [Progressive Web App](https://developers.google.com/web/progressive-web-apps) \(PWA\).
13+
[Angular Material](https://material.angular.dev) is an example of a large, general-purpose library that provides sophisticated, reusable, and adaptable UI components.
14+
15+
Any application developer can use these and other libraries that have been published as npm packages by the Angular team or by third parties.
16+
See [Using Published Libraries](tools/libraries/using-libraries).
17+
18+
HELPFUL: Libraries are intended to be used by Angular applications. To add Angular features to non-Angular web applications, use [Angular custom elements](guide/elements).
19+
20+
## Creating libraries
21+
22+
If you have developed features that are suitable for reuse, you can create your own libraries.
23+
These libraries can be used locally in your workspace, or you can publish them as [npm packages](reference/configs/npm-packages) to share with other projects or other Angular developers.
24+
These packages can be published to the npm registry, a private npm Enterprise registry, or a private package management system that supports npm packages.
25+
See [Creating Libraries](tools/libraries/creating-libraries).
26+
27+
Deciding to package features as a library is an architectural decision. It is comparable to deciding whether a feature is a component or a service, or deciding on the scope of a component.
28+
29+
Packaging features as a library forces the artifacts in the library to be decoupled from the application's business logic.
30+
This can help to avoid various bad practices or architecture mistakes that can make it difficult to decouple and reuse code in the future.
31+
32+
Putting code into a separate library is more complex than simply putting everything in one application.
33+
It requires more of an investment in time and thought for managing, maintaining, and updating the library.
34+
This complexity can pay off when the library is being used in multiple applications.
Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
1-
# Overview of Angular libraries
1+
# Visión general de las librerías de Angular
22

3-
Many applications need to solve the same general problems, such as presenting a unified user interface, presenting data, and allowing data entry.
4-
Developers can create general solutions for particular domains that can be adapted for re-use in different applications.
5-
Such a solution can be built as Angular *libraries* and these libraries can be published and shared as *npm packages*.
3+
Muchas aplicaciones necesitan resolver los mismos problemas generales, como presentar una interfaz de usuario unificada, presentar datos y permitir la entrada de datos.
4+
Los desarrolladores pueden crear soluciones generales para dominios particulares que pueden ser adaptadas para reutilización en diferentes aplicaciones.
5+
Tales soluciones pueden construirse como *librerías* de Angular y estas librerías pueden publicarse y compartirse como *paquetes npm*.
66

7-
An Angular library is an Angular project that differs from an application in that it cannot run on its own.
8-
A library must be imported and used in an application.
7+
Una librería de Angular es un proyecto de Angular que difiere de una aplicación en que no puede ejecutarse por sí sola.
8+
Una librería debe importarse y usarse en una aplicación.
99

10-
Libraries extend Angular's base features.
11-
For example, to add [reactive forms](guide/forms/reactive-forms) to an application, add the library package using `ng add @angular/forms`, then import the `ReactiveFormsModule` from the `@angular/forms` library in your application code.
12-
Similarly, adding the [service worker](ecosystem/service-workers) library to an Angular application is one of the steps for turning an application into a [Progressive Web App](https://developers.google.com/web/progressive-web-apps) \(PWA\).
13-
[Angular Material](https://material.angular.dev) is an example of a large, general-purpose library that provides sophisticated, reusable, and adaptable UI components.
10+
Las librerías extienden las características base de Angular.
11+
Por ejemplo, para agregar [formularios reactivos](guide/forms/reactive-forms) a una aplicación, agrega el paquete de la librería usando `ng add @angular/forms`, luego importa el `ReactiveFormsModule` desde la librería `@angular/forms` en el código de tu aplicación.
12+
De manera similar, agregar la librería de [service worker](ecosystem/service-workers) a una aplicación de Angular es uno de los pasos para convertir una aplicación en una [Aplicación Web Progresiva](https://developers.google.com/web/progressive-web-apps) \(PWA\).
13+
[Angular Material](https://material.angular.dev) es un ejemplo de una librería grande y de propósito general que proporciona componentes de interfaz de usuario sofisticados, reutilizables y adaptables.
1414

15-
Any application developer can use these and other libraries that have been published as npm packages by the Angular team or by third parties.
16-
See [Using Published Libraries](tools/libraries/using-libraries).
15+
Cualquier desarrollador de aplicaciones puede usar estas y otras librerías que han sido publicadas como paquetes npm por el equipo de Angular o por terceros.
16+
Consulta [Usando librerías publicadas](tools/libraries/using-libraries).
1717

18-
HELPFUL: Libraries are intended to be used by Angular applications. To add Angular features to non-Angular web applications, use [Angular custom elements](guide/elements).
18+
ÚTIL: Las librerías están destinadas a ser usadas por aplicaciones de Angular. Para agregar características de Angular a aplicaciones web que no son Angular, usa [elementos personalizados de Angular](guide/elements).
1919

20-
## Creating libraries
20+
## Creando librerías
2121

22-
If you have developed features that are suitable for reuse, you can create your own libraries.
23-
These libraries can be used locally in your workspace, or you can publish them as [npm packages](reference/configs/npm-packages) to share with other projects or other Angular developers.
24-
These packages can be published to the npm registry, a private npm Enterprise registry, or a private package management system that supports npm packages.
25-
See [Creating Libraries](tools/libraries/creating-libraries).
22+
Si has desarrollado características que son adecuadas para reutilización, puedes crear tus propias librerías.
23+
Estas librerías pueden usarse localmente en tu espacio de trabajo, o puedes publicarlas como [paquetes npm](reference/configs/npm-packages) para compartirlas con otros proyectos u otros desarrolladores de Angular.
24+
Estos paquetes pueden publicarse en el registro de npm, un registro privado de npm Enterprise, o un sistema privado de gestión de paquetes que soporte paquetes npm.
25+
Consulta [Creando librerías](tools/libraries/creating-libraries).
2626

27-
Deciding to package features as a library is an architectural decision. It is comparable to deciding whether a feature is a component or a service, or deciding on the scope of a component.
27+
Decidir empaquetar características como una librería es una decisión arquitectónica. Es comparable a decidir si una característica es un componente o un servicio, o decidir el alcance de un componente.
2828

29-
Packaging features as a library forces the artifacts in the library to be decoupled from the application's business logic.
30-
This can help to avoid various bad practices or architecture mistakes that can make it difficult to decouple and reuse code in the future.
29+
Empaquetar características como una librería fuerza a que los artefactos en la librería estén desacoplados de la lógica de negocio de la aplicación.
30+
Esto puede ayudar a evitar varias malas prácticas o errores arquitectónicos que pueden dificultar el desacoplamiento y reutilización del código en el futuro.
3131

32-
Putting code into a separate library is more complex than simply putting everything in one application.
33-
It requires more of an investment in time and thought for managing, maintaining, and updating the library.
34-
This complexity can pay off when the library is being used in multiple applications.
32+
Poner código en una librería separada es más complejo que simplemente poner todo en una aplicación.
33+
Requiere más inversión en tiempo y reflexión para gestionar, mantener y actualizar la librería.
34+
Esta complejidad puede valer la pena cuando la librería está siendo usada en múltiples aplicaciones.
Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
# Usage of Angular libraries published to npm
2+
3+
When you build your Angular application, take advantage of sophisticated first-party libraries, as well as a rich ecosystem of third-party libraries.
4+
[Angular Material][AngularMaterialMain] is an example of a sophisticated first-party library.
5+
6+
## Install libraries
7+
8+
Libraries are published as [npm packages][GuideNpmPackages], usually together with schematics that integrate them with the Angular CLI.
9+
To integrate reusable library code into an application, you need to install the package and import the provided functionality in the location you use it.
10+
For most published Angular libraries, use the `ng add <lib_name>` Angular CLI command.
11+
12+
The `ng add` Angular CLI command uses a package manager to install the library package and invokes schematics that are included in the package to other scaffolding within the project code.
13+
Examples of package managers include [npm][NpmjsMain] or [yarn][YarnpkgMain].
14+
Additional scaffolding within the project code includes import statements, fonts, and themes.
15+
16+
A published library typically provides a `README` file or other documentation on how to add that library to your application.
17+
For an example, see the [Angular Material][AngularMaterialMain] documentation.
18+
19+
### Library typings
20+
21+
Typically, library packages include typings in `.d.ts` files; see examples in `node_modules/@angular/material`.
22+
If the package of your library does not include typings and your IDE complains, you might need to install the `@types/<lib_name>` package with the library.
23+
24+
For example, suppose you have a library named `d3`:
25+
26+
<docs-code language="shell">
27+
28+
npm install d3 --save
29+
npm install @types/d3 --save-dev
30+
31+
</docs-code>
32+
33+
Types defined in a `@types/` package for a library installed into the workspace are automatically added to the TypeScript configuration for the project that uses that library.
34+
TypeScript looks for types in the `node_modules/@types` directory by default, so you do not have to add each type package individually.
35+
36+
If a library does not have typings available at `@types/`, you may use it by manually adding typings for it.
37+
To do this:
38+
39+
1. Create a `typings.d.ts` file in your `src/` directory.
40+
This file is automatically included as global type definition.
41+
42+
1. Add the following code in `src/typings.d.ts`:
43+
44+
<docs-code language="typescript">
45+
46+
declare module 'host' {
47+
export interface Host {
48+
protocol?: string;
49+
hostname?: string;
50+
pathname?: string;
51+
}
52+
export function parse(url: string, queryString?: string): Host;
53+
}
54+
55+
</docs-code>
56+
57+
1. In the component or file that uses the library, add the following code:
58+
59+
<docs-code language="typescript">
60+
61+
import * as host from 'host';
62+
const parsedUrl = host.parse('https://angular.dev');
63+
console.log(parsedUrl.hostname);
64+
65+
</docs-code>
66+
67+
Define more typings as needed.
68+
69+
## Updating libraries
70+
71+
A library is able to be updated by the publisher, and also has individual dependencies which need to be kept current.
72+
To check for updates to your installed libraries, use the [`ng update`][CliUpdate] Angular CLI command.
73+
74+
Use `ng update <lib_name>` Angular CLI command to update individual library versions.
75+
The Angular CLI checks the latest published release of the library, and if the latest version is newer than your installed version, downloads it and updates your `package.json` to match the latest version.
76+
77+
When you update Angular to a new version, you need to make sure that any libraries you are using are current.
78+
If libraries have interdependencies, you might have to update them in a particular order.
79+
See the [Angular Update Guide][AngularUpdateMain] for help.
80+
81+
## Adding a library to the runtime global scope
82+
83+
If a legacy JavaScript library is not imported into an application, you may add it to the runtime global scope and load it as if it was added in a script tag.
84+
Configure the Angular CLI to do this at build time using the `scripts` and `styles` options of the build target in the [`angular.json`][GuideWorkspaceConfig] workspace build configuration file.
85+
86+
For example, to use the [Bootstrap 4][GetbootstrapDocs40GettingStartedIntroduction] library
87+
88+
1. Install the library and the associated dependencies using the npm package manager:
89+
90+
<docs-code language="shell">
91+
92+
npm install jquery --save
93+
npm install popper.js --save
94+
npm install bootstrap --save
95+
96+
</docs-code>
97+
98+
1. In the `angular.json` configuration file, add the associated script files to the `scripts` array:
99+
100+
<docs-code language="json">
101+
102+
"scripts": [
103+
"node_modules/jquery/dist/jquery.slim.js",
104+
"node_modules/popper.js/dist/umd/popper.js",
105+
"node_modules/bootstrap/dist/js/bootstrap.js"
106+
],
107+
108+
</docs-code>
109+
110+
1. Add the `bootstrap.css` CSS file to the `styles` array:
111+
112+
<docs-code language="css">
113+
114+
"styles": [
115+
"node_modules/bootstrap/dist/css/bootstrap.css",
116+
"src/styles.css"
117+
],
118+
119+
</docs-code>
120+
121+
1. Run or restart the `ng serve` Angular CLI command to see Bootstrap 4 work in your application.
122+
123+
### Using runtime-global libraries inside your app
124+
125+
After you import a library using the "scripts" array, do **not** import it using an import statement in your TypeScript code.
126+
The following code snippet is an example import statement.
127+
128+
<docs-code language="typescript">
129+
130+
import * as $ from 'jquery';
131+
132+
</docs-code>
133+
134+
If you import it using import statements, you have two different copies of the library: one imported as a global library, and one imported as a module.
135+
This is especially bad for libraries with plugins, like JQuery, because each copy includes different plugins.
136+
137+
Instead, run the `npm install @types/jquery` Angular CLI command to download typings for your library and then follow the library installation steps.
138+
This gives you access to the global variables exposed by that library.
139+
140+
### Defining typings for runtime-global libraries
141+
142+
If the global library you need to use does not have global typings, you can declare them manually as `any` in `src/typings.d.ts`.
143+
144+
For example:
145+
146+
<docs-code language="typescript">
147+
148+
declare var libraryName: any;
149+
150+
</docs-code>
151+
152+
Some scripts extend other libraries; for instance with JQuery plugins:
153+
154+
<docs-code language="typescript">
155+
156+
$('.test').myPlugin();
157+
158+
</docs-code>
159+
160+
In this case, the installed `@types/jquery` does not include `myPlugin`, so you need to add an interface in `src/typings.d.ts`.
161+
For example:
162+
163+
<docs-code language="typescript">
164+
165+
interface JQuery {
166+
myPlugin(options?: any): any;
167+
}
168+
169+
</docs-code>
170+
171+
If you do not add the interface for the script-defined extension, your IDE shows an error:
172+
173+
<docs-code language="text">
174+
175+
[TS][Error] Property 'myPlugin' does not exist on type 'JQuery'
176+
177+
</docs-code>
178+
179+
[CliUpdate]: cli/update "ng update | CLI |Angular"
180+
181+
[GuideNpmPackages]: reference/configs/npm-packages "Workspace npm dependencies | Angular"
182+
183+
[GuideWorkspaceConfig]: reference/configs/workspace-config "Angular workspace configuration | Angular"
184+
185+
[Resources]: resources "Explore Angular Resources | Angular"
186+
187+
[AngularMaterialMain]: https://material.angular.dev "Angular Material | Angular"
188+
189+
[AngularUpdateMain]: https://angular.dev/update-guide "Angular Update Guide | Angular"
190+
191+
[GetbootstrapDocs40GettingStartedIntroduction]: https://getbootstrap.com/docs/4.0/getting-started/introduction "Introduction | Bootstrap"
192+
193+
[NpmjsMain]: https://www.npmjs.com "npm"
194+
195+
[YarnpkgMain]: https://yarnpkg.com " Yarn"

0 commit comments

Comments
 (0)