[英]Realurl config combination of domain an get-parameter for language
Hidiho, Hidiho,
i got a TYPO3-Site with many translations for each langauge. 我有一个TYPO3-Site,每个语言都有很多翻译。
The Realurl-config for the translations are working fine, if a have a certain domain. 如果具有特定域,则用于翻译的Realurl-config可以正常工作。 For example domainname.com, domainname.de, domainname.es and so on. 例如domainname.com,domainname.de,domainname.es等。
Now i want to add a new translation (Portuguese), but i don't have a domain for it. 现在我想添加一个新的翻译(葡萄牙语),但是我没有域名。 I want to use the url domainname.com/pt for the new translation. 我想使用url domainname.com/pt进行新翻译。
Does RealUrl supports this different way of use? RealUrl是否支持这种不同的使用方式?
Previews in Backend are not working fine. 后端中的预览无法正常工作。 The langauge-Menu contains an the correct Link, but when opening it, i get the standard-langauge (en). 语言菜单包含正确的链接,但是当打开它时,我得到了标准语言(en)。
In TS: 在TS中:
configname {
baseURL = https://www.domainname.com
sys_language_uid = 0
language = en
locale_all = en_EN
htmlTag_langKey = en
}
[globalVar = GP:L = 0]
configname {
sys_language_uid = 0
language = en
locale_all = en_EN
htmlTag_langKey = en
}
[global]
[globalVar = GP:L = 1]
configname {
sys_language_uid = 1
language = de
locale_all = de_DE
htmlTag_langKey = de
baseURL = https://www.domainname.de
}
[global]
....
#new config for portuguese
[globalVar = GP:L = 3]
configname {
sys_language_uid = 3
language = pt
locale_all = pt_PT
htmlTag_langKey = pt
}
[global]
perhaps i don't know to config realurl_conf.php correctly for this purpose. 也许我不知道为此目的正确配置realurl_conf.php。
Here it comes: 它来了:
$TYPO3_CONF_VARS['EXTCONF']['realurl']['_DEFAULT'] = array(
'preVars' => array(
array(
'GETvar' => 'L',
'valueMap' => array(
'pt' => '3',
),
'valueDefault' => '',
'noMatch' => 'bypass',
),
),
....
);
$TYPO3_CONF_VARS['EXTCONF']['realurl']['_DOMAINS'] = array(
'encode' => array(
array(
'GETvar' => 'L',
'value' => '',
'ifDifferentToCurrent' => true,
'useConfiguration' => '_DEFAULT',
'urlPrepend' => 'https://www.domainname.com',
),
array(
'GETvar' => 'L',
'value' => '0',
'ifDifferentToCurrent' => true,
'useConfiguration' => '_DEFAULT',
'urlPrepend' => 'https://www.domainname.com'
),
array(
'GETvar' => 'L',
'value' => '1',
'ifDifferentToCurrent' => true,
'useConfiguration' => '_DEFAULT',
'urlPrepend' => 'https://www.domainname.de'
),
array(
'GETvar' => 'L',
'value' => '2',
'ifDifferentToCurrent' => true,
'useConfiguration' => '_DEFAULT',
'urlPrepend' => 'https://www.domainname.es'
),
array(
'GETvar' => 'L',
'value' => '4',
'ifDifferentToCurrent' => true,
'useConfiguration' => '_DEFAULT',
'urlPrepend' => 'https://www.domainname.cn'
),
array(
'GETvar' => 'L',
'value' => '6',
'ifDifferentToCurrent' => true,
'useConfiguration' => '_DEFAULT',
'urlPrepend' => 'https://www.domainname.com'
),
),
'decode' => array(
'www.domainname.com' => array(
'GETvars' => array(
'L' => '0',
),
'useConfiguration' => '_DEFAULT',
),
'www.domainname.de' => array(
'GETvars' => array(
'L' => '1',
),
'useConfiguration' => '_DEFAULT'
),
'www.domainname.es' => array(
'GETvars' => array(
'L' => '2',
),
'useConfiguration' => '_DEFAULT'
),
'www.domainname.cn' => array(
'GETvars' => array(
'L' => '4',
),
'useConfiguration' => '_DEFAULT'
),
),
);
Any suggestions how to say realurl that its the langauge 3 it has to use? 有什么建议要说realurl它必须使用它的语言3吗?
Multilanguange/Multidomain config is not trivial to achieve... I never mixed the different modes, though. Multilanguange / Multidomain配置并非易事……尽管我从未混合使用不同的模式。
The biggest problem I see at first glance is that alll your domain config use the same [_default] configuration - I always create dedicated arrays for each domains like this: 乍看之下,最大的问题是您的域配置全部使用相同的[_default]配置-我总是为每个域创建专用的数组,如下所示:
// [_default] stuff
$TYPO3_CONF_VARS['EXTCONF']['realurl']['whatever.de'] = $TYPO3_CONF_VARS['EXTCONF']['realurl']['_DEFAULT'];
$TYPO3_CONF_VARS['EXTCONF']['realurl']['whatever.de']['pagePath']['rootpage_id'] = 1;
$TYPO3_CONF_VARS['EXTCONF']['realurl']['whatever.com'] = $TYPO3_CONF_VARS['EXTCONF']['realurl']['_DEFAULT'];
$TYPO3_CONF_VARS['EXTCONF']['realurl']['whatever.com']['pagePath']['rootpage_id'] = 1;
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['_DOMAINS']['encode'] = array(
array(
'GETvar' => 'L',
'value' => '0',
'useConfiguration' => 'whatever.de',
'urlPrepend' => 'http://whatever.de',
'ifDifferentToCurrent' => true,
),
array(
'GETvar' => 'L',
'value' => '1',
'useConfiguration' => 'whatever.com',
'urlPrepend' => 'http://whatever.com',
'ifDifferentToCurrent' => true,
),
// ...
);
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['_DOMAINS']['decode'] = array(
'whatever.de' => array(
'GETvars' => array(
'L' => '0',
),
'useConfiguration' => 'whatever.de'
),
'whatever.com' => array(
'GETvars' => array(
'L' => '1',
),
'useConfiguration' => 'whatever.com'
),
// ...
);
But the cleanest solution would definitely be to aquire the necessary .pt domain, imho. 但是最干净的解决方案肯定是获取必要的.pt域,恕我直言。
Now i want to add a new translation (Portuguese), but i don't have a domain for it. 现在我想添加一个新的翻译(葡萄牙语),但是我没有域名。 I want to use the url domainname.com/pt for the new translation. 我想使用url domainname.com/pt进行新翻译。
Does RealUrl supports this different way of use? RealUrl是否支持这种不同的使用方式?
No, it does not. 不,不是的。 It either domains, or language segments. 它可以是域,也可以是语言段。
Thank you guys for your answers. 谢谢你们的回答。
I found a solution. 我找到了解决方案。 It's all abput the encode/decode blocks and preVars. 全部都放弃了编码/解码块和preVars。 In Addtion i hooked me into UrlDecoder (function setRequestVariables(){...}) ecspacially for my purpose (dirty fix). 另外,出于我的目的(肮脏的修复),我特别迷上了UrlDecoder(函数setRequestVariables(){...})。 One Configuration is enough to get real_url work for mixing up multi-domain and language-parameters. 一种配置足以使real_url工作来混合多域参数和语言参数。
realurl_conf.php realurl_conf.php
$TYPO3_CONF_VARS['EXTCONF']['realurl']['_DEFAULT'] = array(
'init' => array(
'enableCHashCache' => true,
'appendMissingSlash' => 'ifNotFile',
'enableUrlDecodeCache' => true,
'emptyUrlReturnValue' => '/',
),
'preVars' => array(
array(
'GETvar' => 'L',
'valueMap' => array(
'en' => '0',
'de' => '1',
'es' => '2',
'pt' => '3',
'cn' => '4',
'it' => '5',
'us' => '6',
'fr' => '7',
),
'valueDefault' => 'en',
'noMatch' => 'bypass',
),
),
...
);
Now the Endcode/Decode Block: 现在,结束码/解码块:
$TYPO3_CONF_VARS['EXTCONF']['realurl']['example.org'] = $TYPO3_CONF_VARS['EXTCONF']['realurl']['_DEFAULT'];
$TYPO3_CONF_VARS['EXTCONF']['realurl']['_DOMAINS'] = array(
'encode' => array(
array(
'GETvar' => 'L',
'value' => '0',
'useConfiguration' => 'example.org',
'urlPrepend' => 'https://www.example.org'
),
array(
'GETvar' => 'L',
'value' => '1',
'useConfiguration' => 'example.org',
'urlPrepend' => 'https://www.example.de'
),
array(
'GETvar' => 'L',
'value' => '2',
'useConfiguration' => 'example.org',
'urlPrepend' => 'https://www.example.es'
),
array(
'GETvar' => 'L',
'value' => '3',
'useConfiguration' => 'example.org',
'urlPrepend' => 'https://www.example.org/pt'
),
array(
'GETvar' => 'L',
'value' => '4',
'useConfiguration' => 'example.org',
'urlPrepend' => 'https://www.example.cn'
),
array(
'GETvar' => 'L',
'value' => '6',
'useConfiguration' => 'example.org',
'urlPrepend' => 'https://www.example.org/us'
),
array(
'GETvar' => 'L',
'value' => '7',
'useConfiguration' => 'example.org',
'urlPrepend' => 'https://www.example.org/fr'
)
),
'decode' => array(
'example.com' => array(
'GETvars' => array(
'L' => '0',
),
'useConfiguration' => 'example.org'
),
'example.de' => array(
'GETvars' => array(
'L' => '1',
),
'useConfiguration' => 'example.org'
),
'example.es' => array(
'GETvars' => array(
'L' => '2',
),
'useConfiguration' => 'example.org'
),
'example.pt' => array(
'GETvars' => array(
'L' => '3',
),
'useConfiguration' => 'example.org'
),
'example.cn' => array(
'GETvars' => array(
'L' => '4',
),
'useConfiguration' => 'example.org'
),
'example.us' => array(
'GETvars' => array(
'L' => '6',
),
'useConfiguration' => 'example.org'
),
'example.fr' => array(
'GETvars' => array(
'L' => '7',
),
'useConfiguration' => 'example.org'
)
)
);
RealurlUrlDecoder.php RealurlUrlDecoder.php
use DmitryDulepov\Realurl\Cache\UrlCacheEntry;
class RealurlUrlDecoder extends \DmitryDulepov\Realurl\Decoder\UrlDecoder {
/**
* Sets variables after the decoding.
*
* @param UrlCacheEntry $cacheEntry
*/
public function setRequestVariables(UrlCacheEntry $cacheEntry) {
$languageWithoutDomain = array(
3 => '/pt/',
6 => '/us/',
7 => '/fr/',
);
if (in_array(substr($_SERVER['REQUEST_URI'], 0, 4), $languageWithoutDomain)) {
foreach ($languageWithoutDomain as $key => $value) {
if(substr($_SERVER['REQUEST_URI'], 0, 4) == $value){
$requestVariables = $cacheEntry->getRequestVariables();
if(isset($requestVariables['L'])){
$requestVariables['L'] = $key;
$cacheEntry->setRequestVariables($requestVariables);
}
}
}
}
parent::setRequestVariables($cacheEntry);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.