Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:

If you're trying to add a new custom language in WPML and encounter the error message "Error adding a new language", and your debug log shows a database error related to an unknown 'country' column during an INSERT operation into the `wp_icl_languages` table, this summary is for you.

Solution:

First, ensure that all your plugins are up to date. If the issue persists, follow these steps:
1. Enable the WordPress debug log by setting

define('WP_DEBUG', true);

and

define('WP_DEBUG_LOG', true);

in your wp-config.php file, then reproduce the issue.
2. Check the debug.log file for errors.
3. If you see an error showing that the 'country' column is missing in the `wp_icl_languages` table in your database, run the following SQL query:

ALTER TABLE `wp_icl_languages` ADD COLUMN `country` varchar(10) COLLATE utf8mb4_unicode_520_ci DEFAULT NULL;

4. Attempt to add the new custom language again.

Please ensure you have a full backup of your website before making any changes to the database.
If this solution does not seem relevant to your issue, please open a new support ticket with us.

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 12 replies, has 2 voices.

Last updated by Marsel Nikolli 1 year, 5 months ago.

Assisted by: Marsel Nikolli.

Author Posts
December 18, 2023 at 11:42 am #15083799

stelS

Im trying to add a new custom language (Europe). I have US English, so I'm following this guide https://wpml.org/errata/how-to-add-english-united-states-as-a-custom-language-to-use-as-default-or-translation-language/

When I try to create it, it shows me "Error adding a new language". Here you can see a screenshot of my custom language config before hitting "Save".

Either setting hreflang and regional config to "en" wont work.

Regards

screenshot-www-stg.stelorder.com-2023.12.18-12_39_09.png
December 18, 2023 at 2:53 pm #15085371

Marsel Nikolli

Hi,



Thank you for contacting WPML Support, I will be happy to help you.


1) Could you please tell me what is the code that you are using for the language you want to add, as I am not able to check it properly from the screenshot?

2) Can you please check the following steps:

- Update all plugins (if there is any outdated)
- Deactivate all plugins except WPML and its addons and check for the issue.
- After, activate each plugin one-by-one, while keeping check on the issue after a plugin is activated. This way you'll be able to pinpoint a plugin having a conflict (or problem), if any.
- If the problem persists, please repeat the above steps with a default theme of WordPress

Let me know how it goes,
Marsel

December 18, 2023 at 3:41 pm #15085781

stelS

Hello Marsel

I used "europe" as code. I thought it didn't have to be ISO 639-1 related codes.

I will check part 2 tomorrow.

December 18, 2023 at 3:51 pm #15085851

Marsel Nikolli

Thanks for the update.

Can you please try using: "en-eu" as code instead of "europe" and see if it works?

Take your time about checking part #2.
Let me know once you checked.

Thanks,
Marsel

December 18, 2023 at 5:08 pm #15086479

stelS

Just checked adding en-eu.

en-eu & en_EU & en-eu codes in all three columns related but ain't working. Also trying mapping language and not-mapped but got same result.

December 19, 2023 at 8:24 am #15089483

Marsel Nikolli

Hi,

Please let me know once you had the possibility to check the #2 suggested on https://wpml.org/forums/topic/error-adding-a-new-language-europe-english/#post-15085371

so we can troubleshoot further the issue you are facing.

Looking forward to your reply,
Marsel

December 19, 2023 at 9:19 am #15090021

stelS

Hello Marsel

I've deactivated all plugins in my WordPress (except the main ones). But the issue is still there.

If you want to login in our staging site, I've provided WPML credential in this former ticket:

https://wpml.org/forums/topic/svg-wrong-path-on-translated-pages/

December 19, 2023 at 9:26 am #15090281

stelS

I've created a new backup of my staging site and also reactivated all plugins.

December 19, 2023 at 1:50 pm #15093483

Marsel Nikolli

Hi,

Thank you for the update and for providing the access.

Would it be possible to provide the WordPress debug.log file content, to allow us to see if any PHP errors are being produced. More Info: https://wordpress.org/support/article/debugging-in-wordpress/

To enable debug.log, open your wp-config.php file and look for:

define('WP_DEBUG', false);

And change it to:

define('WP_DEBUG', true);
// Enable Debug logging to the /wp-content/debug.log file
define('WP_DEBUG_LOG', true);
// Disable display of errors and warnings which is recommended on a live site.
define('WP_DEBUG_DISPLAY', false);
@ini_set('display_errors',0);

Then try to reproduce the issue and check if any errors were saved to the debug.log log file inside the “.../wp-content/” directory
If you can paste your debug.log to https://pastebin.com/ and provide me with that link, it would be great!

Thanks,
Marsel

December 19, 2023 at 3:50 pm #15094619

stelS

Here you got:

"[19-Dec-2023 15:41:40 UTC] WordPress database error Unknown column 'country' in 'field list' for query INSERT INTO `wp_icl_languages` (`code`, `english_name`, `default_locale`, `major`, `active`, `encode_url`, `tag`, `country`) VALUES ('en-eu', 'europe', 'en_EU', '0', 1, '0', 'en-eu', NULL) made by include('/plugins/sitepress-multilingual-cms/menu/languages.php'), SitePress_EditLanguages->__construct, SitePress_EditLanguages->update, SitePress_EditLanguages->insert_one, WPML\Element\API\Languages::add, QM_DB->query"

If you want to check it all: https://pastebin.com/Huu3ERey

December 19, 2023 at 4:15 pm #15095025

Marsel Nikolli

Thank you for the update.

Thank you for the updates. Please login to the database using a tool like PHPMyAdmin or Adminer. After that check *country* column exists in *wp_icl_languages* table.

If the *country* column is missing in the *wp_icl_languages* table please run the following query:

ALTER TABLE `wp_icl_languages` 
ADD COLUMN `country` varchar(10) COLLATE utf8mb4_unicode_520_ci DEFAULT NULL;

Then try adding the new custom language and see if the issue persists.

Important: Please make sure you have a full backup of your website (database & files) before you make any change.

Let me know how it goes,
Marsel

December 19, 2023 at 5:58 pm #15095737

stelS

Thank you very much Marsel! It is working!

Is there any other option we have to consider before closing this thread? Why did it failed?

Kind regards!

December 20, 2023 at 7:58 am #15098499

Marsel Nikolli

Hi,

Glad to hear that it's resolved now.
- That would be the solution for this issue, as the *country* column was missing on the database.

- This kind of issues happens sometimes during the plugin updates, depending on the database setup/server environment.

Let me know if you have any more questions or you need more help.

Kind regards,
Marsel

December 20, 2023 at 8:14 am #15098535

stelS

Ok, that's all.

Thanks you Marsel!