formio / formio.js

JavaScript powered Forms with JSON Form Builder
https://formio.github.io/formio.js
MIT License
1.89k stars 1.06k forks source link

Translation gets not always applied #2224

Closed marcus-at-localhost closed 9 months ago

marcus-at-localhost commented 4 years ago

I've setup Formbuilder similar to your example http://formio.github.io/formio.js/app/builder and I applied a translation in the options according to http://formio.github.io/formio.js/app/examples/language.html

it seems to work, but only partially when I open the model the first time [SAVE] is still english, the second time it's German. But other parts are translated right away.

Somehow it has to do with the second preview form

var onBuild = function(builder) {
  let previewForm = new Formio.createForm(document.getElementById('preview-form'), builder.form);
};

Is it possible to set that language globally over all new Formio.* instances?

here is a codepen. https://codepen.io/localhorst/pen/BaaEBZz

travist commented 4 years ago

Right not it isn't, but I agree that this should be provided. We will add it to our backlog.

marcus-at-localhost commented 4 years ago

For the time being I add language settings to each instance. https://codepen.io/localhorst/pen/KKwvKwB

let formioOptions = {
  language: 'de',
    i18n: {
            de: {
                'Edit': 'Bearbeiten',
                'Preview': 'Vorschau',
                'Save': 'Speichern',
                'Cancel': 'Abbrechen',
                'Remove': 'Entfernen',
                'Close': 'Schließen',
                'Move': 'Verschieben',
                'Copy': 'Kopieren',
            }
        }
};

let builderOptions = _.merge({}, formioOptions, {
  noDefaultSubmitButton: true
});

// initialize formio
var builder = new Formio.FormBuilder(document.getElementById('builder'), {}, builderOptions);

var onBuild = function(builder) {
  Formio.createForm(document.getElementById('preview-form'), builder.form, formioOptions);
};
olgabann commented 9 months ago

We're currently addressing a backlog of GitHub issues. Closing this thread as it is outdated. Please re-open if it is still relevant. Thank you for your contribution!