Jump to content

ProcessTranslatePage


robert
 Share

Recommended Posts

I created a companion module for Fluency to translate all fields on a page at once:

https://github.com/robertweiss/ProcessTranslatePage

You can find the corresponding conversation about it in the Fluency thread (link below), but I decided to add the module to the official list so others who have a need for this have an easier time finding it.

 

  • Like 2
  • Thanks 1
Link to comment
Share on other sites

Hi Roych,

thanks for your feedback! I found the bug – I falsely assumed that the default language id in processwire is always 1022 (which is obviously not the case …). I pushed a bugfix to the github repo (https://github.com/robertweiss/ProcessTranslatePage) and changed the version to 0.0.3. Could you try the bugfix and see if it works for you now?

  • Thanks 1
Link to comment
Share on other sites

  • 3 weeks later...

Just released v0.5 which includes the following new features:

  • Exclude fields: choose fields which should not be translated
  • Exclude languages: choose languages which should not be translated to
  • Show Single Target Language Buttons: Show all target languages as single buttons in the save dropdown instead of having only one button for all translations

Thanks to @Ivan Gretsky for proposing these additions!

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

@studiowebThanks ? To prevent possible misunderstandings: you’re talking about the $page->name field, right? This is indeed a special case as it is the only translatable system field I could think of. I would suggest the following mechanism: only translate the page name if the target language name is identical to the source language (and therefore: not translated yet) – and allow users to switch it off in the settings to prevent possible conflicts with other modules modifying the name field on save (e.g. ProcessSetupPageName). 

Link to comment
Share on other sites

@studioweb I had a deeper look into the page->name feature request and decided to not include the automatic translation of this field. As I suspected in my last post, there exists already a better solution for this ? If you install the module https://processwire.com/modules/process-setup-page-name/ and activate its option ›Update the name of existing pages‹, the name field will be updated in all languages whenever you change the corresponding field (normally title). 

  • Like 1
Link to comment
Share on other sites

v0.6 is released with the following changes:

  • New setting: Source language (thx for the idea to @Ivan Gretsky and for the pull request to @theoretic)
  • Languages for source and exclude can only be selected if they have been defined in the fluency config first
  • I had to do some refactoring of the translation strings and the module config, so please validate/correct your settings after the update to v0.6!
  • Like 2
Link to comment
Share on other sites

@bernhardSure ? 

Module Config  (sorry for the mixed labeling, I have the german language pack installed ? ):

Screenshot-2021-12-08-1006.thumb.jpg.020eb5181156c337424816d91b49f144.jpg

Publish + Translate to all target languages at once:

Screenshot-2021-12-08-1009.thumb.jpg.02cec02ce3d910985ff4dbca2049ae7f.jpg

Publish + Translate to single languages (on the left side of the arrow: source language, right: all available (aka not excluded) target languages):

Screenshot-2021-12-08-1007.thumb.jpg.e78f209b69f2bb0b8da6607982174109.jpg

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

Translating only changed fields is quite a good idea, I just added it in v0.7 ?

  • New radio option: Write Mode (replaces the checkbox Overwrite Existing Translation)
    • Translate only if target field is empty
    • Translate only changed fields
    • Overwrite all target fields

Caution: the »Changed fields«-option support is currently only one level deep. If you change any value inside a Repeater(-Matrix) or FieldsetPage field, the complete field will be translated. If anybody knows how to get the names of nested fields that changed inside the afterPages::saved hook, please let me know ?

  • Like 1
Link to comment
Share on other sites

  • 2 years later...

@robert it seems that this module does not work with the latest PW version

Schwerwiegender Fehler: Uncaught TypeError: Cannot access offset of type string on string in site/modules/ProcessTranslatePage/ProcessTranslatePage.module.php:189

#0 site/modules/ProcessTranslatePage/ProcessTranslatePage.module.php(59): ProcessTranslatePage->setLanguages()
#1 site/modules/ProcessTranslatePage/ProcessTranslatePage.module.php(41): ProcessTranslatePage->initSettings()
#2 wire/core/ModulesLoader.php (168): ProcessTranslatePage->init()
#3 wire/core/ModulesLoader.php (100): ModulesLoader->initModule()
#4 wire/core/ModulesLoader.php (111): ModulesLoader->triggerInit()
#5 wire/core/Modules.php (338): ModulesLoader->triggerInit()
#6 wire/core/ProcessWire.php (775): Modules->triggerInit()
#7 wire/core/Wire.php (413): ProcessWire->___init()
#8 wire/core/WireHooks.php (968): Wire->_callMethod()
#9 wire/core/Wire.php (484): WireHooks->runHooks()
#10 wire/core/ProcessWire.php (909): Wire->__call()
#11 wire/core/ProcessWire.php (665): ProcessWire->__call()
#12 wire/core/ProcessWire.php (613): ProcessWire->setStatus()
#13 wire/core/ProcessWire.php (315): ProcessWire->load()
#14 index.php (52): ProcessWire->__construct()
#15 {main}
thrown (Zeile 189 in site/modules/ProcessTranslatePage/ProcessTranslatePage.module.php)

Diese Fehlermeldung wurde angezeigt wegen: Sie sind als Superuser angemeldet. Fehler wurde protokolliert.

 

Link to comment
Share on other sites

Yes, this seems to be the problem. ProcessTranslatePage works with the latest Processwire version, but not with Fluency V2 (yet). @FireWiresorry for the long wait, I did not have time to merge your PR yet, but thanks a lot for your effort! 

  • Like 2
Link to comment
Share on other sites

  • 7 months later...

Good day, @robert!

We have been using your module for a long time. Thank you for making it! We have even extended you classes for our own modules:

  • a form on edit page to configure how the page has to be translated on save;
  • a Lister action for mass transtlation.

Now I have updated Fluency to a newer version (211). @FireWire has made a major rework. And you module no longer works. I have not examined the new Fluency's features. Maybe they already do all the things you wonderful module does...

I see that the incompatibility has already been reported and @FireWire even created a PR (which seems to have issues and needs some work to be merged).

Could you please look into this and update the module? If you find some time... 🙏

Link to comment
Share on other sites

@Ivan Gretsky I'm stuck under a lot of work and deadlines. If you are able to test and provide any info that would help me debug that would make a fix much easier on my part. See if there are any logs generated, dev tools console errors, or share any exceptions you're receiving when attempting to translate.

Is your issue related to the potential namespace issue that is noted under the comments of the PR? I missed the Github notifications on that so I'm just becoming aware of it now.

  • Like 1
Link to comment
Share on other sites

13 hours ago, FireWire said:

@Ivan Gretsky I'm stuck under a lot of work and deadlines. If you are able to test and provide any info that would help me debug that would make a fix much easier on my part. See if there are any logs generated, dev tools console errors, or share any exceptions you're receiving when attempting to translate.

Is your issue related to the potential namespace issue that is noted under the comments of the PR? I missed the Github notifications on that so I'm just becoming aware of it now.

I have not tested the module with PR merged. Just seen it in the last moment before creating an issue in github repo about compatibility. I am waiting for @robert to share his thoughts on this. Maybe he is already in the process of working with your PR. Will ping him on github too.

Link to comment
Share on other sites

Hi @Ivan Gretsky and @FireWire,

Sorry it took me so much time to respond to the big Fluency update. To be honest, I already refactored my module a couple of months ago to work without any dependencies (except the DeepL API), so Fluency is no longer necessary to use it. Since I only did this refactor for one client, I need to remove some customizations before I can push the new version to Github.

I don’t expect this to take too long, so I’m hopeful that I’ll be able to release Version 1.0 for you to test tomorrow or thursday 😊.

Thanks for your patience!

  • Like 3
Link to comment
Share on other sites

Hello everyone,

I'm excited to announce that Version 1.0 of ProcessTranslatePage is now available on GitHub: https://github.com/robertweiss/ProcessTranslatePage

Please note that there are some breaking changes in this update. I recommend uninstalling and then reinstalling the module to ensure everything works smoothly. You can use the same DeepL API key that you use with Fluency.

After installation, you will (hopefully) see two new fields for the language template. However, only the ⁠'translate_locale' field is required for the module to function properly.

Thanks for your patience, I hope you find this update useful!

  • Like 4
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...