How to change the default language in shopware6 from backend?
How to change the default language in shopware6 from backend?
I need this solution to!
According to the documentation this should be possible in Settings > Language > Edit Language… but nothing there.
Maybe not in the Community Version
The default language is part of the Installation and can’t be changed after installation.
I actually found a workaround.
Systemlanguage is stored in the code itself not in the catabase.
If you want to change the Systemlanguage do the following:
Be aware that might not be safe to do this option and make a backup before.
For me this Solution worked, i just needed to set all Names of Product and so on in the Default Language
Changing language for the admin / backend:
Changing the default language for the storefront:
Got it working, but there were still some bugs. Finally i found the last changes which need to be done.
Beside of the fact that you need to change some files like:
core\shopware.js
and Defaults.php (change the system language to the proper one).
ENG = 2fbb5fe2e29a4d70aa5854ce7ce3e20b
DE = afbab23128a44b39be16583ef9d386fa
My core\shopware.js lookes like that (Defualt was EN, now its DE):
this.Defaults = {
systemLanguageId: 'afbab23128a44b39be16583ef9d386fa',
defaultLanguageIds: ['afbab23128a44b39be16583ef9d386fa'],
versionId: '0fa91ce3e96a4bc2be4bd9ce752c3425',
storefrontSalesChannelTypeId: '8a243080f92e4c719546314b577cf82b',
productComparisonTypeId: 'ed535e5722134ac1aa6524f73e26881b',
apiSalesChannelTypeId: 'f183ee5650cf4bdb8a774337575067a6'
};
Defaults.php is now
public const LANGUAGE_SYSTEM = 'afbab23128a44b39be16583ef9d386fa';
After that search for your languages in mysql …
SELECT FROM language
Since you cant change the parent_id in phpmyadmin, you need to execute it directly like:
Deleting the parent id for DE so it doesnt inherit from EN.
UPDATE `language` SET parent_id = NULL where id=0xafbab23128a44b39be16583ef9d386fa
After that you need to inherit all other languages from your primary language (DE in my case):
UPDATE `language` SET parent_id =0xafbab23128a44b39be16583ef9d386fa where id=0x2fbb5fe2e29a4d70aa5854ce7ce3e20b
Deleting the cache and it should be working.
Hey guys! I had the same problem and i finally found a solution without touching the code!
The id of the default language is the same since the start of shopware 6 (2fbb5fe2e29a4d70aa5854ce7ce3e20b) and the db contains foreign-key-references with “on update cascade” for every reference on language_id (language-table). I just updated the id of the english language in the language-table to a new random uuid and afterwards updated the id of the german language to 2fbb5fe2e29a4d70aa5854ce7ce3e20b (see code below).
mysql --user={{ sw_db_user }} --password={{ sw_db_user_password }}
{{ sw_database_name }} --host={{ sw_database_host }} --batch --skip-column-names
--execute="
UPDATE language SET id = UNHEX(REPLACE(UUID(), '-','')) WHERE name='English';
UPDATE language SET id = UNHEX('2FBB5FE2E29A4D70AA5854CE7CE3E20B') WHERE name='Deutsch';"
I did this shortly after setting up the db with the command bin/console system:install --create-database --basic-setup and before building the application for the first time. I also did the following the make it working as expected:
changed the default language for the admin-user to german
mysql --user={{ sw_db_user }} --password={{ sw_db_user_password }}
{{ sw_database_name }} --host={{ sw_database_host }} --batch --skip-column-names
–execute="
UPDATE user SET locale_id = (SELECT id FROM locale WHERE code = ‘de-DE’) WHERE username = ‘admin’;"
changed the default language, currency AND snippet-set for all SalesChannel-Domains
mysql --user={{ sw_db_user }} --password={{ sw_db_user_password }}
{{ sw_database_name }} --host={{ sw_database_host }} --batch --skip-column-names
–execute="
UPDATE sales_channel_domain SET language_id = (SELECT id FROM language WHERE name = ‘Deutsch’),
currency_id = (SELECT id FROM currency WHERE iso_code = ‘EUR’),
snippet_set_id = (SELECT id FROM snippet_set WHERE iso = ‘de-DE’);"
changed the default language, currency and country for all SalesChannels
mysql --user={{ sw_db_user }} --password={{ sw_db_user_password }}
{{ sw_database_name }} --host={{ sw_database_host }} --batch --skip-column-names
–execute="
UPDATE sales_channel SET language_id = (SELECT id FROM language WHERE name = ‘Deutsch’),
currency_id = (SELECT id FROM currency WHERE iso_code = ‘EUR’),
country_id = (SELECT id FROM country WHERE iso3 = ‘DEU’);"
Afterwards you only have to give your storefront-channel a new name (german) because the db-setup-process only inserts a translation for english.
The parent_id-field in the language-table is NULL for all entries (german and english)
For those who struggled with the update and had to remove all languages but not the primary… simple database snippet:
# Emanuel's quick shopware 6 database fix to update the language_id based on previous updates
update `cms_slot_translation` set language_id=0x2fbb5fe2e29a4d70aa5854ce7ce3e20b;
update `sales_channel` set language_id=0x2fbb5fe2e29a4d70aa5854ce7ce3e20b;
update `sales_channel_domain` set language_id=0x2fbb5fe2e29a4d70aa5854ce7ce3e20b;
update `customer` set language_id=0x2fbb5fe2e29a4d70aa5854ce7ce3e20b;
update `newsletter_recipient` set language_id=0x2fbb5fe2e29a4d70aa5854ce7ce3e20b;
update `order` set language_id=0x2fbb5fe2e29a4d70aa5854ce7ce3e20b;
# category_translation has some duplicates, deleting first
delete FROM `category_translation` WHERE language_id=0x2fbb5fe2e29a4d70aa5854ce7ce3e20b;
update `category_translation` set language_id=0x2fbb5fe2e29a4d70aa5854ce7ce3e20b;
update `country_state_translation` set language_id=0x2fbb5fe2e29a4d70aa5854ce7ce3e20b;
update `country_translation` set language_id=0x2fbb5fe2e29a4d70aa5854ce7ce3e20b;
update `currency_translation` set language_id=0x2fbb5fe2e29a4d70aa5854ce7ce3e20b;
update `customer_group_translation` set language_id=0x2fbb5fe2e29a4d70aa5854ce7ce3e20b;
update `locale_translation` set language_id=0x2fbb5fe2e29a4d70aa5854ce7ce3e20b;
update `media_translation` set language_id=0x2fbb5fe2e29a4d70aa5854ce7ce3e20b;
update `payment_method_translation` set language_id=0x2fbb5fe2e29a4d70aa5854ce7ce3e20b;
update `product_manufacturer_translation` set language_id=0x2fbb5fe2e29a4d70aa5854ce7ce3e20b;
update `product_translation` set language_id=0x2fbb5fe2e29a4d70aa5854ce7ce3e20b;
update `shipping_method_translation` set language_id=0x2fbb5fe2e29a4d70aa5854ce7ce3e20b;
update `unit_translation` set language_id=0x2fbb5fe2e29a4d70aa5854ce7ce3e20b;
update `property_group_translation` set language_id=0x2fbb5fe2e29a4d70aa5854ce7ce3e20b;
update `property_group_option_translation` set language_id=0x2fbb5fe2e29a4d70aa5854ce7ce3e20b;
update `sales_channel_translation` set language_id=0x2fbb5fe2e29a4d70aa5854ce7ce3e20b;
update `sales_channel_type_translation` set language_id=0x2fbb5fe2e29a4d70aa5854ce7ce3e20b;
update `salutation_translation` set language_id=0x2fbb5fe2e29a4d70aa5854ce7ce3e20b;
# plugin_translation has some duplicates, deleting first
delete FROM `plugin_translation` WHERE language_id=0x2fbb5fe2e29a4d70aa5854ce7ce3e20b;
update `plugin_translation` set language_id=0x2fbb5fe2e29a4d70aa5854ce7ce3e20b;
update `product_stream_translation` set language_id=0x2fbb5fe2e29a4d70aa5854ce7ce3e20b;
update `state_machine_translation` set language_id=0x2fbb5fe2e29a4d70aa5854ce7ce3e20b;
update `state_machine_state_translation` set language_id=0x2fbb5fe2e29a4d70aa5854ce7ce3e20b;
update `cms_page_translation` set language_id=0x2fbb5fe2e29a4d70aa5854ce7ce3e20b;
update `cms_slot_translation` set language_id=0x2fbb5fe2e29a4d70aa5854ce7ce3e20b;
update `mail_header_footer_translation` set language_id=0x2fbb5fe2e29a4d70aa5854ce7ce3e20b;
update `mail_template_translation` set language_id=0x2fbb5fe2e29a4d70aa5854ce7ce3e20b;
update `document_type_translation` set language_id=0x2fbb5fe2e29a4d70aa5854ce7ce3e20b;
update `number_range_type_translation` set language_id=0x2fbb5fe2e29a4d70aa5854ce7ce3e20b;
update `delivery_time_translation` set language_id=0x2fbb5fe2e29a4d70aa5854ce7ce3e20b;
update `promotion_translation` set language_id=0x2fbb5fe2e29a4d70aa5854ce7ce3e20b;
update `product_search_keyword` set language_id=0x2fbb5fe2e29a4d70aa5854ce7ce3e20b;
update `product_keyword_dictionary` set language_id=0x2fbb5fe2e29a4d70aa5854ce7ce3e20b;
update `mail_template_type_translation` set language_id=0x2fbb5fe2e29a4d70aa5854ce7ce3e20b;
update `number_range_translation` set language_id=0x2fbb5fe2e29a4d70aa5854ce7ce3e20b;
update `tax_rule_type_translation` set language_id=0x2fbb5fe2e29a4d70aa5854ce7ce3e20b;
update `product_review` set language_id=0x2fbb5fe2e29a4d70aa5854ce7ce3e20b;
# seo_url has some duplicates, deleting first
delete FROM `seo_url` WHERE language_id=0x2fbb5fe2e29a4d70aa5854ce7ce3e20b;
update `seo_url` set language_id=0x2fbb5fe2e29a4d70aa5854ce7ce3e20b;
update `product_cross_selling_translation` set language_id=0x2fbb5fe2e29a4d70aa5854ce7ce3e20b;
update `product_sorting_translation` set language_id=0x2fbb5fe2e29a4d70aa5854ce7ce3e20b;
update `app_translation` set language_id=0x2fbb5fe2e29a4d70aa5854ce7ce3e20b;
update `app_action_button_translation` set language_id=0x2fbb5fe2e29a4d70aa5854ce7ce3e20b;
What about shopware updates ? I’ve tried your workaround solution (with code changing). It works, but shopware 6 version update erased it.
Updates should not have any effect on this „tweak“ because all migrations which could affect it have already been run. We use this tweak once on each instance we spin up before the first build happens and never had any issues with it afterwards. What this tweak does, it only changes the association between the fixed language-id from the codebase and the language in the db.
Pait, thank you for so fast answer. One more question for you. Is it possible to use this solution after the website was completely builded ? I’ve aready installed it and a lot of content were created, and only afterwards we understood that we need change default language for products
You’re welcome
As far as i remember correctly, we had issues when performing teh tweak after the initial build. What you could do is remove all build-assets (under /public), do the tweak and build everything again. I am not 100% sure this will work, but i quess it is worth a try