-
Notifications
You must be signed in to change notification settings - Fork 11
Allow taxonomy labels to be translated #26
Comments
I can understand wanting to translate strings that display on the front end, but changing the name of the However, if you're talking about the https://github.com/copyblogger/agentpress-listings/blob/develop/includes/class-listings.php#L71-L84 |
It looks like the WPML team highlighted the wrong section in the screenshot above. The customer needs to translate the contents of the first The issue is that custom taxonomy labels that people declare at Listings → Register Taxonomies aren't currently translatable via WPML. i.e. <?php
echo "<select name='$tax' id='$tax' class='agentpress-taxonomy'>\n\t";
echo '<option value="" ' . selected($current == '', true, false) . ">{$data['labels']['name']}</option>\n";
foreach ((array)$terms as $term)
echo "\t<option value='{$term->slug}' " . selected($current, $term->slug, false) . ">{$term->name}</option>\n";
echo '</select>'; [From: https://github.com/copyblogger/agentpress-listings/blob/develop/includes/class-property-search-widget.php#L46 ] I'm talking to the WPML team to clarify what they require from us here, but at this stage it seems possible that the plugin may not be declaring the taxonomy labels using a Gettext function: <?php
function register_taxonomies() {
foreach ((array)$this->get_taxonomies() as $id => $data) {
register_taxonomy($id, array('listing'), $data);
}
} [From: https://github.com/copyblogger/agentpress-listings/blob/develop/includes/class-taxonomies.php#L298 ] The It looks like taxonomies are being registered with data that doesn't use a Gettext function, but there may be other workarounds for this. Will report back if I hear more from WPML. |
Ah, I see. Yes, that's correct. But by necessity. We allow users to create custom taxonomies for listings using an admin UI. Unfortunately, this means that they are not translatable, as they aren't hardcoded. |
Seems like when I worked support and this came up I suggested to users they could create additional taxonomies for the translated language and use a plugin to conditionally load the widget per the translation the site was using. It's a bit more work but allows for better localization as you may not present the same options or present them in exactly the same way depending on the culture you are selling to. |
Thanks very much for confirming, Nathan. I thought that might be the case. Many thanks also to Nick for the suggested workaround – I'll be sure to offer that as an option here. WPML allows taxonomy label translation via WPML → Translate Taxonomies (even dynamically created ones). I was hoping we'd be able to automate translation by using the taxonomy label we already pull from Still looking into this, but will let you know if anything comes of it. |
I have a potential fix for this in the PR above. It relies on WPML, but most customers translating AgentPress Listings tend to use that for their translations. |
nickcernis, this fix isn't working in my case. The first field of the |
@uritzo It's still working for me in my tests. I commented at #27 with more info about how I'm setting this up. Following up with WPML support to debug your WP/WPML installation may be worthwhile here. The fix that the pull request was based on originally came from their team. |
Thanks @nickcernis, now is working perfect thanks! Seems that in the last update of the plugin "agentpress listings 1.2.7, the solution is not implemented by default. Thank you, you saved my ass. |
Hello @nickcernis did you tried to update to the last version? Because I need to do it and I don't know if its gonna work. THANKS |
@uritzo I have not tried it with the latest WPML yet. Maybe take a backup or snapshot first? |
Yes I actually tried in the staging site. It's not working anymore... But I can't find why! Im not that good on solving code problems so if you find a way to keep up to date with WPML just put it here please! Thanks for the quick answer. Tested on WPML 3.9.3 AND WPML String Translation 2.7.3 |
@uritzo You're welcome! You may be best contacting WPML support if an update has caused this; their team originally supplied the code used above. |
I found a thread talking about the same issue. They say "We previously tried to get in touch with the plugin author but never got a response" Maybe its time to "match" and make us all happy 💯 👍 👍 |
As reported by a customer here, Listing taxonomy labels are not currently translatable.
The customer provided the following screenshots from WPML support, who suggest using the
gettext
filter to add translation support for drop-down labels:The text was updated successfully, but these errors were encountered: