1
0
mirror of https://github.com/actix/examples synced 2024-11-23 22:41:07 +01:00
examples/templating/fluent
2022-12-21 14:49:28 +00:00
..
locales add fluent templates example 2022-07-10 03:30:48 +01:00
src add actorless websocket echo example 2022-07-11 01:44:46 +01:00
templates add fluent templates example 2022-07-10 03:30:48 +01:00
Cargo.toml Use workspace dependencies for actix-web (#594) 2022-12-21 14:49:28 +00:00
README.md add fluent templates example 2022-07-10 03:30:48 +01:00

Fluent Templates

This is an example of how to integrate Fluent Templates with Actix Web using the Handlebars templating engine.

Directory Structure

  • src: Rust source code for web server and endpoint configuration
  • templates: Handlebars templates (no text content is stored in the templates)
  • locales: Fluent files containing translations for English (en) and French (fr)

Usage

cd templating/fluent
cargo run

After starting the server, you may visit the following pages:

This example implements language selection using the standard Accept-Language header, which is sent by browsers according to OS/browser settings. To view the translated pages, pass the Accept-Encoding header with en or fr. Values which do not have associated translation files will fall back to English.

# using HTTPie
http :8080/Alice/documents Accept-Language:fr

# using cURL
curl http://localhost:8080/Alice/documents -H 'accept-language: fr'