Jump to content

Issue translating string using ProcessWire language translator


Erbenos
 Share

Recommended Posts

Hello,

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?

Thanks

14An4DA.png

An0PCRj.png

Link to comment
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
Link to comment
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: 

LdP9Gwz.png

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

Link to comment
Share on other sites

  • 1 month later...

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...