Skip to content

Default language is overwriten by browser language settings #7528

Closed

Description

@NightSkySK

Please verify that this bug has NOT been raised before.

  • I checked and didn't find a similar issue

Describe the bug*

in Inventree config file /etc/inventree/config.yaml I've applied language setting:

# Select default system language (default is 'en-us')
# Use the environment variable INVENTREE_LANGUAGE
language: en-us

How ever once I launch Inventree it's set up language to Polish by default:
image

Even if I save the setting for my account to English it return back to Polish after some time.
Also language setting seems to not be stored in account setting as in new browser it display all in Polish as well.

Steps to Reproduce

  1. Use browser with primary language different than english
  2. Set up config.yaml language: en-us
  3. Open inventree app and check UI language displayed

Expected behaviour

  1. config.yaml should have higher priority than browser language settings
  2. If user decide to use different language the setting should be stored within account settings and all browsers and app (including mobile app ) should launch with the same language version

Deployment Method

  • Docker
  • Package
  • Bare metal
  • Other - added info in Steps to Reproduce

Version Information

Version Information:

InvenTree-Version: 0.15.4
Django Version: 4.2.12

Database: postgresql
Debug-Mode: False
Deployed using Docker: False
Platform: Linux-5.4.0-186-generic-x86_64-with-glibc2.31
Installer: None

Active plugins: [{'name': 'InvenTreeBarcode', 'slug': 'inventreebarcode', 'version': '2.0.0'}, {'name': 'InvenTreeCoreNotificationsPlugin', 'slug': 'inventreecorenotificationsplugin', 'version': '1.0.0'}, {'name': 'InvenTreeCurrencyExchange', 'slug': 'inventreecurrencyexchange', 'version': '1.0.0'}, {'name': 'InvenTreeLabel', 'slug': 'inventreelabel', 'version': '1.0.0'}, {'name': 'InvenTreeLabelMachine', 'slug': 'inventreelabelmachine', 'version': '1.0.0'}, {'name': 'InvenTreeLabelSheet', 'slug': 'inventreelabelsheet', 'version': '1.0.0'}, {'name': 'DigiKeyPlugin', 'slug': 'digikeyplugin', 'version': '1.0.0'}, {'name': 'LCSCPlugin', 'slug': 'lcscplugin', 'version': '1.0.0'}, {'name': 'MouserPlugin', 'slug': 'mouserplugin', 'version': '1.0.0'}, {'name': 'TMEPlugin', 'slug': 'tmeplugin', 'version': '1.0.0'}, {'name': 'Zebra', 'slug': 'zebra', 'version': '0.6.0'}, {'name': 'KiCadLibraryPlugin', 'slug': 'kicad-library-plugin', 'version': '1.4.2'}]

Please verify if you can reproduce this bug on the demo site.

  • I can reproduce this bug on the demo site.

Relevant log output

No response

Activity

  1. added
    bug
    question
    triage:not-checked
    on Jun 28, 2024
  2. SchrodingersGat commented on Jun 29, 2024

    @SchrodingersGat
    Member

    If your browser is requesting the page in polish, this is what the server will return. The "default" language selection is intended as a back-stop after other language selection priorities are exhausted.

    From the django documentation:

    LocaleMiddleware tries to determine the user’s language preference by following this algorithm:
    
    - First, it looks for the language prefix in the requested URL. This is only performed when you are using the i18n_patterns function in your root URLconf. See [Internationalization: in URL patterns](https://docs.djangoproject.com/en/4.2/topics/i18n/translation/#url-internationalization) for more information about the language prefix and how to internationalize URL patterns.
    - Failing that, it looks for a cookie. The name of the cookie used is set by the [LANGUAGE_COOKIE_NAME](https://docs.djangoproject.com/en/4.2/ref/settings/#std-setting-LANGUAGE_COOKIE_NAME) setting. (The default name is django_language.)
    - Failing that, it looks at the Accept-Language HTTP header. This header is sent by your browser and tells the server which language(s) you prefer, in order by priority. Django tries each language in the header until it finds one with available translations.
    - Failing that, it uses the global [LANGUAGE_CODE](https://docs.djangoproject.com/en/4.2/ref/settings/#std-setting-LANGUAGE_CODE) setting.
    
  3. removed
    triage:not-checked
    on Jun 29, 2024
  4. NightSkySK commented on Jun 29, 2024

    @NightSkySK
    Author

    OK, I understand it's not a bug in this case. Can it be "feature-request" to store user preferred language in user settings? in this case login page would be still based on "language selection priorities" mentioned above, but once user successfully login it would switch to the preferred language/language which he was using during last session, etc.

  5. SchrodingersGat commented on Jul 3, 2024

    @SchrodingersGat
    Member

    @NightSkySK this is possible with the new user interface, but likely not with the current "legacy" interface.

  6. github-actions commented on Sep 2, 2024

    @github-actions
    Contributor

    This issue seems stale. Please react to show this is still important.

  7. added
    inactive
    on Sep 2, 2024
  8. removed
    inactive
    on Sep 3, 2024
  9. added this to the horizon milestone on Sep 3, 2024
  10. matmair commented on Dec 31, 2024

    @matmair
    Member

    @NightSkySK the next stable release only contains the new user interface - could you validate if this still occurs with the "master" branch?

  11. modified the milestones: horizon, 1.0.0 on Feb 26, 2025
  12. removed
    question
    on Feb 26, 2025
  13. matmair commented on Feb 26, 2025

    @matmair
    Member

    working on this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions