Jump to content

Issue translating string using ProcessWire language translator

Recommended Posts


recently i came across this issue.

Basically, I am using TemplateEngineBlade module which allows me to use Blade templating engine in my templates. I needed to translate strings like '__(<your string>)', but since the module compiles the templates into its own directory (as highlighted in screenshots), the language translator find the function call in 2 files:

  1. Template where the code is written
  2. Modules 'compiled'/cache directory where the templates are in their compiled state

Now, I actually have to translate the string in its compiled directory else it  doesn't work at all. But since that filename changes often it is not usable at all.

I tryed prepending all templates with a file (for example _init.php) and getting all translatable strings there which works but not for the use cases where i need to get same string translated in multiple languages in a single page - I would have to create separate variables.

Does anyone have any idea which would help me work around my issue?




Share this post

Link to post
Share on other sites

I never used Blade, so I don't even know if that's an option, but can you tell Blade to not create that cache file in the first place?

If that's not possible, try to disable cache in your template(s).

Alternative multilang approaches are described here:

And then there's also the recently added functional fields (never used it myself so far): https://processwire.com/blog/posts/functional-fields/


  • Like 1

Share this post

Link to post
Share on other sites

Actually the intro to the article you linked was just what I needed.

I guess I should have been more thoughtful about having an option to use translation context. If I just edit the files like this: 


it works.

I can simply edit the template files in Language translator since the compiled templates also inherit the translation context, dummy me.

Thanks a lot

Share this post

Link to post
Share on other sites

@Erbenos .. Could you please explain how we can configure PW to allow for Blade usage  ..

i tried to do that but i get errors :( - i just opened a file inside "Templates" Directory and put: 


$view->share('foo', 'bar');



Share this post

Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Noel Boss
      Hi everyone 🙌
      Is there a way to order the language tabs in the backend? Currently, they seem to be ordered based on the created date (or id?) …
      ( time passes … ⏰ 🚶‍♂️)
      Just answered my own question. One can reorder the languages in the page tree under admin » languages or directly in the DB » pages » template_id=54 » sord field.
      Anyone knows if there are side effects when moving the default language from sort 0 to somewhere higher?
    • By gerritvanaaken
      Wouldn’t it be cool to have whole repeater items (or even repeater matrix items) language-specific. Some of my clients do have pages that are 90% identical in German and English, but there are some sections that should not appear in one or another language. I attached a concept screenshot.
      Would something like this be possible with some simple backend hooks and "hidden checkbox fields"? Or is it way more complicated?

    • By Sten
      This is not directly about language module but I think I can get information from you.
      Can I add a vendor module to have all languages written automatically into name?
      I used this vendor module which is good with any language (hebrew, arabic...). How could I add it, so admin interface can use it ?
      Thank you
    • By Sten
      Is it possible for home.twig or any other template to be inserted inside a other larger template which is like an empty enveloppe, a template parent ? And at the same time to have placeholder from several part ?
      Thank you

    • By prestoav
      Hi all,
      A very odd issue this one!
      I'm working on a site with 5 languages - English (default), French, German, Spanish and Polish. I have a set of pages set up as a country list (templae='country') which contain various country info like two-letter country code etc and where the page title is the Country name. This is so that I can use the country list in various parts of the site.
      When the site is showing in English, Spanish and Polish I can display the country list without an issue. However, when the page is displaying in French or German the country pages seem not to exist. So, this code...
      $countries = $pages->find("template=country"); foreach ($countries as $country) { if ($country) { echo $country->title . "<br />"; } } ...displays the country list just fine in English, Spanish and Polish but displays nothing in French and German.
      Just for extra info, the Title field is set up as PageTitleLanguage and all languages are setup the same.
      Any ideas?
  • Create New...