简体   繁体   English

TYPO3和RealURL的混合语言网址

[英]Mixed language url's by TYPO3 & RealURL

I have setup RealURL for generating the url's but it is generating mixed language url's after changing the language. 我已经设置了RealURL来生成网址,但是在更改语言后会生成混合语言的网址。 After clearing cache and don't changing language the urls stay in the active language, no problem. 清除缓存并且不更改语言后,URL仍保持活动语言,没问题。 But after changing the language the url's become mixed. 但是更改语言后,URL变得混杂了。 The language preset and page name stay correct but the description is a mix between two languages. 语言预设和页面名称保持正确,但是描述是两种语言的混合。 For example the link urls below are generated on the same page: 例如,以下链接URL在同一页面上生成:

/de/anzeige/kategorie/1/vorrat/all.html (this is correct)
/de/anzeige/categorie/1/voorraad/all.html (mix between german & dutch)

Looks like a cached problem? 看起来像是缓存的问题? I fixed it now by making all combination between the languages in the realurl config file, but this makes the file to complex. 我现在通过在realurl配置文件中进行所有语言之间的组合来修复它,但这会使文件变得复杂。

In the realurl config file I'm using the following code in the beginning to do the languages selection: 在realurl配置文件中,我一开始就使用以下代码进行语言选择:

$lang = substr($_SERVER['REQUEST_URI'], 1, 2);

if($lang=='de') {
    $cat = 'kategorie';
    $alias = 'COALESCE(name_de, name_en, name_nl)';
}
else {
    $cat = 'categorie';
    $alias = 'COALESCE(name_nl, name_en, name_de)';
}

This part is used in the postVarSets to get the category name from the database. 这部分在postVarSets中用于从数据库中获取类别名称。 Could it a problem on how I get the category name from the database? 我如何从数据库中获取类别名称可能会出现问题吗?

$cat => array(
     array (
         'GETvar' => 'extension[catname]',
                    'lookUpTable' => array (
                        'table' => 'database_table',
                        'id_field' => 'uid',
                        'alias_field' => 'uid',
                        'addWhereClause' => ' AND NOT deleted',
                        'useUniqueCache' => '1',
                        'useUniqueCache_conf' => array (
                            'strtolower' => '1',
                            'spaceCharacter' => '-',
                        ),
                    ),
                ),
                array (
                    'GETvar' => 'extension[catname]',
                    'lookUpTable' => array (
                        'table' => 'database_table',
                        'id_field' => 'uid',
                        'alias_field' => $alias,
                        'addWhereClause' => ' AND NOT deleted',
                        'useUniqueCache' => '1',
                        'useUniqueCache_conf' => array (
                            'strtolower' => '1',
                            'spaceCharacter' => '-',
                        ),
                    ),
               ),
         ),
   ),

It looks like you did not create a translation of your actual page in the page tree. 您似乎没有在页面树中创建实际页面的翻译。 The language identifier is still "de" in both of your links. 您的两个链接中的语言标识符仍为“ de”。 So first step is to create a translation. 因此,第一步是创建翻译。

Next step is to make your extension support multiple languages, which will add some language_* fields to your table. 下一步是使您的扩展程序支持多种语言,这将向表中添加一些language_*字段。 If done correctly, you can created translations of your categories without having multiple languages in one database record. 如果操作正确,则可以创建类别的翻译,而在一个数据库记录中无需使用多种语言。 You will end up with having one record per language. 您最终将获得每种语言的一条记录。

Next, you need to add the language config to your realurl config like in the news extension : 接下来,您需要像在新闻扩展中一样,将语言配置添加到您的realurl配置中:

    array(
            'GETvar' => 'tx_news_pi1[news]',
            'lookUpTable' => array(
                'table' => 'tx_news_domain_model_news',
                'id_field' => 'uid',
                'alias_field' => 'title',
                'addWhereClause' => ' AND NOT deleted',
                'useUniqueCache' => 1,
                'useUniqueCache_conf' => array(
                    'strtolower' => 1,
                    'spaceCharacter' => '-',
                ),
                'languageGetVar' => 'L',
                'languageExceptionUids' => '',
                'languageField' => 'sys_language_uid',
                'transOrigPointerField' => 'l10n_parent',
                'autoUpdate' => 1,
                'expireDays' => 180,
            ),
        ),

Then you're done :-) 然后您就完成了:-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM