• Resolved edo888

    (@edo888)


    Hi,

    I have a client who uses GTranslate paid version (Translation Proxy).

    The forms generated by Ninja Forms do not get translated, because the form is being rendered by JavaScript

    
    <!-- TODO: Move to Template File. -->
            <script>
                var formDisplay = 1;
    
                /* Maybe initialize nfForms object */
                var nfForms = nfForms || [];
    
                /* Build Form Data */
                var form = [];
                form.id = '1';
                form.settings = {...};
    ...
    

    I can see that you have a todo to move it to the template.

    Is there a way you can do that, or may be you can load form.settings by doing an ajax request, so GTranslate can translate the JSON response?

    Thanks!

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author James Laws

    (@jameslaws)

    All strings, including those added by javascript should be localized properly for translation. In fact we have over 25+ full language translations available for Ninja Forms thanks to the team at GoDaddy.

    I’m not sure what else we could do for GTranslate as it works fine for Poedit.

    Plugin Contributor klhall1987

    (@klhall1987)

    Marking this issue as resolved. Please let us know if you have any further questions. We will be happy to help.

    Thread Starter edo888

    (@edo888)

    Hi,

    My question was more about your TODO comment.

    So as I understand you have plans to do it and when it is done the form will be pre-rendered server side, so there will not be anything to do with javascript on client side. In that case our parser will be able to get the strings out of HTML and translate it. Right now we cannot do that, because <script> is not structured and we cannot know what should be translated to not break the javascript code.

    Thanks!

    Plugin Contributor Kyle B. Johnson

    (@kbjohnson90)

    @edo888 the mention of the “Template File” was an organizational comment, where I was wanting to use an *.html file to store the script tag and its contents, which could then be parsed as a template and output. This is as opposed to exiting and re-entering PHP processing.

    That said, server-side rendering is something that we are considering, but would require a refactor to MarionetteJS version 3, which supports HTML/DOM attachment of a Backbone Application. This would allow the initial rendering of the form to be performed on the server, with view updates being handled by the application.

    However, this does not address the issue of translating on page render since the view updates would still be using JavaScript and would override the initial render.

    Being a WordPress plugin, Ninja Forms follows WordPress standards for translation, which is currently a PHP process. Strings displayed by the app are translated then localized onto the page using the WordPress script localization process.

    Unfortunately, it sounds like there may currently be some compatibility issues between the translation process and Ninja Forms. Although, it would be an issue for anything rendered (or even updated) by JavaScript.

    Thread Starter edo888

    (@edo888)

    So you are saying that you will output rendered English HTML form, then do the client side render to replace the labels to other language, is that correct? If that is the case, it works for me, just need to know when it will be done.

    Thanks!

    Plugin Contributor Kyle B. Johnson

    (@kbjohnson90)

    Rather, anything parsed on render will be overridden by the JS with the WordPress translated strings. So any on page translation would need to update after the JS.

    Thread Starter edo888

    (@edo888)

    OK, I think I’m saying the same thing. So if I disable your client side rendering, which will be easy, it will stay in server side non-translated form.

    Why do you not render the translated HTML form, but instead use Javascript later?

    Thanks!

    • This reply was modified 7 years, 12 months ago by edo888.
    Plugin Contributor Kyle B. Johnson

    (@kbjohnson90)

    The form is fully rendered by JavaScript. It is a BackboneJS application.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Translating Ninja Forms with GTranslate’ is closed to new replies.