Skip to content

Commit

Permalink
Translations - PT (#66)
Browse files Browse the repository at this point in the history
* Add translations to portuguese
  • Loading branch information
tarsil authored Jun 11, 2024
1 parent 9ef28cf commit 244b682
Show file tree
Hide file tree
Showing 56 changed files with 5,601 additions and 63 deletions.
2 changes: 1 addition & 1 deletion docs/en/docs/applications.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ requests (HTTP and Websockets).
* **permissions** - A list of [permissions](./permissions.md) to serve the application incoming
requests (HTTP and Websockets).
* **middleware** - A list of [middleware](./middleware.md) to run for every request. The middlewares can be subclasses of the [MiddlewareProtocol](./middleware.md#middlewareprotocol).
* **exception handlers** - A dictionary of [exception types](./exceptions.md) (or custom exceptions) and the handler
* **exception_handlers** - A dictionary of [exception types](./exceptions.md) (or custom exceptions) and the handler
functions on an application top level. Exception handler callables should be of the form of
`handler(request, exc) -> response` and may be be either standard functions, or async functions.
* **on_shutdown** - A list of callables to run on application shutdown. Shutdown handler callables do not take any
Expand Down
4 changes: 4 additions & 0 deletions docs/en/docs/clients/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Clients

Lilya has comes with [Directives](../directives/directives.md), a [test client](../test-client.md) and a
[native client](../lilya-cli.md) powered by click.
6 changes: 3 additions & 3 deletions docs/en/docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ Thank you for showing interes in contributing to Lilya. There are many ways you
project.

* Try Lilya and [report bugs and issues](https://github.com/dymmond/lilya/issues/new) you find.
* [Implement new features](https://github.com/dymmond/lilya/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22)
* Help othes by [reviewing pull requests](https://github.com/dymmond/lilya/pulls)
* Help writting documentation
* [Implement new features](https://github.com/dymmond/lilya/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22).
* Help othes by [reviewing pull requests](https://github.com/dymmond/lilya/pulls).
* Help writting documentation.
* Use the discussions and actively participate on them.
* Become an contributor by helping Lilya growing and spread the words across small, medium, large or any company
size.
Expand Down
4 changes: 4 additions & 0 deletions docs/en/docs/deployment/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Deployment

All the necessary information to run a simple and yet effective deployment can be found in
this section.
2 changes: 1 addition & 1 deletion docs/en/docs/directives/directives.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ A lot of people cannot be bothered with running cookiecutters and go straight to
provides some suggested options but it does not mean it should always be in that way. It simply serves as an
option.

Currently there are two built-in directives.
Currently there are a few built-in directives.

* [directives](#list-available-directives) - Lists all the available directives.
* [createproject](#create-project) - Used to generate a scaffold for a project.
Expand Down
3 changes: 1 addition & 2 deletions docs/en/docs/directives/discovery.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ This is the way that Lilya can `auto discover` your application.
Flask has a similar pattern for the functions called `create_app`. Lilya doesn't use the
`create_app`, instead uses the `get_application` or `get_app` as a pattern as it seems cleaner.


## Environment variables

When using some of the custom directives or built-in directives with this method, Lilya
Expand All @@ -94,7 +93,7 @@ When using some of the custom directives or built-in directives with this method
* **LILYA_DEFAULT_APP** - The Lilya application to run the directives against.

The reason for this is because every Lilya application might differ in structure and design.
Lilya not being opinionated in the way you should assemble, the application needs to know,
Lilya not being opinionated in the way you should assemble, the application needs to know
**at least where the entry-point is going be**.

Also, gives a clean design for the time when it is needed to go to production as the procedure is
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion docs/en/docs/exceptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Exception handlers are, as the name suggests, the handlers in case an exception
In every level the `exception_handler` parameter (among others) are available to be used and handle specific exeptions
raised on each level.

The exception handlers are read a python dictionary and you can pass the key as the exception itself or the `status_code`
The exception handlers are in read a python dictionary and you can pass the key as the exception itself or the `status_code`
that will always use the exception itself.

```python
Expand Down
5 changes: 5 additions & 0 deletions docs/en/docs/features/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Features

To build a full scalable application you will need something more than just a scaffold of an application.
Lilya comes with a set of features that is useful to any of those scenarios. Middleware, permissions and exception
handlers are just a few of those.
2 changes: 1 addition & 1 deletion docs/en/docs/deployment/intro.md → docs/en/docs/intro.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Introduction
# Deployment

Deploying an **Lilya** application is relatively easy.

Expand Down
2 changes: 1 addition & 1 deletion docs/en/docs/lilya-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Usage: lilya [OPTIONS] COMMAND [ARGS]...

Options:
--app TEXT Module path to the application to generate the migrations. In a
module:path formatyping.
module:path format.
--n TEXT The directive name to run.
--help Show this message and exit.

Expand Down
6 changes: 2 additions & 4 deletions docs/en/docs/middleware.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ the secure schemes instead.

### TrustedHostMiddleware

Enforces all requests to have a correct set `Host` header in order to protect against heost header attacks.
Enforces all requests to have a correct set `Host` header in order to protect against host header attacks.

```python
{!> ../../../docs_src/middleware/available/trusted_hosts.py !}
Expand Down Expand Up @@ -261,7 +261,7 @@ Let us assume the previous example of the `flask` app was inside `myapp/asgi_or_
{!> ../../../docs_src/middleware/available/wsgi_str.py !}
```

To call it inside the middleware is as simple as;
To call it inside the middleware is as simple as:

```python
{!> ../../../docs_src/middleware/available/wsgi_import.py !}
Expand All @@ -287,8 +287,6 @@ A middleware class for reading/generating request IDs and attaching them to appl
#### <a href="https://github.com/steinnes/timing-asgi">TimingMiddleware</a>

ASGI middleware to record and emit timing metrics (to something like statsd).
This integration works using [EsmeraldTimming](https://github.com/dymmond/esmerald-timing).


## Important points

Expand Down
6 changes: 0 additions & 6 deletions docs/en/docs/overrides/nav.html

This file was deleted.

1 change: 0 additions & 1 deletion docs/en/docs/requests.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ functions or libraries that expect a "file-like" object.
headers were included in the multipart field they will be included here. Note that these headers have no relationship with the headers in `Request.headers`.
* **size**: An `int` with uploaded file's size in bytes. This value is calculated from request's contents, making it better choice to find uploaded file's size than `Content-Length` header. None if not set.


The `DataUpload` class provides several asynchronous methods that invoke the corresponding
file operations using the internal `SpooledTemporaryFile`:

Expand Down
4 changes: 4 additions & 0 deletions docs/en/docs/resources/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Resources

These are the basic resources that Lilya can provide for you and from here you will
get the grasp of what you can do with it. From settings, context and responses to requests to routing and controllers.
2 changes: 1 addition & 1 deletion docs/en/docs/responses.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ changed if the `response_class` parameter is set to something else.
So, why is this `make_response` different from the other responses? Well, here its where Lilya shines.

Lilya is pure Python, which means that it does not rely or depend on external libraries like Pydantic,
msgspec, attrs or any other **but allows you to [build a custom encoder](#build-a-custom-encoder) that
msgspec, attrs or any other **but allows** you to [build a custom encoder](#build-a-custom-encoder) that
can later be used to serialise your response automatically and then passed to the `make_response`.

Check the [build a custom encoder](#build-a-custom-encoder) and [custom encoders with make_response](#custom-encoders-and-the-make_response)
Expand Down
2 changes: 1 addition & 1 deletion docs/en/docs/routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ parent order where the order is:
3. `InternalServerError : http_internal_server_error_handler`.
4. `NotAuthorized: http_not_authorized_handler`.

More than one exception handler can be added to each mapping.
**More than one exception handler can be added to each mapping.**

#### Permissions

Expand Down
6 changes: 1 addition & 5 deletions docs/en/docs/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ In every application, there arises a need for project-specific settings to ensur
As a project grows in complexity, and settings become dispersed throughout the codebase,
managing them can become challenging, leading to a potential organizational mess.

Lilya leverages [Dymmond Setings](https://settings.dymmond.com).

!!! warning
All the settings in Lilya use Python dataclasses.

Expand Down Expand Up @@ -165,7 +163,6 @@ anything else. Let us imagine the following:
{!> ../../../docs_src/applications/settings/settings_config/example1.py !}
```


**What is happenening here?**

In the example above we:
Expand All @@ -190,7 +187,6 @@ So the order of priority:
* `settings_module` takes priority above `LILYA_SETTINGS_MODULE`.
* `LILYA_SETTINGS_MODULE` is the last being checked.


## Settings config and Lilya settings module

The beauty of this modular approach is the fact that makes it possible to use **both** approaches at
Expand Down Expand Up @@ -323,5 +319,5 @@ to maintain.
!!! Check
When you pass the parameters via instantiation of a Lilya object and not via parameters, when accessing the
values via `request.app.settings`, the values **won't be in the settings** as those were passed via application
instantiation and not via settings object. The way to access those values is, for example, `request.app.debug`
instantiation and not via settings object. The way to access those values is, for example, via `request.app.debug`
directly.
71 changes: 39 additions & 32 deletions docs/en/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ site_description: The ASGI toolkit that delivers.
site_url: https://lilya.dev
theme:
name: material
custom_dir: docs/overrides
language: en
palette:
- scheme: default
Expand Down Expand Up @@ -68,41 +67,45 @@ plugins:
show_symbol_type_heading: true
show_symbol_type_toc: true
nav:
- Introduction: index.md
- Lilya:
- Applications: applications.md
- Settings: settings.md
- Routing: routing.md
- Controllers: controllers.md
- Requests: requests.md
- Responses: responses.md
- WebSockets: websockets.md
- Context: context.md
- index.md
- Resources:
- resources/index.md
- applications.md
- settings.md
- routing.md
- controllers.md
- requests.md
- responses.md
- websockets.md
- context.md
- Features:
- Tasks: tasks.md
- Lifespan: lifespan.md
- Middleware: middleware.md
- Permissions: permissions.md
- Static Files: static-files.md
- Templates: templates.md
- Server Push: server-push.md
- Exceptions & Exception Handlers: exceptions.md
- WSGI Frameworks: wsgi.md
- Environments: environments.md
- features/index.md
- tasks.md
- lifespan.md
- middleware.md
- permissions.md
- static-files.md
- templates.md
- server-push.md
- exceptions.md
- wsgi.md
- environments.md
- Clients:
- clients/index.md
- Lilya Client:
- Intro: lilya-cli.md
- Application Discovery: directives/discovery.md
- Directives: directives/directives.md
- Custom Directives: directives/custom-directives.md
- Shell: directives/shell.md
- Test Client: test-client.md
- lilya-cli.md
- directives/discovery.md
- directives/directives.md
- directives/custom-directives.md
- directives/shell.md
- test-client.md
- Deployment:
- Intro: deployment/intro.md
- Using docker: deployment/docker.md
- Contributing: contributing.md
- Sponsorship: sponsorship.md
- Release Notes: release-notes.md
- deployment/index.md
- intro.md
- docker.md
- contributing.md
- sponsorship.md
- release-notes.md
markdown_extensions:
- toc:
permalink: true
Expand All @@ -120,3 +123,7 @@ extra:
alternate:
- link: /
name: en - English
- link: /pt/
name: pt - português
hooks:
- ../../scripts/hooks.py
117 changes: 117 additions & 0 deletions docs/pt/docs/applications.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# Aplicações

Lilya traz uma classe chamada `Lilya` que encapsula toda a funcionalidade da aplicação.

```python
from lilya.apps import Lilya
```

Existem várias maneiras de criar uma aplicação Lilya, mas:

=== "Resumidamente"

```python
{!> ../../../docs_src/applications/nutshell.py !}
```

=== "Com Include"

```python
{!> ../../../docs_src/applications/with_include.py!}
```

## Testar usando o curl

```shell
$ curl -X GET http://localhost:8000/user/lilya
```
## Criar uma instância de uma aplicação

Criar uma instância de uma aplicação pode ser feito de diferentes maneiras e com uma grande vantagem de usar as
[configurações](./settings.md) para uma abordagem mais limpa.

**Parâmetros**:

* **debug** - Boolean que indica se deve retornar o *traceback* em caso de erro. Basicamente, modo de *debug*,
muito útil para desenvolvimento.
* **settings_module** - Uma instância ou definição de classe de [configurações](./settings.md) de onde os valores das configurações
serão lidos.
* **routes** - Uma lista de rotas que escutam pedidos HTTP e WebSocket recebidos.
Uma lista de [Path](./routing.md#path), [WebSocketPath](./routing.md#websocketpath), [Include](./routing.md#include) e
[Host](./routing.md#host).
* **permissions** - Uma lista de [permissões](./permissions.md) para atender aos pedidos de escutra da aplicação
(HTTP e WebSockets).
* **middleware** - Uma lista de [middlewares](./middleware.md) para serem executados para cada solicitação. Os middlewares podem ser subclasses do [MiddlewareProtocol](./middleware.md#middlewareprotocol).
* **exception_handlers** - Um dicionário de [tipos de exceção](./exceptions.md) (ou exceções personalizadas) e as
funções num nível superior da aplicação. As funções de exceção devem estar no formato
`handler(request, exc) -> response` e podem ser funções padrão ou funções assíncronas.
* **on_shutdown** - Uma lista de funções para serem executadas no encerramento da aplicação. As funções de encerramento não recebem nenhum
argumento e podem ser funções padrão ou funções assíncronas.
* **on_startup** - Uma lista de funções para serem executadas na inicialização da aplicação. As funções de inicialização não recebem nenhum
argumento e podem ser funções padrão ou funções assíncronas.
* **lifepan** - A função de contexto de vida útil é um estilo mais recente que substitui os *handlers* on_startup / on_shutdown.
Use um ou outro, não ambos.
* **include_in_schema** - Boolean para indicar se deve ser incluído no *schema** ou não. Isso pode ser útil
se estiver a descontinuar uma aplicação Lilya [Incluída](./routing.md#include) inteira em favor de uma nova. O *boolean*
deve indicar que todos os caminhos devem ser considerados obsoletos.
* **redirect_slashes** - Boolean para habilitar/desabilitar redirecionamento de barras para os *handlers*. Está activo por defeito.

## Configurações da aplicação

As configurações são outra forma de controlar os parâmetros passados para o objecto Lilya ao instanciar. Consulte as [configurações](./settings.md) para obter mais detalhes e como usá-las para potencializar sua aplicação.

Para aceder às configurações da aplicação, existem diferentes formas:

=== "Dentro do pedido da aplicação"

```python hl_lines="6"
{!> ../../../docs_src/applications/settings/within_app_request.py!}
```

=== "A partir das configurações globais"

```python hl_lines="1 6"
{!> ../../../docs_src/applications/settings/global_settings.py!}
```

## Estado e instância da aplicação

Pode armazenar um estado extra arbitrário na instância da aplicação utilizando o atributo `state`.

Exemplo:

```python hl_lines="6"
{!> ../../../docs_src/applications/app_state.py !}
```

## Aceder à instância da aplicação

A instância da aplicação está **sempre** disponível através de `request` ou através de `context`.

**Examplo**

```python
from lilya.apps import Lilya
from lilya.requests import Request
from lilya.context import Context
from lilya.routing import Path


# For request
def home_request(request: Request):
app = request.app
return {"message": "Welcome home"}


# For context
def home_context(context: Context):
app = context.app
return {"message": "Welcome home"}


app = Lilya(routes=[
Path("/request", home_request),
Path("/context", home_context),
]
)
```
Loading

0 comments on commit 244b682

Please sign in to comment.