Expand description
Localized routes for Laravel Rust: one route per language, translated paths, resources, and the
hreflang alternates of every page.
ⓘ
use laralang::{LocalizedRoute, locales};
pub fn routes(route: &mut Router) {
LocalizedRoute::get(route, "dashboard", locales!["en", "es" => "panel"], dashboard).name("dashboard");
}That serves /dashboard in English and /es/panel in Spanish, and laralang::route("dashboard", ())
is the URL in the language of the request.
The current locale is laralocale’s: this crate sets it from the URL prefix and reads it to build
URLs, and keeps no locale of its own. Laravel Rust 0.1 has no named routes, so the localized
routes are recorded in a Registry that gives them names.
It is the port of the PHP package edulazaro/laralang to
Laravel Rust 0.1 (beta), and its API follows the framework’s changes until 1.0.
Re-exports§
pub use alternates::Alternates;pub use alternates::alternates;pub use alternates::alternates_head;pub use alternates::alternates_with;pub use alternates::laralang_alternates;pub use config::LaralangConfig;pub use fallback::localized_fallback;pub use locales::LocaleDefinition;pub use locales::Locales;pub use middleware::SetBrowserLocale;pub use middleware::SetRouteLocale;pub use middleware::SetSessionLocale;pub use middleware::SetSmartLocale;pub use params::IntoParams;pub use params::Params;pub use prefixes::LocalePrefixes;pub use provider::LaralangServiceProvider;pub use registry::Entry;pub use registry::Registry;pub use registry::Settings;pub use resource::LocalizedResource;pub use resource::ResourceHandlers;pub use route::LocalizedGroup;pub use route::LocalizedRoute;pub use url::has;pub use url::route;pub use url::route_is;pub use url::route_with;pub use ziggy::ziggy;
Modules§
Macros§
- locales
- Write the locales of a route as PHP does: a bare locale reuses the route’s path, and
"es" => "panel"gives that locale its own.
Functions§
- merge_
alternates - Merge the
hreflanglinks of the current page into the response’s head.