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

[BUG] Form does not change language when options change #410

Open
1 task done
madflow opened this issue Sep 27, 2021 · 8 comments
Open
1 task done

[BUG] Form does not change language when options change #410

madflow opened this issue Sep 27, 2021 · 8 comments
Assignees
Labels

Comments

@madflow
Copy link

madflow commented Sep 27, 2021

Environment

Please provide as many details as you can:

  • Hosting type
    • [] Form.io
    • Local deployment
      • Version: Latest
  • Formio.js version: Latest
  • Frontend framework: React
  • Browser: Firefox latest
  • Browser version: latest

Steps to Reproduce

  1. Use React and Formio with i18next.
  2. Configure everything something like this:
  const options = {
    i18n: {
      [i18n.language]: i18n.getResourceBundle(i18n.language, 'translation'),
    },
    language: i18n.language,
    hooks: {},
  };

// https://help.form.io/developers/form-renderer#form-renderer-options
  return (
    <>
      <Form
        src={url}
        onSubmitDone={onSubmitDone}
        formReady={onFormReady}
        options={options}
      />
      {isReady ? null : <LoadingSpinner animation="border" />}
    </>
  );
  1. Change the language

Expected behavior

  • Language changes in the form

Kapture 2021-09-27 at 17 53 35

Observed behavior

  • Language does not change

Kapture 2021-09-27 at 17 56 29

This can be hack-fixed by amending Form.jsx ,

}, [props.src]);

  useEffect(() => {
    const { src } = props;
    if (src) {
      createWebformInstance(src).then(() => {
        if (formio) {
          formio.src = src;
        }
      });
      initializeFormio();
    }
  }, [props.src, props.options]);
@madflow madflow added the bug label Sep 27, 2021
@rijusougata13
Copy link

hi @madflow can you assign me here?

@madflow
Copy link
Author

madflow commented Oct 4, 2021

@rijusougata13 No, I cannot assign you.

@rafapsm
Copy link

rafapsm commented Mar 2, 2022

@madflow @rijusougata13 Is there a solution for this problem. I am facing the same issue.
Thanks

@travist
Copy link
Member

travist commented Sep 2, 2022

We added this for our Monday planning to get this prioritized. Thanks.

@PatrikWing
Copy link

Having the same issue.

@lane-formio
Copy link
Contributor

We've done some work recently around translations. Can you try again with the latest rc versions to see if this has resolved?

@madflow
Copy link
Author

madflow commented Sep 2, 2024

@lane-formio

I have installed the latest RC Version, which required a npm namespace change using the "formiojs" now as @formio/js library. I tried a full update:

 yarn add @formio/js @formio/react @formio/premium

This resulted in:

    "@formio/js": "5.0.0-rc.48",
    "@formio/premium": "^2.0.3",
    "@formio/react": "^5.3.1-dev.AvA08V.6",

Changing the language and passing it down as prop (see initial first post) is still not working.

Also, the `@formio/premium" package does not build properly and the complete build fails (I had to disable it to test the language changes). It seems, that the premium package does not know about the name change yet.

✘ [ERROR] Could not resolve "formiojs"

    node_modules/@formio/premium/lib/components/Sketchpad/Sketchpad.form.js:8:27:
      8 │ import { Components } from 'formiojs';
        ╵                            ~~~~~~~~~~

  You can mark the path "formiojs" as external to exclude it from the bundle, which will remove this
  error.

✘ [ERROR] Could not resolve "formiojs"

    node_modules/@formio/premium/lib/utils/utils.js:14:45:
      14 │ import { Utils as FormioUtils, Formio } from 'formiojs';
         ╵                                              ~~~~~~~~~~

  You can mark the path "formiojs" as external to exclude it from the bundle, which will remove this
  error.

✘ [ERROR] Could not resolve "formiojs"

    node_modules/@formio/premium/lib/components/DynamicWizard/editForm/DynamicWizard.edit.templates.js:1:22:
      1 │ import { Utils } from 'formiojs';
        ╵                       ~~~~~~~~~~

  You can mark the path "formiojs" as external to exclude it from the bundle, which will remove this
  error.

✘ [ERROR] Could not resolve "formiojs"

    node_modules/@formio/premium/lib/components/DataTable/DataTableFormioIntegration.js:19:37:
      19 │ import { Components, Builders } from 'formiojs';
         ╵                                      ~~~~~~~~~~

  You can mark the path "formiojs" as external to exclude it from the bundle, which will remove this
  error.

✘ [ERROR] Could not resolve "formiojs"

    node_modules/@formio/premium/lib/components/DataTable/DataTable.form.js:8:27:
      8 │ import { Components } from 'formiojs';
        ╵                            ~~~~~~~~~~

  You can mark the path "formiojs" as external to exclude it from the bundle, which will remove this
  error.

✘ [ERROR] Could not resolve "formiojs"

    node_modules/@formio/premium/lib/components/Captcha/editForm/Captcha.edit.display.js:1:22:
      1 │ import { Utils } from 'formiojs';
        ╵                       ~~~~~~~~~~

@lane-formio
Copy link
Contributor

Apologies, try @formio/[email protected]

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

No branches or pull requests

7 participants