Closed k1sul1 closed 8 years ago
I think there's no need to implement support for other multilingual plugins at this time. It is also kinda decision about if we wan't to encourage usage of badly coded monster sized things (wpml :trollface:).
Yeah I agree.
I could rename the class to WPLF_Polylang, just for clarity. I could also make the class loading optional, if someone wants to make a WPML port of it.
I researched it briefly, and the WPML string translation logic isn't that different, but there is no way I'm going to install WPML on any of my projects.
Okay, I made the changes.
What do you think @anttiviljami?
Gorgeous! Merging right away!
Thank you !
Not a big deal, but double curly braces are pretty common as placeholder delimiters, meaning that eventually there's going to be collision. In my case some placeholders for template bindings were stripped of curly braces, which resulted in some loud, naughty words and a half hour long bug hunting trip in all the wrong places.
Luckily this is an edge case and I can use alternative syntax for placeholders, but I might even try to modify the code a bit, if it could be considered an actual improvement and worthy of a pull request.
I think we could provide a filter to change the delimiters? Shouldn't be too hard to implement.
I wouldn't want to break any existing functionality, even if this feature hasn't been officially released just yet, hence the filter.
I like the idea of setting up custom delimiters via filter. I don't see many cases where using double handlebars is actually an issue
Filters for delimiters might be good, but keep in mind that if at some point another plugin uses wplf+polylang, changing delimiters would probably cause trouble.
I had a different idea - I made a small change to the delimiter regex, which now matches the inner 2 curly braces instead of the outer ones, so {{{{foo}}}} becomes {{foo}} after going through WPLF-Polylang . I think this solves most of the problems in similar cases and as a bonus doesn't expose the delimiter regex to changes by short-sighted users.
classes/class-wplf-polylang.php, line 8
protected $regular_expression = "/{{[^{}]+}}/"; // matches {{, anything that is not either { or } and finally }}
As discussed in #17.
This is currently dependent on Polylang, so even if you think it looks good, don't merge just yet.
Should we implement support for other multilingual plugins too?