nerdess
nerdess

Reputation: 10920

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

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:

To:

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

Upvotes: 4

Views: 4803

Answers (4)

RCOR
RCOR

Reputation: 11

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

Upvotes: 1

Oleg V Karun
Oleg V Karun

Reputation: 736

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

Upvotes: 0

Mark
Mark

Reputation: 11

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);

Upvotes: 1

Mateng
Mateng

Reputation: 3734

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.

Upvotes: 3

Related Questions