review: consistent naming and methodology
This commit is contained in:
parent
ad9c9fd678
commit
ef297fa8e1
5 changed files with 22 additions and 19 deletions
|
@ -9,7 +9,7 @@ use Psr\Http\Message\ServerRequestInterface;
|
|||
use Psr\Http\Server\MiddlewareInterface;
|
||||
use Psr\Http\Server\RequestHandlerInterface;
|
||||
|
||||
class ReplaceGetTranslationRequest implements MiddlewareInterface
|
||||
class TransformTranslationRequestMiddleware implements MiddlewareInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
|
@ -26,11 +26,6 @@ class ReplaceGetTranslationRequest implements MiddlewareInterface
|
|||
*/
|
||||
protected string $translateGetParam;
|
||||
|
||||
/**
|
||||
* @param string $headerName
|
||||
* @param string|null $reactOnPath
|
||||
* @param string $translateGetParam
|
||||
*/
|
||||
public function __construct(string $headerName, ?string $reactOnPath, string $translateGetParam)
|
||||
{
|
||||
$this->headerName = $headerName;
|
|
@ -17,7 +17,7 @@ use Psr\Http\Message\ServerRequestInterface;
|
|||
use Psr\Http\Server\MiddlewareInterface;
|
||||
use Psr\Http\Server\RequestHandlerInterface;
|
||||
|
||||
class TranslationMiddleware implements MiddlewareInterface
|
||||
class TranslationRequestMiddleware implements MiddlewareInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
|
@ -1,5 +1,5 @@
|
|||
DigiComp:TransformTranslationRequest:
|
||||
className: "DigiComp\\FlowTranslationEndpoint\\Http\\ReplaceGetTranslationRequest"
|
||||
DigiComp.FlowTranslationEndpoint:TransformTranslationRequestMiddleware:
|
||||
className: "DigiComp\\FlowTranslationEndpoint\\Http\\TransformTranslationRequestMiddleware"
|
||||
arguments:
|
||||
1:
|
||||
setting: "DigiComp.FlowTranslationEndpoint.headerName"
|
||||
|
@ -8,17 +8,25 @@ DigiComp:TransformTranslationRequest:
|
|||
3:
|
||||
setting: "DigiComp.FlowTranslationEndpoint.replaceRoutedEndpoint.translateGetParam"
|
||||
|
||||
DigiComp:TranslationResponseCache:
|
||||
DigiComp.FlowTranslationEndpoint:TranslationResponseCache:
|
||||
className: "Neos\\Cache\\Frontend\\StringFrontend"
|
||||
factoryObjectName: Neos\Flow\Cache\CacheManager
|
||||
factoryMethodName: getCache
|
||||
factoryObjectName: "Neos\\Flow\\Cache\\CacheManager"
|
||||
factoryMethodName: "getCache"
|
||||
arguments:
|
||||
1:
|
||||
value: DigiComp_FlowTranslationEndpoint_Responses
|
||||
value: "DigiComp_FlowTranslationEndpoint_Responses"
|
||||
|
||||
DigiComp\FlowTranslationEndpoint\Http\TranslationMiddleware:
|
||||
DigiComp.FlowTranslationEndpoint:TranslationRequestMiddleware:
|
||||
className: "DigiComp\\FlowTranslationEndpoint\\Http\\TranslationRequestMiddleware"
|
||||
autowiring: true
|
||||
arguments:
|
||||
1:
|
||||
setting: "DigiComp.FlowTranslationEndpoint.headerName"
|
||||
2:
|
||||
object: "Neos\\Flow\\I18n\\Service"
|
||||
3:
|
||||
object: "Neos\\Flow\\I18n\\Xliff\\Service\\XliffFileProvider"
|
||||
4:
|
||||
object: "Neos\\Flow\\I18n\\Detector"
|
||||
5:
|
||||
object: "DigiComp:TranslationResponseCache"
|
||||
object: "DigiComp.FlowTranslationEndpoint:TranslationResponseCache"
|
||||
|
|
|
@ -4,10 +4,10 @@ Neos:
|
|||
middlewares:
|
||||
translationReplace:
|
||||
position: "before translation"
|
||||
middleware: "DigiComp:TransformTranslationRequest"
|
||||
middleware: "DigiComp.FlowTranslationEndpoint:TransformTranslationRequestMiddleware"
|
||||
translation:
|
||||
position: "start 100"
|
||||
middleware: "DigiComp\\FlowTranslationEndpoint\\Http\\TranslationMiddleware"
|
||||
middleware: "DigiComp.FlowTranslationEndpoint:TranslationRequestMiddleware"
|
||||
|
||||
DigiComp:
|
||||
FlowTranslationEndpoint:
|
||||
|
|
|
@ -6,7 +6,7 @@ This package is designed to help bringing needed translations to javascript comp
|
|||
|
||||
Other solutions, which would generate files available for usage in client scope, have the disadvantage that one would have to repeat the relativ complex overriding and merging logic of Flow. With this endpoint you can get the same content, as you would get, if you call the translation service with your translation id.
|
||||
|
||||
The main components are a `CurrentHtmlLangViewHelper`, which is intended to be used to fill the `lang` attribute of the `html` tag, so the frontend knows, which language is currently active (and is good practice anyway) and a `TranslationMiddleware`, which will respond to any request, which have a `X-Translation-Request` header, carrying a pattern of translation ids which should be returned.
|
||||
The main components are a `CurrentHtmlLangViewHelper`, which is intended to be used to fill the `lang` attribute of the `html` tag, so the frontend knows, which language is currently active (and is good practice anyway) and a `TranslationRequestMiddleware`, which will respond to any request, which have a `X-Translation-Request` header, carrying a pattern of translation ids which should be returned.
|
||||
|
||||
For example:
|
||||
````
|
||||
|
@ -45,4 +45,4 @@ async function translate(idPatterns) {
|
|||
}
|
||||
```
|
||||
|
||||
If, for whatever reason, you prefer to have a "traditional" single endpoint, which works without a custom header, you can set `DigiComp.FlowTranslationEndpoint.replaceRoutedEndpoint.reactOnPath`. At this point a middleware translates all incoming requests and the GET parameter `idPatterns` (you can change the name in Settings.yaml).
|
||||
If, for whatever reason, you prefer to have a "traditional" single endpoint, which works without a custom header, you can set `DigiComp.FlowTranslationEndpoint.replaceRoutedEndpoint.reactOnPath`. At this point a second middleware (`TransformGetTranslationRequestMiddleware`) transforms all incoming requests and the GET parameter `idPatterns` (you can change names in Settings.yaml).
|
||||
|
|
Loading…
Reference in a new issue