Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i18n locales loading is broken #3015

Closed
bilravil opened this issue Mar 21, 2022 · 1 comment · Fixed by #3072
Closed

i18n locales loading is broken #3015

bilravil opened this issue Mar 21, 2022 · 1 comment · Fixed by #3072

Comments

@bilravil
Copy link

Describe the bug
From the 0.165.0 version (this commit) is not working i18n localization files loading.
My localization file is placed in packages/editor-ui/src/plugins/i18n/locales directory as well.
With the same environment and settings a localization loading is working in previous n8n versions (0.164.0 and lower)
Link to my comment from PR with my investigations.

To Reproduce
Steps to reproduce the behavior:

  1. clone n8n git clone https://github.com/n8n-io/n8n.git
  2. install all dependencies lerna bootstrap --hoist
  3. copy localization file to packages/editor-ui/src/plugins/i18n/locales
  4. set N8N_DEFAULT_LOCALE=ja to env
  5. npm run build
  6. npm run start

Expected behavior
n8n editor ui with settled language.

Environment:

  • OS: MacOS Catalina 10.15.7
  • n8n Version 0.165.0
  • Node.js Version - v14.18.0
  • Additional ENVs - N8N_DEFAULT_LOCALE=ja
@zerobig
Copy link

zerobig commented Mar 26, 2022

I fixed it.
This is due to the fact that NodeView.vue has not yet been initialized at the time of language installation. So watch defaultLocale is never called.

watch: {
...
	async defaultLocale (newLocale, oldLocale) {
		loadLanguage(newLocale);
	},
},

I just added a function call loadLanguage to mounted method:

async mounted () {
...
	try {
		await Promise.all(loadPromises);

		if (this.defaultLocale !== 'en') {
			try {
				loadLanguage(this.defaultLocale); // <= Here is what I added
				const headers = await this.restApi().getNodeTranslationHeaders();
				addHeaders(headers, this.defaultLocale);
			} catch (_) {
				// no headers available
			}
		}
	} catch (error) {
...
}

Let someone else do the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants