Refactor language URL routing to use explicit @lang special route tokens instead of positional segment detection
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 45/100
Línea de trabajo
Empieza leyendo src/Router/PatternCompiler.php, src/Router/MatchedRoute.php, src/Http/Traits/Request/Route.php y src/Lang/Factories/LangFactory.php; después, inspecciona las pruebas de routing existentes. Traza cómo funcionan actualmente los tokens de ruta y la resolución de idioma. Se considera terminado cuando las rutas @lang coincidan con los idiomas compatibles, conserven el idioma como contexto de ruta en lugar de como un parámetro ordinario y cuenten con pruebas correspondientes, además de plantillas o ejemplos actualizados cuando sea necesario.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Summary
Refactor Quantum language URL routing so routes can explicitly declare language segments using the special route token:
@lang
instead of relying on positional URL segment detection through config such as lang.url_segment.
Why
Current language URL handling is implicit and positional.
Today, language detection relies on config-driven segment index logic, for example:
lang.url_segment
and the framework then tries to detect the language by reading a configured request segment position, with additional prefix-aware adjustment logic.
That works, but it has several weaknesses:
- route structure does not explicitly show where language lives
- language handling depends on URL segment position math
- routes are harder to reason about when combined with prefixes or other special segments
- the model does not align with the new special route token direction
With special route token support in place, language routing should become explicit in the route pattern itself.
Goal
Allow routes to explicitly declare the language segment using:
@lang
so the router can treat language as a framework-owned route context rather than a positional URL convention.
Proposed Direction
Routes that are language-aware should explicitly include:
@lang
Examples:
$route->get('@lang/posts', 'PostController', 'posts');
$route->get('@lang/post/[uuid=:any]', 'PostController', 'post');
This should allow URLs such as:
/en/posts/es/posts
or, when module prefix is present:
/web/en/posts/api/en/posts
depending on module prefix configuration.
Config Direction
Language config should continue to define language behavior such as:
- whether language is enabled
- supported languages
- default language
But routed language placement should no longer depend on positional config like:
lang.url_segment
The route itself should explicitly declare where language lives.
Important behavior
The resolved language should be:
- matched through the
@langtoken - validated against configured supported languages
- made available to framework internals as language route context
- kept distinct from ordinary controller action parameters by default
Migration Direction
This feature should replace routed language URL detection based on positional segment config for routes that adopt @lang.
Backward compatibility strategy can be decided during implementation, but the intended direction is for explicit routed language segments to become the preferred and cleaner model.
Acceptance Criteria
- routes can explicitly declare language position using
@lang - matched
@langvalues are validated against configured supported languages - language route context is resolved through
@langrather than positional URL segment detection for token-based routes - routed language values do not become ordinary positional controller action parameters by default
- tests cover
@langroute matching and language resolution behavior - templates and examples can be updated to use
@langwhere appropriate
Notes
Relevant code:
src/Lang/Factories/LangFactory.phpsrc/Router/PatternCompiler.phpsrc/Router/MatchedRoute.phpsrc/Http/Traits/Request/Route.php- module route templates currently using language-prefixed route patterns
This ticket depends on:
- Lenguaje dominante
- PHP
- Estrellas
- 36
- Forks
- 22
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de quantum-php/framework
-
routing testing
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
quantum-php/framework#547 ·
-
view
Dificultad 1/5 Menos de una hora Aptitud para principiantes 75/100
quantum-php/framework#542 ·
-
enhancement http
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
quantum-php/framework#565 · 1 comentario ·
-
components view
Dificultad 5/5 Más de una semana Aptitud para principiantes 42/100
quantum-php/framework#551 ·
-
Add explicit @version special route token support for API major versioning within a single moduleAbiertorouting
Dificultad 5/5 Más de una semana Aptitud para principiantes 45/100
quantum-php/framework#550 ·
Todos los issues de quantum-php/framework
Issues similares
-
sync-en
Dificultad 1/5 1-3 horas Aptitud para principiantes 88/100
Los mantenedores suelen responder en 2 días
-
P2 testing
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
Los mantenedores suelen responder en 1 día
-
1.severity: security
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Automattic/static-site-importer#1879 ·
Los mantenedores suelen responder en 1 día
-
bug Installation / Upgrade
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
Los mantenedores suelen responder en 1 día