mealie-recipes / mealie

Mealie is a self hosted recipe manager and meal planner with a RestAPI backend and a reactive frontend application built in Vue for a pleasant user experience for the whole family. Easily add recipes into your database by providing the url and mealie will automatically import the relevant data or add a family recipe with the UI editor
https://docs.mealie.io
GNU Affero General Public License v3.0
7.41k stars 741 forks source link

Language settings are saved for one browser #332

Closed Norsagir closed 3 years ago

Norsagir commented 3 years ago

Describe the bug When a language other than English is selected and settings are saved, site is still in English when using another PC/browser with clean cache.

Steps To Reproduce Please be specific!

  1. Login as admin
  2. Go to the site settings
  3. Click on the language icon
  4. Select another language (anything except English)
  5. Click on "Save"
  6. Go to the website with another browser with clean cache

Expected behavior Site is in the selected language with every browser.

Actual Behavior Site is in English with other browser except the one used to apply settings.

Device Information (please complete the following information):

Additional context Before opening this issue, I asked about this in the discussion #331

hay-kot commented 3 years ago

Sorry about this, I should have caught the problem. I think I've found the underlying issue though. During a rewrite of the settings, we missed a few sections on the frontend where the language was cached, some parts of the website were pulling from one 'store' some were pulling from another.

sephrat commented 3 years ago

Yes we never retrieve from the API but always from the store. So far I've tried a quick and simple fix but the API call comes too late after some frontend initialization (some items in the menu and Vuetify components). I'm still investigating. As a fallback solution, maybe we could set an env var for it and be done with it.

hay-kot commented 3 years ago

Yes we never retrieve from the API but always from the store. So far I've tried a quick and simple fix but the API call comes too late after some frontend initialization (some items in the menu and Vuetify components). I'm still investigating. As a fallback solution, maybe we could set an env var for it and be done with it.

I think I was able to get it sorted out in this commit . I think it's as simple as caching the siteSettings, pulling the language from the siteSettings cache and cleaning up all the old references/assignment. I still need to do another pass and make sure I caught all the references.

sephrat commented 3 years ago

I like your solution better than the one I started to cook, but it's still not enough for some texts: image Same goes for the top-right menu and the admin menu. 'Standard' texts get translated on the fly but some stuff like these were coded differently and are not updated when the locale changes after the initialization. Basically what fails us is the async thing: we'd need to wait for all translations to be calculated only when we get the settings from the API. On second thought, maybe it's the way these menu items are generated that need refactoring, not the way we set the locale.

Norsagir commented 3 years ago

~~I think I just discovered than the same problem occurs when selecting a different color for the default theme : default colors are still displayed until I go to the Theme settings and reapply the default theme. Do you want me to open a new issue for that problem ?~~ EDIT : I failed cleaning the cache of my web browser, but the user may expect to see the website changing on all web browser even if cache is not clean. Is it another issue ?