blakej115 / magic-forms

Create easy (and almost magic) AJAX forms
https://octobercms.com/plugin/blakejones-magicforms
MIT License
6 stars 4 forks source link

Rainlab Translation for OC V3. #13

Open apinard opened 1 year ago

apinard commented 1 year ago

Hi,

plugins\blakejones\magicforms\classes\BackendHelpers.php

public static function isTranslatePlugin() :bool { return class_exists('\RainLab\Translate\Classes\Translator') && class_exists('\RainLab\Translate\Models\Message') && class_exists('\RainLab\Translate\Models\Locale'); }

RainLab\Translate\Models\Locale

That model doesn't exist in RainLab Translate v2.1.3, which cause Magic Form to be untranslatable.

apinard commented 1 year ago

Basically,

I removed the class_exists('\RainLab\Translate\Models\Locale')

plugins\blakejones\magicforms\classes\BackendHelpers.php

public static function isTranslatePlugin() :bool { return class_exists('\RainLab\Translate\Classes\Translator') && class_exists('\RainLab\Translate\Models\Message'); }

and comment out this :

// LOAD TRANSLATOR PLUGIN
        // if (BackendHelpers::isTranslatePlugin()) {
        //     \Log::info('ici');
        //     $translator = \RainLab\Translate\Classes\Translator::instance();
        //     $translator->loadLocaleFromSession();
        //     $locale = $translator->getLocale();
        //     \RainLab\Translate\Models\Message::setContext($locale);
        // }

in the file plugins\blakejones\magicforms\classes\MagicForm.php

now it seems to work.

az-vm commented 1 year ago

Hello,

It´s true, now there is no option to translate message of MagicForms.

Any fix?

Kind Regard´s

nnmer commented 1 year ago

same here, translation doesn't work. linking another similar issue (#16 )

@blakej115 any ideas on when may have a chance to fix ?

ssi-com-pl commented 1 year ago

Any updates on this issue?

blakej115 commented 9 months ago

Pull request #18 has been merged in. I apologize for the delay.

Thanks!

az-vm commented 9 months ago

@blakej115 Thank you! i will update and test it! :)

az-vm commented 9 months ago

the fix of @apinard worked, but this update does not fix the issue, the translate word, don't show on translate messages. OC V. 3.57 OC Translate V. 2.2.7 Magic Form V. 1.6.5

How i can rollback ?

blakej115 commented 9 months ago

@az-vm For testing purposes, you can try and change the code to exactly what @apinard suggested.

On line 33 of /plugins/blakejones/magicforms/classes/BackendHelpers.php, change the code from this:

return class_exists('\RainLab\Translate\Classes\Translator') && class_exists('\RainLab\Translate\Models\Message') && class_exists('\RainLab\Translate\Classes\Locale');

Change to:

return class_exists('\RainLab\Translate\Classes\Translator') && class_exists('\RainLab\Translate\Models\Message');

See if that fixes your issue. I don't think it will, because the \RainLab\Translate\Classes\Locale should exist. If making this change doesn't fix your issue, then you are having some other kind of issue, because this change makes your code identical to what @apinard suggested.

Please let me know the result.

Thanks!

az-vm commented 9 months ago

I have try to change the line, and got same result as the fix of @apinard to show on the translation messages the word to be translated, i have to go to he page of the form, and hit the form to show the "word" and then "Scan for messages" the word will show to be translated.

blakej115 commented 8 months ago

@az-vm I don't think I understand what your last message said. I am curious to know if anyone else is having issues.

az-vm commented 8 months ago

Hello @blakej115 Ok! I will try to explain me better.

When we add some text like this:

Captura de ecrã 2023-12-04, às 21 32 16

And when we go here:

Captura de ecrã 2023-12-04, às 21 15 34

The message "text" does not show with scan and clean caches, etc..... like normal use case.

We need to go to the form in the frontend, hit the form, so then the message "text" can show up to be translated.

This as a behavior, exactly the same as the fix provided by @apinard

Hope you understand it now, or i can send you a capture video.