Support » Plugin: Contact Form X » multilingual form

  • Resolved tezalsec

    (@tezalsec)


    Hey Jeff,

    sorry to spam you with ‘issues’ πŸ™‚ My site is in two languages (with the help of the WPML plugin), and I am now trying to translate the labels, button text and messages.

    It is nice we can customize the labels in the settings, but if I understand correctly, this overrides your translatable strings in your code. So po/mo files can not be used for labels chosen in the settings other than the default ones, correct?

    For instance, you have this in your code for the submit button:

    __(‘Send Message’, ‘contact-form-x’);

    I can create a translation for this in the po file, as long as it stays this default value. But I changed it. I am wondering if this could be dynamic in your code, like:

    __($my chosen_button_text, ‘contact-form-x’);

    Then I could translate any label text in the po file, right?

    Thanks again πŸ™‚

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Jeff Starr

    (@specialk)

    Hi again,

    It’s an interesting idea, but best practice is to never use a variable for any underscore (translation) functions. It opens up security issues, etc.

    Best advice is to use one or the other, translation or options, to set the labels that you need.

    Thread Starter tezalsec

    (@tezalsec)

    @specialk , I see your point, didn’t thought of that. So that means no multilingual solution is possible, without using your default label values.

    Maybe it is an idea to create the option to create more than one contact form, with different values/settings. That would make it more versatile and supporting a multilingual setup, and would be more attractive in comparison to CF7, which supports this.

    Actually, maybe I could petition you to use “Name:” labels instead of “Your name:” labels, as the removal of the word “Your” was actually all I wanted to get rid of. πŸ™‚

    Thanks.

    Thread Starter tezalsec

    (@tezalsec)

    I thought the default label values (like “Your Name”) where hardcoded inside __ functions, but they are not. They are only in the database I see now. So they can not be translated either. I’m giving up doing it without hacking, I’m just gonna hack your contactformx_get_input function, and replace the labels there.

    To respond to what you said, there is a solution to the security thing, though. you could based on chosen settings (label values) create a code file on the fly when saving settings, containing hardcoded label values. Like:

    // printed into file
    $label_button = __(‘my chosen_button_text’, β€˜contact-form-x’);

    Plugin Author Jeff Starr

    (@specialk)

    Thanks for the information. If you let me know specifically what you are doing with contactformx_get_input(), I can try to add a way to do it via filter hook. So that way you’re not modifying any core files (not recommended).

    Thread Starter tezalsec

    (@tezalsec)

    Thanks for getting back to it, but I decided to go back to Contact Form 7. I loved your lightweight solution, but the lack of multilingual support was just too much of an obstacle. I hope you’ll integrate it someday.

    Cheers.

    Plugin Author Jeff Starr

    (@specialk)

    It’s all good, glad you found a solution, tezalsec. Cheers.

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.