abinjohnedamanaabinjohnedamana MemberComments: 42 Received thanks: 11 Member since: February 2019

How to change the default language in shopware6 from backend?

 

 

Answers

  • noahnoah MemberComments: 11 Received thanks: 3 Member since: March 18

    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

  • Moritz NaczenskiMoritz Naczenski AdministratorsComments: 9673 Received thanks: 2921 Member since: September 2013

    The default language is part of the Installation and can't be changed after installation.

  • noahnoah MemberComments: 11 Received thanks: 3 Member since: March 18

    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:

    1. Go to the Table Language in your DB
    2. Copy the id of your Systemlanguage
    3. Make sure to remove the 0x prefix of the ID
    4. Search your Code for the ID you've copied before
    5. You should be able to find the ID in the following Files: common.js, Defaults.php, shopware.js and common.js
    6. I replaced the ID with the one i wanted as default Language in the above Files

    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 

  • jfrankejfranke MemberComments: 8 Received thanks: 0 edited October 7 Member since: July 14

    Changing language for the admin / backend:

    • Go to the admin tab (bottom left corner)
    • Click on "Your profile"
    • On "Profile information" change the language to the desired one
    • Click save & input your admin password

     

    Changing the default language for the storefront:

    • Go to "Sales channel" & select Storefront (or the channel where you want to change the default language)
    • On "General settings" you'll see on the bottom right corner "Default language"
    • Change the language to the desired one 
    • Scroll down to the "Domain" section
    • Edit your current domain
    • Select the desired language & change the "Snippet" section as well to the corresponding language
    • Click on "Edit domain" and save everything
    • Go to your storefront, refresh the page and drink some water Thumb-Up
  • mynotemynote MemberComments: 16 Received thanks: 4 edited November 13 Member since: October 2017

    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.

     

  • paitpait MemberComments: 2 Received thanks: 0 edited November 18 Member since: February 10

    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)

Sign In or Register to comment.