Skip to content

Conversation

SkyLundy
Copy link

Refactored to work with the new Fluency module's API.

  • Module and config both use Fluency to provide the languages that are configured
  • Module config stores the ProcessWire language IDs as config values for default/excluded languages
  • Source/Target languages are now instances of Fluency's ConfiguredLanguageData objects that encapsulate much of the data needed
  • Using the ConfiguredLanguageData object removed the need to manually parse language codes or determine which should be used
  • Add error handling. Fluency's translate method returns localized error messages that will now be shown after page load if problems occurred during translation
  • Fixed a bug where excluded languages were still included
  • Versioned the Fluency module dependency to require Fluency 1.0.6 or later
  • Version bump, incompatible with previous versions of Fluency

Items that don't affect functionality:

  • The info banner after page save now shows which fields were translated by name, ended up helping during coding
  • Messages and strings in the UI for ProcessTranslatePage uses the localized strings from Fluency so this module will be automatically translated if Fluency has been

I ended up having to make some modifications to how Fluency initializes itself so that it can be used by other modules, so users will need to upgrade Fluency to the latest for these modules to work together.

@tiberium-v
Copy link

As a module user note: I test the PR, and it makes the module functional again.

Thx!

@jonashamm
Copy link

Hey! Thanks to @SkyLundy and @robertweiss for your great modules!
I'm also trying to get the current version of Fluency running in combination with TranslatePage and used this version. But then I currently get the following error:
Fatal Error: Uncaught TypeError: Fluency\DataTransferObjects\AllConfiguredLanguagesData::getByProcessWireId(): Argument #1 ($id) must be of type array|int, string given, called in site/modules/ProcessTranslatePage/ProcessTranslatePage.module.php on line 180 and defined in site/modules/Fluency/app/DataTransferObjects/AllConfiguredLanguagesData.php:84
I'm using ProcessWire 3.0.229. Might I be doing something wrong or are there maybe new changes to one of the modules since this last PR here?

@jonashamm
Copy link

@SkyLundy @robertweiss ... sorry, seams like I did something wrong. Now I installed both of your modules via ProcessWire and copied ProcessTranslatePage.config.php and ProcessTranslatePage.module.php from commit 984ee7d0225fadea3eea39be47ecaed9fce67e39 ... and it works!
Sorry for bothering!

@tiberium-v
Copy link

@SkyLundy Your patch is unfortunate not more working. I get with tracy:

File: .../ProcessTranslatePage/ProcessTranslatePage.module.php:69

Error
Class "Fluency\App\FluencyLocalization" not found

68:            $this->localizedStrings = (object) [
69:                'translate' => FluencyLocalization::get('inputfieldTranslateButtons', 'translate'),
70:                'translated' => FluencyLocalization::get('standaloneTranslator', 'fieldLabelTranslated'),
71:                'rateLimitError' => FluencyLocalization::get('errors', FluencyErrors::RATE_LIMIT_EXCEEDED),
72:            ];

Is there a possibility to implement this page wide translation as a built-in function in fluency?

@ivangretsky
Copy link

Good day @robertweiss !
Are you planning to have a look at this PR soon? Just came here to say that your module is a great one and I have been using it with great success for a long time. Would be great to have it updated to work with new Fluency version. And it is cool that @SkyLundy is ready to help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants