如何将替代网站语言设置为默认网站语言?

发布于 2024-12-20 22:00:55 字数 223 浏览 4 评论 0原文

我有一个 TYPO3 网站,默认网站语言是德语。不久前,我添加了一种替代网站语言,即英语。

我现在需要做的是在后端交换这两种语言:

从:

  • 默认:德语
  • 替代:英语

到:

  • 默认:英语
  • 替代:德语

因此,在后端,当我创建新的内容元素时,默认语言将是英语。

I've got a TYPO3 website where the default site language is German. A while ago I added an alternative site language which is English.

What I need to do now is to swap those two languages in the backend:

From:

  • Default: German
  • Alternative: English

To:

  • Default: English
  • Alternative: German

So in the backend when I create a new content element the default language would be English.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

ゞ记忆︶ㄣ 2024-12-27 22:00:55

在 TYPO3 的本地化概念中,默认语言被视为原始语言,并驻留在数据库表pages中。其他语言是原始语言的翻译,并驻留在表pages_language_overlay中。因此,您不能简单地将默认设置切换为其中一种翻译语言。

更改新内容的默认语言本身并不困难,但您将留下所有标记为“英语”的现有德语内容,因此您需要使用一些 mySQL 技巧重新分配内容元素。如果您不关心现有内容,只需省略第 3 步和第 3 步即可。 4.

第 1 步:

在对数据库进行更改之前,请确保备份相关数据,至少备份表 pagespages_language_overlaytt_content

第 2 步:

假设 id 为 english 的语言为 1 (sys_language_uid = 1):

在后端为德语创建一个新的语言条目。如果您过去没有定义任何其他语言,它将被视为“sys_language_uid = 2”

第 3 步:

将默认语言元素更改为新语言“德语”(在 mySQL / phpMyAdmin 中):

UPDATE tt_content SET sys_language_uid = 2 WHERE sys_language_uid = 0

第 4 步:

将以前的英语语言元素更改为新的默认语言:

UPDATE tt_content SET sys_language_uid = 0 WHERE sys_language_uid = 1

第 5 步:

然后,如果您愿意,可以通过输入以下内容来更改后端的语言标签:根页面的页面属性:

mod.SHARED {
        defaultLanguageFlag = gb
        defaultLanguageLabel = English
}

第 6 步:

请记住还要更改前端的所有 language_uid(例如语言菜单):
config.sys_language_uid = 2(如果之前是德语)。如果处理不当,可能会导致一些死链接。

步骤 7:

删除英语的替代语言记录


结论:

根据涉及的其他扩展名数量(例如 realURL),此任务可能不值得您花费时间。 。我希望核心开发人员将来能够提出更简单的解决方案。

In TYPO3s localisation concept the default language is considered to be the original language and resides in the database table pages. Other languages are translations of the original language and reside in the table pages_language_overlay. Hence you can't simply toggle the default to one of the translated languages.

Changing the default language for new content is not difficult per se, but you will be left with all the existing german content labelled "english", therefore you will need reassign your content elements with some mySQL trickery. If you don't care about your existing content, just leave out step 3 & 4.

Step 1:

Before making changes to your database make sure you backup relevant data, at least the tables pages, pages_language_overlay and tt_content

Step 2:

Assuming english is the language with id 1 (sys_language_uid = 1):

Create a new language entry for german in the backend. If you didn't define any other languages in the past it will be considered 'sys_language_uid = 2'

Step 3:

Change default language elements to new language "german" (in mySQL / phpMyAdmin):

UPDATE tt_content SET sys_language_uid = 2 WHERE sys_language_uid = 0

Step 4:

Change former english language elements to new default language:

UPDATE tt_content SET sys_language_uid = 0 WHERE sys_language_uid = 1

Step 5:

Then, if you want so, change the language label in the backend by entering the following to the page properties of your root page:

mod.SHARED {
        defaultLanguageFlag = gb
        defaultLanguageLabel = English
}

Step 6:

Remember to also change all language_uids for the frontend (e.g. language menus):
config.sys_language_uid = 2 (if it was german before). This might result in some dead links if not done right.

Step 7:

Delete the alternative language record for english


Conclusion:

Depending on how many other extensions are involved (e.g. realURL) this task might not be worth the time you spend on it. I hope core developers come up with a simpler solution in the future.

财迷小姐 2024-12-27 22:00:55

人们可能还想切换页面标题。做类似的事情:

UPDATE pages, pages_language_overlay 
SET pages.title = pages_language_overlay.title, 
       pages.subtitle = pages_language_overlay.subtitle, 
       pages.nav_title = pages_language_overlay.nav_title, 
       pages.tx_realurl_pathsegment = pages_language_overlay.tx_realurl_pathsegment 
WHERE (pages.uid = pages_language_overlay.pid) 
AND (pages_language_overlay.sys_language_uid = 1);

One may also want to switch the page titles. Do something like:

UPDATE pages, pages_language_overlay 
SET pages.title = pages_language_overlay.title, 
       pages.subtitle = pages_language_overlay.subtitle, 
       pages.nav_title = pages_language_overlay.nav_title, 
       pages.tx_realurl_pathsegment = pages_language_overlay.tx_realurl_pathsegment 
WHERE (pages.uid = pages_language_overlay.pid) 
AND (pages_language_overlay.sys_language_uid = 1);
累赘 2024-12-27 22:00:55

我在这里找到了一个很好的解决方案,不会丢失任何“t3_origuid”。

当前设置:默认语言为德语,英语为1
第一:清理所有删除条目:

delete from tt_content where deleted = 1;

德语内容的 sys_language_uid 更改(从 0 到 10):

update tt_content set sys_language_uid=10 where sys_language_uid=0;

英语的 sys_language_uid 更改(从 1 到 0):

update tt_content set sys_language_uid=0 where sys_language_uid=1;

德语的 sys_language_uid 更改回 1(从 10 到 1):

update tt_content set sys_language_uid=1 where sys_language_uid=10;

为德语设置新的 l18n_parent条目:

UPDATE tt_content as c1
RIGHT JOIN tt_content as c2 on c2.l18n_parent=c1.uid
SET c1.l18n_parent=c1.uid,c1.t3_origuid=c1.uid
WHERE c1.sys_language_uid=1
    AND c2.sys_language_uid=0;

更改德国条目的 uid(> 超过最新内容 ID!):

UPDATE tt_content as c1
RIGHT JOIN tt_content as c2 on c2.l18n_parent=c1.uid
SET c1.uid=c2.uid+10000
WHERE c1.sys_language_uid=1
    AND c2.sys_language_uid=0;

设置 uid英语的 ID 为德语所在的 ID:

UPDATE tt_content
SET uid=l18n_parent where sys_language_uid=0 and l18n_parent>0;

再次更改德语 uid

UPDATE tt_content
SET uid=uid-10000 where sys_language_uid=1 and uid>10000;

清理

UPDATE tt_content 
SET l18n_parent=0,t3_origuid=0,l18n_diffsource=''
where sys_language_uid=0 and l18n_parent>0;

传输某些已传输的字段:

UPDATE  tt_content as c1
RIGHT JOIN tt_content as c2 on c2.l18n_parent=c1.uid
SET c1.hidden=c2.hidden,
    c1.starttime=c2.starttime,
    c1.endtime=c2.endtime
WHERE c1.sys_language_uid=0
    AND c2.sys_language_uid=1;

页数:
从表格页面复制一份,例如pages_new:

然后第1步:

update pages left join pages_language_overlay on pages.uid=pages_language_overlay.pid set pages.title=pages_language_overlay.title,        pages.subtitle=pages_language_overlay.subtitle,     pages.description=pages_language_overlay.description,        pages.keywords=pages_language_overlay.keywords,        pages.abstract=pages_language_overlay.abstract,        pages.nav_title=pages_language_overlay.nav_title    where pages_language_overlay.sys_language_uid=1;

第2步:

update pages_language_overlay right join pages_new on pages_language_overlay.pid=pages_new.uid set pages_language_overlay.title=pages_new.title,        pages_language_overlay.subtitle=pages_new.subtitle,     pages_language_overlay.description=pages_new.description,        pages_language_overlay.keywords=pages_new.keywords,        pages_language_overlay.abstract=pages_new.abstract,        pages_language_overlay.nav_title=pages_new.nav_title    where pages_language_overlay.sys_language_uid=1;

在此处找到在此处输入链接描述

I found a good solution here without losing any 't3_origuid'.

Current setup: German is the default language, English language 1
FIRST: Clean up all deletet Entries:

delete from tt_content where deleted = 1;

sys_language_uid of German content change (from 0 to 10):

update tt_content set sys_language_uid=10 where sys_language_uid=0;

sys_language_uid of Englisch change (from 1 to 0):

update tt_content set sys_language_uid=0 where sys_language_uid=1;

sys_language_uid of German change back to 1 (from 10 to 1):

update tt_content set sys_language_uid=1 where sys_language_uid=10;

Set new l18n_parent for German Entries:

UPDATE tt_content as c1
RIGHT JOIN tt_content as c2 on c2.l18n_parent=c1.uid
SET c1.l18n_parent=c1.uid,c1.t3_origuid=c1.uid
WHERE c1.sys_language_uid=1
    AND c2.sys_language_uid=0;

Change uid for German Entries (> More Than most current Content ID!):

UPDATE tt_content as c1
RIGHT JOIN tt_content as c2 on c2.l18n_parent=c1.uid
SET c1.uid=c2.uid+10000
WHERE c1.sys_language_uid=1
    AND c2.sys_language_uid=0;

Set uid of englisch to the ID where German are :

UPDATE tt_content
SET uid=l18n_parent where sys_language_uid=0 and l18n_parent>0;

Change again the German uid

UPDATE tt_content
SET uid=uid-10000 where sys_language_uid=1 and uid>10000;

Clean up

UPDATE tt_content 
SET l18n_parent=0,t3_origuid=0,l18n_diffsource=''
where sys_language_uid=0 and l18n_parent>0;

Transfer certain fields transferred:

UPDATE  tt_content as c1
RIGHT JOIN tt_content as c2 on c2.l18n_parent=c1.uid
SET c1.hidden=c2.hidden,
    c1.starttime=c2.starttime,
    c1.endtime=c2.endtime
WHERE c1.sys_language_uid=0
    AND c2.sys_language_uid=1;

PAGES:
Make a Copy from the table Pages for example pages_new:

Then step 1:

update pages left join pages_language_overlay on pages.uid=pages_language_overlay.pid set pages.title=pages_language_overlay.title,        pages.subtitle=pages_language_overlay.subtitle,     pages.description=pages_language_overlay.description,        pages.keywords=pages_language_overlay.keywords,        pages.abstract=pages_language_overlay.abstract,        pages.nav_title=pages_language_overlay.nav_title    where pages_language_overlay.sys_language_uid=1;

Step 2:

update pages_language_overlay right join pages_new on pages_language_overlay.pid=pages_new.uid set pages_language_overlay.title=pages_new.title,        pages_language_overlay.subtitle=pages_new.subtitle,     pages_language_overlay.description=pages_new.description,        pages_language_overlay.keywords=pages_new.keywords,        pages_language_overlay.abstract=pages_new.abstract,        pages_language_overlay.nav_title=pages_new.nav_title    where pages_language_overlay.sys_language_uid=1;

Found here enter link description here

城歌 2024-12-27 22:00:55

是的,您还需要更改 tx_news 插件中的所有新闻,

首先将所有新闻复制到 tmp 表

CREATE  TABLE  `news_tmp` (  `uid` int( 11  )  NOT  NULL  AUTO_INCREMENT ,
 `pid` int( 11  )  NOT  NULL DEFAULT  '0',
 `tstamp` int( 11  )  NOT  NULL DEFAULT  '0',
 `crdate` int( 11  )  NOT  NULL DEFAULT  '0',
 `cruser_id` int( 11  )  NOT  NULL DEFAULT  '0',
 `t3ver_oid` int( 11  )  NOT  NULL DEFAULT  '0',
 `t3ver_id` int( 11  )  NOT  NULL DEFAULT  '0',
 `t3ver_wsid` int( 11  )  NOT  NULL DEFAULT  '0',
 `t3ver_label` varchar( 30  )  NOT  NULL DEFAULT  '',
 `t3ver_state` tinyint( 4  )  NOT  NULL DEFAULT  '0',
 `t3ver_stage` tinyint( 4  )  NOT  NULL DEFAULT  '0',
 `t3ver_count` int( 11  )  NOT  NULL DEFAULT  '0',
 `t3ver_tstamp` int( 11  )  NOT  NULL DEFAULT  '0',
 `t3ver_move_id` int( 11  )  NOT  NULL DEFAULT  '0',
 `t3_origuid` int( 11  )  NOT  NULL DEFAULT  '0',
 `editlock` tinyint( 4  )  NOT  NULL DEFAULT  '0',
 `sys_language_uid` int( 11  )  NOT  NULL DEFAULT  '0',
 `l10n_parent` int( 11  )  NOT  NULL DEFAULT  '0',
 `l10n_diffsource` mediumtext,
 `deleted` tinyint( 4  )  NOT  NULL DEFAULT  '0',
 `hidden` tinyint( 4  )  NOT  NULL DEFAULT  '0',
 `starttime` int( 11  )  NOT  NULL DEFAULT  '0',
 `endtime` int( 11  )  NOT  NULL DEFAULT  '0',
 `sorting` int( 11  )  NOT  NULL DEFAULT  '0',
 `fe_group` varchar( 100  )  NOT  NULL DEFAULT  '0',
 `title` tinytext,
 `teaser` text,
 `bodytext` mediumtext,
 `datetime` int( 11  )  NOT  NULL DEFAULT  '0',
 `archive` int( 11  )  NOT  NULL DEFAULT  '0',
 `author` tinytext,
 `author_email` tinytext,
 `categories` int( 11  )  NOT  NULL DEFAULT  '0',
 `related` int( 11  )  NOT  NULL DEFAULT  '0',
 `related_from` int( 11  )  NOT  NULL DEFAULT  '0',
 `related_files` tinytext,
 `fal_related_files` int( 11  ) unsigned DEFAULT  '0',
 `related_links` tinytext,
 `type` varchar( 100  )  NOT  NULL DEFAULT  '0',
 `keywords` text,
 `description` text,
 `tags` int( 11  )  NOT  NULL DEFAULT  '0',
 `media` text,
 `fal_media` int( 11  ) unsigned DEFAULT  '0',
 `internalurl` text,
 `externalurl` text,
 `istopnews` int( 11  )  NOT  NULL DEFAULT  '0',
 `content_elements` text,
 `path_segment` tinytext,
 `alternative_title` tinytext,
 `rte_disabled` tinyint( 4  )  NOT  NULL DEFAULT  '0',
 `import_id` varchar( 100  )  NOT  NULL DEFAULT  '',
 `import_source` varchar( 100  )  NOT  NULL DEFAULT  '',
 PRIMARY  KEY (  `uid`  ) ,
 KEY  `parent` (  `pid`  ) ,
 KEY  `sys_language_uid_l10n_parent` (  `sys_language_uid` ,  `l10n_parent`  ) ,
 KEY  `import` (  `import_id` ,  `import_source`  )  ) ENGINE  =  MyISAM  DEFAULT CHARSET  = utf8

INSERT INTO `news_tmp` SELECT * FROM `tx_news_domain_model_news`

,然后更改内容。固定“tmp”中的翻译文本并设置为新的原始语言。

UPDATE news_tmp news, tx_news_domain_model_news tmp 
SET news.title = tmp.title, 
       news.teaser = tmp.teaser,
       news.bodytext = tmp.bodytext 
WHERE (news.uid = tmp.t3_origuid) 
AND (news.sys_language_uid = 0)
AND (tmp.sys_language_uid = 2);

UPDATE news_tmp news, tx_news_domain_model_news tmp 
SET news.title = tmp.title, 
       news.teaser = tmp.teaser,
       news.bodytext = tmp.bodytext 
WHERE (news.t3_origuid = tmp.uid) 
AND (news.sys_language_uid = 2)
AND (tmp.sys_language_uid = 0)

准备

UPDATE news_tmp news, tx_news_domain_model_news tmp 
SET news.title = tmp.title, 
       news.teaser = tmp.teaser,
       news.bodytext = tmp.bodytext 
WHERE (news.t3_origuid = tmp.uid) 
AND (news.sys_language_uid = 2)
AND (tmp.sys_language_uid = 0)

好-出发。将 tmp 表更改为原点:

RENAME TABLE  `db`.`tx_news_domain_model_news` TO `db`.`tx_news_domain_model_news_old` ;
RENAME TABLE  `db`.`news_tmp` TO  `db`.`tx_news_domain_model_news` ;

这就是全部。谢谢

Yep and also you need change all news in tx_news plugin

First coppy all to tmp table

CREATE  TABLE  `news_tmp` (  `uid` int( 11  )  NOT  NULL  AUTO_INCREMENT ,
 `pid` int( 11  )  NOT  NULL DEFAULT  '0',
 `tstamp` int( 11  )  NOT  NULL DEFAULT  '0',
 `crdate` int( 11  )  NOT  NULL DEFAULT  '0',
 `cruser_id` int( 11  )  NOT  NULL DEFAULT  '0',
 `t3ver_oid` int( 11  )  NOT  NULL DEFAULT  '0',
 `t3ver_id` int( 11  )  NOT  NULL DEFAULT  '0',
 `t3ver_wsid` int( 11  )  NOT  NULL DEFAULT  '0',
 `t3ver_label` varchar( 30  )  NOT  NULL DEFAULT  '',
 `t3ver_state` tinyint( 4  )  NOT  NULL DEFAULT  '0',
 `t3ver_stage` tinyint( 4  )  NOT  NULL DEFAULT  '0',
 `t3ver_count` int( 11  )  NOT  NULL DEFAULT  '0',
 `t3ver_tstamp` int( 11  )  NOT  NULL DEFAULT  '0',
 `t3ver_move_id` int( 11  )  NOT  NULL DEFAULT  '0',
 `t3_origuid` int( 11  )  NOT  NULL DEFAULT  '0',
 `editlock` tinyint( 4  )  NOT  NULL DEFAULT  '0',
 `sys_language_uid` int( 11  )  NOT  NULL DEFAULT  '0',
 `l10n_parent` int( 11  )  NOT  NULL DEFAULT  '0',
 `l10n_diffsource` mediumtext,
 `deleted` tinyint( 4  )  NOT  NULL DEFAULT  '0',
 `hidden` tinyint( 4  )  NOT  NULL DEFAULT  '0',
 `starttime` int( 11  )  NOT  NULL DEFAULT  '0',
 `endtime` int( 11  )  NOT  NULL DEFAULT  '0',
 `sorting` int( 11  )  NOT  NULL DEFAULT  '0',
 `fe_group` varchar( 100  )  NOT  NULL DEFAULT  '0',
 `title` tinytext,
 `teaser` text,
 `bodytext` mediumtext,
 `datetime` int( 11  )  NOT  NULL DEFAULT  '0',
 `archive` int( 11  )  NOT  NULL DEFAULT  '0',
 `author` tinytext,
 `author_email` tinytext,
 `categories` int( 11  )  NOT  NULL DEFAULT  '0',
 `related` int( 11  )  NOT  NULL DEFAULT  '0',
 `related_from` int( 11  )  NOT  NULL DEFAULT  '0',
 `related_files` tinytext,
 `fal_related_files` int( 11  ) unsigned DEFAULT  '0',
 `related_links` tinytext,
 `type` varchar( 100  )  NOT  NULL DEFAULT  '0',
 `keywords` text,
 `description` text,
 `tags` int( 11  )  NOT  NULL DEFAULT  '0',
 `media` text,
 `fal_media` int( 11  ) unsigned DEFAULT  '0',
 `internalurl` text,
 `externalurl` text,
 `istopnews` int( 11  )  NOT  NULL DEFAULT  '0',
 `content_elements` text,
 `path_segment` tinytext,
 `alternative_title` tinytext,
 `rte_disabled` tinyint( 4  )  NOT  NULL DEFAULT  '0',
 `import_id` varchar( 100  )  NOT  NULL DEFAULT  '',
 `import_source` varchar( 100  )  NOT  NULL DEFAULT  '',
 PRIMARY  KEY (  `uid`  ) ,
 KEY  `parent` (  `pid`  ) ,
 KEY  `sys_language_uid_l10n_parent` (  `sys_language_uid` ,  `l10n_parent`  ) ,
 KEY  `import` (  `import_id` ,  `import_source`  )  ) ENGINE  =  MyISAM  DEFAULT CHARSET  = utf8

INSERT INTO `news_tmp` SELECT * FROM `tx_news_domain_model_news`

Then change content. Tacke translation text from "tmp" and set into new origin language.

UPDATE news_tmp news, tx_news_domain_model_news tmp 
SET news.title = tmp.title, 
       news.teaser = tmp.teaser,
       news.bodytext = tmp.bodytext 
WHERE (news.uid = tmp.t3_origuid) 
AND (news.sys_language_uid = 0)
AND (tmp.sys_language_uid = 2);

UPDATE news_tmp news, tx_news_domain_model_news tmp 
SET news.title = tmp.title, 
       news.teaser = tmp.teaser,
       news.bodytext = tmp.bodytext 
WHERE (news.t3_origuid = tmp.uid) 
AND (news.sys_language_uid = 2)
AND (tmp.sys_language_uid = 0)

and back

UPDATE news_tmp news, tx_news_domain_model_news tmp 
SET news.title = tmp.title, 
       news.teaser = tmp.teaser,
       news.bodytext = tmp.bodytext 
WHERE (news.t3_origuid = tmp.uid) 
AND (news.sys_language_uid = 2)
AND (tmp.sys_language_uid = 0)

Ready - go. Change tmp table to origin:

RENAME TABLE  `db`.`tx_news_domain_model_news` TO `db`.`tx_news_domain_model_news_old` ;
RENAME TABLE  `db`.`news_tmp` TO  `db`.`tx_news_domain_model_news` ;

This all. Thx

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文