Change language code for existing languages

uy flag

My site has two existing languages with several pages of existing content. The language code for both are incorrect. I need to change the language code for English from en-gb to en-ca. Drupal UI doesn't seem to allow that (see below).

Drupal edit language

How can I change the language code for an existing language ?

cn flag
I don't think you can (easily), the language code is the config entity's ID, and will be referenced in a lot of places in the database as the literal string `en-gb`. As well as the ID itself you'll need to find a way to enumerate and update all those references too
leymannx avatar
ne flag
Yeah I think you have to add the new language `en-ca` and then make the content use that language instead.

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.