Jump to content

Translate new created pages from page field on the fly


Can
 Share

Recommended Posts

Hey folks,
 
I use InputfieldPageAutocomplete a lot, but because the website is dual language it's a little awkward when creating new tags with this field.
While looking if anyone else had a solution for this I found out that InputfieldPage is still not activating language urls https://github.com/ryancramerdesign/ProcessWire/issues/889 but couldn't find a solution how to translate new entries on the fly.
 
Maybe someone comes up with a nicer solution, but for now it works for me. I copied InputfieldPage.module to /site/modules/ and added a few lines of code.
Now when creating a new tag using for example autocomplete field, I just enter "foo:bar" where foo is default (english) and bar is german title. So as you can see, right now it's quite static..

Here my complete file, I commented my additions with "added by Can"

  Reveal hidden contents

I would love to read your thought on this.

Maybe it could be interesting to have it check for both (or all) languages if the provided exists, but I'm not exactly sure how to do that.

change user language via api and run line 610 again? Or a direct $database query would be possible.. By the way, I think it would be amazing to have language selectors, like a sub-selector "title.de" or something :)

Link to comment
Share on other sites

Here's how you activate all languages for a page: https://processwire-recipes.com/recipes/activate-all-languages/

I like the idea for a language subselector, but there's always the chance of collision with other subfields as language names are arbitrary and there's no support for something like title.lang.de yet. 

Link to comment
Share on other sites

Thanks for sharing LostKobrakai,
I got only one additional language, so for me it fits for now, but with more it's better to automate it of cause. :)

That's a valid point I guess your idea title.lang.de is nice and then title.lang.all to query all languages :D

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...