How to make an alternative site language the default site language?

I have a TYPO3 website where the default language is German. Some time ago, I added an alternative site language, which is English.

Now I need to replace these two languages ​​with a backend:

From:

  • Default: German
  • Alternative: English

To:

  • Default: English
  • Alternative: German

So, in the backend, when I create a new content item, the default language will be English.

+4
source share
4 answers

In the TYPO3s localization concept, the default language is considered the source language and is located in the pages database table. Other languages ​​are translations of the source language and are located in the pages_language_overlay table. Therefore, you cannot simply switch the default value to one of the translated languages.

Changing the default language for new content is not difficult in itself, but you will remain with all existing German content with the inscription "english", so you will need to reassign your content elements with some mySQL misleading. If you don't care about your existing content, just leave it in steps 3 and 4.

Step 1:

Before making changes to your database, be sure to back up the relevant data, at least the tables pages , pages_language_overlay and tt_content

Step 2:

Assuming English is a language with identifier 1 ( sys_language_uid = 1 ):

Create a new language entry for the German language in the backend. If you have not defined any other languages ​​in the past, this will be considered "sys_language_uid = 2"

Step 3:

Change the default language elements to the new German language (in mySQL / phpMyAdmin):

UPDATE tt_content SET sys_language_uid = 2 WHERE sys_language_uid = 0

Step 4:

Change the old English elements to the new default language:

UPDATE tt_content SET sys_language_uid = 0 WHERE sys_language_uid = 1

Step 5:

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

 mod.SHARED { defaultLanguageFlag = gb defaultLanguageLabel = English } 

Step 6:

Do not forget to change all the language parameters for the interface (for example, language menus): config.sys_language_uid = 2 (if it was German before). This can lead to some dead links if this is not done correctly.

Step 7:

Delete alternate entry in English


Output:

Depending on how many other extensions are involved (for example, realURL), this task may not be worth the time you spend on it. I hope that the main developers come up with a simpler solution in the future.

+3
source

You can also switch page names. 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); 
+1
source

I found a good solution here without losing "t3_origuid".

Current setting: Default German, English 1 FIRST: Clear all deletion records:

 delete from tt_content where deleted = 1; 

sys_language_uid changes to German content (0 to 10):

 update tt_content set sys_language_uid=10 where sys_language_uid=0; 

sys_language_uid Englisch changes (1 to 0):

 update tt_content set sys_language_uid=0 where sys_language_uid=1; 

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

 update tt_content set sys_language_uid=1 where sys_language_uid=10; 

Set a 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 posts (> More than the most current content identifier!):

 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 identifier where the Germans are:

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

Change the German uid again

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

Cleaning

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

Transfer specific passed fields:

 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 Pages table, 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

+1
source

Yes, and you need to change all the news in the tx_news plugin

First copy everything to the 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 the contents. The text of the Tacke translation is from "tmp" and is set to the new language of origin.

 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) 

Done. Change the tmp table to the 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` ; 

It's all. thanks

0
source

Source: https://habr.com/ru/post/1386130/


All Articles