Plugin Author
Tim W
(@timwhitlock)
Fuzzy matching is not relevant here.
Syncing a PO or POT directly to your source code should work. Please provide full details if you want me to examine why it isn’t.
Hi Tim,
Thanks for the quick reply. What do you mean by “Syncing a PO or POT directly to your source code should work.”?
My flow was:
– Write theme with ±20 translatable strings
– Install Polylang Pro for managing translations
– Install Locotranslate for managing string translations
– This all worked
– Changing/adding a string in the theme source doesn’t update the strings visible in the [Loco plugin > Themes > English > Source text fields]. Should the [Sync] button here re-scan the theme folder?
Plugin Author
Tim W
(@timwhitlock)
What do you mean by “Syncing a PO or POT directly to your source code should work.”?
I mean that there is no problem with Loco Translate’s ability to identify __ and _e function calls, so without knowing exactly what you’ve done I can’t say why it doesn’t work.
Should the [Sync] button here re-scan the theme folder?
If the English file is syncing to a POT file then no. If the English file is syncing to source code, then yes. I can’t tell you which is the case.
To understand what’s happening for yourself please consult the help page on working with templates and the related page about the sync function.
Hi Tim,
The project has been paused for a bit, excuse my late reply.
From reading a lot of your documentation, I feel like I’m not (automatically) generating a refreshed POT file upon a theme update.
Is there any way to force a rescan for the POT file? After which I assume I can sync these with the PO file from the admin?
Hope you can point me in the right direction.
Best,
Dave
Plugin Author
Tim W
(@timwhitlock)
I feel like I’m not (automatically) generating a refreshed POT file upon a theme update.
Correct. File updates do NOT happen automatically in Loco Translate (i.e. in the background, without your action). This is deliberate as operations can be destructive if not configured properly.
Is there any way to force a rescan for the POT file?
Not without writing some code of your own. Scanning source code is an expensive operation, so it’s not done as a matter of course in order to prompt users about old (out of sync) POT files.
You would have to perform your own scan, triggered by some WordPress hook that fires after your theme is updated. I can’t help with such a complex bit of coding, but you may find Loco Translate’s WP-CLI extract command useful instead. You could run this every night if you wanted, just after you expect the WordPress updater to run. A lot easier than writing a plugin to do it all in code.
See https://localise.biz/wordpress/plugin/manual/wpcli#extract
Thanks for the quick reply Tim, this explains a lot!
One more question: when I enabled the plugin at first, at some point the initial POT file was created, right? I can’t recall making that myself. Am I misremembering or missing something?
Plugin Author
Tim W
(@timwhitlock)
when I enabled the plugin at first, at some point the initial POT file was created, right?
Loco Translate does not create any files automatically. That includes creation of POTs when you enable the plugin.