Skip to content

Commit

Permalink
docs(spanish): spanish version of the documentation (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
dockfries committed May 29, 2024
2 parents ee4803e + 974258c commit 125327c
Show file tree
Hide file tree
Showing 21 changed files with 1,112 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

The name "Infernus" comes from the vehicle id 411 in the game.

NodeJS library for scripting [Open Multiplayer](https://open.mp).
Node.js library for scripting [Open Multiplayer](https://open.mp).

Highly recommended to get started with the [infernus-starter](https://github.com/dockfries/infernus-starter) template.

Expand Down
2 changes: 2 additions & 0 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ import { defineConfig } from "vitepress";
import { shared } from "./shared";
import { en_US } from "./en-US";
import { zh_CN } from "./zh-CN";
import { es_ES } from "./es-ES";

export default defineConfig({
...shared,
locales: {
root: { label: "English", ...en_US },
"zh-CN": { label: "简体中文", ...zh_CN },
"es-ES": { label: "Español", ...es_ES }
},
});
2 changes: 1 addition & 1 deletion docs/.vitepress/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { defineConfig, type DefaultTheme } from "vitepress";

export const en_US = defineConfig({
lang: "en-US",
description: "NodeJS library for scripting Open Multiplayer",
description: "Node.js library for scripting Open Multiplayer",
themeConfig: {
nav: nav(),

Expand Down
110 changes: 110 additions & 0 deletions docs/.vitepress/es-ES.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import { defineConfig, type DefaultTheme } from "vitepress";

export const es_ES = defineConfig({
lang: "es-ES",
description:
"Librería de Node.js para la creación de scripts en Open Multiplayer",
themeConfig: {
nav: nav(),

sidebar: [
{ base: "/es-ES/", text: "Comenzar", items: sidebarGuide() },
{
base: "/es-ES/essentials/",
text: "Esenciales",
items: sidebarEssentials(),
},
{ base: "/es-ES/plugins/", text: "Plugins", items: sidebarPlugins() },
],

editLink: {
pattern: "https://github.com/dockfries/infernus/edit/main/docs/:path",
text: "Editar esta página en GitHub",
},

darkModeSwitchLabel: "Cambiar apariencia",
docFooter: {
next: "Siguiente",
prev: "Anterior",
},
lastUpdatedText: "Última actualización",
outlineTitle: "Navegación de la página",
returnToTopLabel: "Volver al principio",
sidebarMenuLabel: "Menú",
},
});

function nav(): DefaultTheme.NavItem[] {
return [
{ text: "Inicio", link: "/es-ES/" },
{ text: "Open Multiplayer", link: "https://open.mp/es" },
{
text: "Plugins",
items: [
{
text: "samp-node",
link: "https://github.com/AmyrAhmady/samp-node",
},
{
text: "Streamer",
link: "https://github.com/samp-incognito/samp-streamer-plugin",
},
{
text: "RakNet",
link: "https://github.com/katursis/Pawn.RakNet",
},
{
text: "MapAndreas",
link: "https://github.com/philip1337/samp-plugin-mapandreas",
},
{
text: "ColAndreas",
link: "https://github.com/Pottus/ColAndreas",
},
],
},
];
}

function sidebarGuide(): DefaultTheme.SidebarItem[] {
return [
{ text: "Introducción", link: "introduction" },
{ text: "Inicio rápido", link: "quick-start" },
];
}

function sidebarEssentials(): DefaultTheme.SidebarItem[] {
return [
{ text: "Eventos", link: "events" },
{ text: "Ciclo de vida", link: "life-cycle" },
{ text: "Internacionalización", link: "i18n" },
{ text: "Diálogos", link: "dialogs" },
{ text: "Características", link: "features" },
{ text: "Uso", link: "use" },
];
}

function sidebarPlugins(): DefaultTheme.SidebarItem[] {
return [{ text: "Introducción", link: "introduction" }];
}

export const search = {
"es-ES": {
translations: {
button: {
buttonText: "Buscar en la documentación",
buttonAriaLabel: "Buscar en la documentación",
},
modal: {
noResultsText: "No se encontraron resultados",
resetButtonTitle: "Restablecer consulta",
displayDetails: "Ver lista de detalles",
footer: {
selectText: "Seleccionar",
closeText: "Cerrar",
navigateText: "Navegar",
},
},
},
},
};
3 changes: 2 additions & 1 deletion docs/.vitepress/shared.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { defineConfig } from "vitepress";
import { search as zhSearch } from "./zh-CN";
import { search as esSearch } from "./es-ES";

export const shared = defineConfig({
base: "/infernus/",
Expand All @@ -14,7 +15,7 @@ export const shared = defineConfig({
search: {
provider: "local",
options: {
locales: { ...zhSearch },
locales: { ...zhSearch, ...esSearch },
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion docs/.vitepress/zh-CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { defineConfig, type DefaultTheme } from "vitepress";

export const zh_CN = defineConfig({
lang: "zh-CN",
description: "用于编写Open Multiplayer脚本的NodeJS库",
description: "用于编写Open Multiplayer脚本的Node.js库",
themeConfig: {
nav: nav(),

Expand Down
74 changes: 74 additions & 0 deletions docs/es-ES/essentials/dialogs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Diálogos

El diálogo es una función de uso común en el proceso de desarrollo. `Infernus` proporciona soporte orientado a objetos y **async**, para que puedas usarlo de forma más elegante.

Al mismo tiempo, en términos generales, ya no es necesario seguir el `id` del diálogo de la forma tradicional, y el código se generará aleatoriamente.

El tradicional evento de callback `PlayerEvent.OnDialogResponse` puede seguir siendo utilizado, pero no es recomendable.

## Ejemplo

Con el ejemplo, puede utilizar diálogos de forma elegante y continua para almacenar la lógica relevante en el mismo segmento de código, en lugar de tan complejo como el desarrollo nativo en el pasado.

### Comprobación de registro

```ts
import { PlayerEvent, Dialog, DialogStylesEnum } from "@infernus/core";

PlayerEvent.onCommandText("registro", async ({ player, next }) => {
const dialog = new Dialog({
style: DialogStylesEnum.PASSWORD,
caption: "Registro",
info: "Por favor, ingresa la contraseña",
button1: "ok",
});

const { inputText: password } = await dialog.show(player);

// Puede reutilizar una instancia de diálogo existente, modificar su información y volver a utilizarla más adelante.
// Hay muchos setter además de info.
dialog.info = "Por favor, ingresa la contraseña nuevamente";

const { inputText: againPassword } = await dialog.show(player);

if (password !== againPassword) {
player.sendClientMessage(
"#f00",
"La contraseña que ha introducido dos veces no es la misma, inténtelo de nuevo."
);
}

return next();
});
```

### Cerrar diálogo

```ts
import { PlayerEvent, Player, Dialog } from "@infernus/core";

PlayerEvent.onCommandText("cerrarDialogo", ({ player, subcommand, next }) => {
const [playerId] = subcommand;

if (!playerId) {
player.sendClientMessage(
"#f00",
"Introduzca el cuadro de diálogo del jugador que desea cerrar"
);
return next();
}

// Los comandos introducidos por el jugador son todos cadenas, por lo que es necesario convertir el tipo a un tipo numérico.
const closePlayer = Player.getInstance(+playerId);

if (!closePlayer) {
player.sendClientMessage("#f00", "El jugador no está conectado.");
} else {
// Método estático de diálogo
Dialog.close(closePlayer);
player.sendClientMessage("#ff0", "Has cerrado el diálogo del jugador.");
}

return next();
});
```
Loading

0 comments on commit 125327c

Please sign in to comment.