fix(i18n): load language files before doing anything else #3218

Merged
konrad merged 2 commits from fix/load-language-files into main 2023-03-10 13:46:25 +00:00
Owner

Resolves #3214

Resolves #3214
konrad added 1 commit 2023-03-09 12:13:21 +00:00
continuous-integration/drone/pr Build is failing Details
ee2e313ed8
fix(i18n): load language files before doing anything else
Resolves #3214
Author
Owner

This PR fixes the problem mentioned in the issue, but I'm not 100% sure about the cause of it. In simply loading the language before doing anything else, the watcher is only executed once the language files are correctly in the browser. I suspect registering the watcher happens before the app is mounted?

This PR fixes the problem mentioned in the issue, but I'm not 100% sure about the cause of it. In simply loading the language before doing anything else, the watcher is only executed once the language files are correctly in the browser. I suspect registering the watcher happens before the app is mounted?
konrad requested review from dpschen 2023-03-09 12:15:19 +00:00
dpschen was assigned by konrad 2023-03-09 12:15:23 +00:00
konrad added 1 commit 2023-03-09 12:42:42 +00:00
continuous-integration/drone/pr Build is passing Details
f9c42c737d
fix(i18n): top level await
Member

Hi konrad!

Thank you for creating a PR!

I've deployed the changes of this PR on a preview environment under this URL: https://3218-fix-load-language-files--vikunja-frontend-preview.netlify.app

You can use this url to view the changes live and test them out.
You will need to manually connect this to an api running somehwere. The easiest to use is https://try.vikunja.io/.

Have a nice day!

Beep boop, I'm a bot.

Hi konrad! Thank you for creating a PR! I've deployed the changes of this PR on a preview environment under this URL: https://3218-fix-load-language-files--vikunja-frontend-preview.netlify.app You can use this url to view the changes live and test them out. You will need to manually connect this to an api running somehwere. The easiest to use is https://try.vikunja.io/. Have a nice day! > Beep boop, I'm a bot.
Member

I suspect registering the watcher happens before the app is mounted?

I guess this is because of the vue life cycle.

  1. (script setup)
  2. created
  3. mounted

(with steps in between)

> I suspect registering the watcher happens before the app is mounted? I guess this is because of the vue life cycle. 1) (script setup) 2) created 3) mounted (with steps in between)
dpschen reviewed 2023-03-09 20:35:55 +00:00
@ -39,74 +39,76 @@ if (window.API_URL.slice(window.API_URL.length - 1, window.API_URL.length) === '
window.API_URL = window.API_URL.slice(0, window.API_URL.length - 1)
}
const app = createApp(App)

Would it work if we save the returned promise of setLanguage and load it in parallel to all the stuff until mounting the app?

const languageLoaded = setLanguage()
const app = createApp(App)

// [...]

languageLoaded.then(() => {
	app.mount('#app')
})
Would it work if we save the returned promise of `setLanguage` and load it in parallel to all the stuff until mounting the app? ```ts const languageLoaded = setLanguage() const app = createApp(App) // [...] languageLoaded.then(() => { app.mount('#app') }) ```
Author
Owner

That's how it is done right now, but that does not seem to work.

That's how it is done right now, but that does not seem to work.
Author
Owner

It looks like the language needs to be loaded before the Vue Lifecycle starts.

It looks like the language needs to be loaded before the Vue Lifecycle starts.
Author
Owner

Actually tried it again but even got an error here TypeError: route is undefined.

Actually tried it again but even got an error here `TypeError: route is undefined`.

That's weird. I just tried this myself and couldn't trigger that error.

That's weird. I just tried this myself and couldn't trigger that error.
konrad merged commit 013472e899 into main 2023-03-10 13:46:25 +00:00
konrad deleted branch fix/load-language-files 2023-03-10 13:46:25 +00:00
Member

Unsure if this was the case before, but right now it doesn't load the user language if it's not english for me.

Unsure if this was the case before, but right now it doesn't load the user language if it's not english for me.
Author
Owner

You mena it does not load it at all?

You mena it does not load it at all?
Member

Yes. It's not translated. I have to manually save the user settings again (that show the correct saved language) to trigger the loading of the language.

Yes. It's not translated. I have to manually save the user settings again (that show the correct saved language) to trigger the loading of the language.
Author
Owner

That's really wired. Is it reproducible on try?

That's really wired. Is it reproducible on try?
Member

That's really wired. Is it reproducible on try?

It was in the test branch of this pr. So I guess it should also exist on try.

> That's really wired. Is it reproducible on try? It was in the test branch of this pr. So I guess it should also exist on try.
This repo is archived. You cannot comment on pull requests.
No description provided.