-
AuthorPosts
-
November 20, 2015 at 12:02 pm #673152
Hi guys,
I’m using the Integrity stack on my fantastic X theme.I know also installed, via the “Polylang” WP plug-in, a multi-language support for my site (italian and english).
I was wondering: how can I change the Portfolio Custom URL Slug and the Tag List Title to have them differentiated according to the language used?
For instance, here’s the italian version of a portfolio item: http://www.vinodiretto.it/it/cantina/bele-casel/
and here’s the english version of the same: http://www.vinodiretto.it/en/cantina/bele-casel/They both have the “cantina” custom url slug now and the same “vini” tag list title, while I’d like to have them differentiated as per related language.
Is that possible?Thanks!
November 20, 2015 at 6:18 pm #673662Hi there,
Thanks for writing in.
It’s not possible, slug is the identity of your post type. Changing it to another may detach your existing portfolio items resulting to 404 page.
There are of course some way, but they are more complex as you’re working with permalinks. Any mistake would result to 404 pages. Like from here http://wordpress.stackexchange.com/questions/30021/theme-localization-of-slugs-custom-post-types-taxonomies
You may hire a developer that’s familiar working with permalinks.
Thanks for understanding.
November 21, 2015 at 1:50 am #673964Thanks for your reply.
I guess the best way would be to find a name for the slug that can fit both the IT and EN languages (like the word “portfolio” would be).
And what about the Tag Lis Title? Is that somehow changeable according to the language in use?
On both the live pages that is now set to “Vini” but it would need to be instead different/translated:IT http://www.vinodiretto.it/it/cantina/bele-casel/
EN http://www.vinodiretto.it/en/cantina/bele-casel/Cheers!
November 21, 2015 at 2:24 am #673981Hi there,
Yes, you should able to translate them. And your plugin should have the capability to do that. Like WPML, there are different section for each language and for each taxonomy (category, tags, etc).
You may check your translator/plugin for documentation as the procedure may change depending of who made the plugin.
Thanks.
November 21, 2015 at 4:29 am #674058Thanks, but does that apply to the Labels fields on Customizer > Portfolio?
I found a way to have custom/language-based tags and categories but I’m trying to have different labels for EN and IT also.Thx!
November 21, 2015 at 5:32 am #674091Hi there,
Would you mind providing us with login credentials so we can take a closer look? To do this, you can make a post with the following info:
– Link to your site
– WordPress Admin username / passwordDon’t forget to select Set as private reply. This ensures your information is only visible to our staff.
Thanks.
November 21, 2015 at 6:40 am #674127This reply has been marked as private.November 21, 2015 at 4:57 pm #674471Hi there,
You’re referring to customizer’s data that is pulled from database. They are not currently translatable, but you should able to translate them by adding this code at your child theme’s functions.php
add_filter('x_option_x_portfolio_tag_title', 'x_make_translatable', 999 ); add_filter('x_option_x_portfolio_launch_project_title', 'x_make_translatable', 999 ); add_filter('x_option_x_portfolio_launch_project_button_text', 'x_make_translatable', 999 ); add_filter('x_option_x_portfolio_share_project_title', 'x_make_translatable', 999 ); function x_make_translatable ( $string ) { return __( $string, '__x__'); }
Then add this code too, then scan your strings again and remove this same code when the translation works. Or you can just let this stay.
add_action('init', 'x_invoke_translation', 99999 ); function x_invoke_translation () { x_get_option( 'x_portfolio_tag_title' ); x_get_option( 'x_portfolio_launch_project_title' ); x_get_option( 'x_portfolio_launch_project_button_text' ); x_get_option( 'x_portfolio_share_project_title' ); }
Then let me know π
Thanks.
November 22, 2015 at 2:19 am #674783Hi,
thanks for the feedback!I’ve added those two parts of code on the file on child themeβs functions.php but I’m not clear about what should I do next π
I believe that code makes some fields translatable but where that translation should be set up exactly? and how can I decide a specific translation for a specific language?
thanks!
November 22, 2015 at 3:22 pm #675200Hi there,
Hmmm, how do you translate them? Through PO files? I did check PolyLang and I only saw 18 strings, but there should be lot of strings. It could be that Polylang isn’t able to detect all other strings including the above one.
Some uses this,
pll_register_string('string1', 'string2');
Though, that kills the purpose of string translation from their setting. So I added this,
pll_register_string('Vini', 'Tag Archive');
and nothing happens either. It’s failing to translate all other strings. Though, I installed on my end and it’s just working on my end.Could you try another translation plugin? Like WPML.
Thanks!
November 22, 2015 at 4:37 pm #675262Thanks,
I wanted to try also WPML at the beginning but I ended up with Polylang in the end because it’s free π and because I managed to have some adjustments with urls on different languages that I’m not user I could have made with WPML. So it would be awesome if there would be a way to make everything work directly with Polylang πI took a look at the additional code you’ve added in functions.php and I was noticing that this introduced a field in the Polylang settings but, as you stated, it’s not working at the moment.
So I’ve tried changing that bit of code as follows (but it’s not working either) because I thought that would have been more proper as it’s referred to the actual Tag Title rather than the Tag Archive, as before:
pll_register_string('x_portfolio_tag_title', 'Vini');
Maybe it’s just a feeling but I think we might be close to a solution here, with this way of adding a dedicated field in the Polylang configuration!
Would there be a more proper configuration for that bit of code above, by any chance? What should it be the right syntax for the Tag Title?
thanks again in advance!
November 22, 2015 at 11:28 pm #675507Hi there,
Let’s try this, replace everything above.
add_filter('x_option_x_portfolio_tag_title', 'x_make_translatable', 999 ); add_filter('x_option_x_portfolio_launch_project_title', 'x_make_translatable', 999 ); add_filter('x_option_x_portfolio_launch_project_button_text', 'x_make_translatable', 999 ); add_filter('x_option_x_portfolio_share_project_title', 'x_make_translatable', 999 ); function x_make_translatable ( $string ) { return pll__( $string ); } add_action('init', 'x_invoke_translation', 99999 ); function x_invoke_translation () { pll_register_string('Vini', 'Wines'); /* register all your other strings here */ }
Then add or register your target strings within x_invoke_translation()
Let me know.
November 23, 2015 at 2:32 am #675648Hi, that seems to work actually! π
The “portfolio tag title” is now translated from Vini (IT) to Wines (EN)
– IT: http://www.vinodiretto.it/it/cantina/arpepe/
– EN: http://www.vinodiretto.it/en/cantina/arpepe/I’ve also added two lines on the .php file:
pll_register_string('Vai al Sito Internet ufficiale', 'Go to official website'); pll_register_string('Condividi', 'Social Sharing');
to have the “launch project btn text” and “share project title” translated:
but that seems not to work, even if the two fields are appearing on the plug-in settings:
(here’s also a screenshot from the Customizer for those fields)
Any idea why the other 2 lines are not being translated? Is there something wrong in the code I’ve added?
Thanks again for your precious help! Really appreciated! π
November 23, 2015 at 3:22 am #675689Hi,
No need to add those lines as those strings are readily translatable.
You can translate those text in your language file.
Thanks
November 23, 2015 at 3:55 am #675726Hi,
thanks for the quick reply.What do you mean exactly for “translate those text in your language file”? You mean with the Polylang plugin or with another plugin/file for translations? (I’m using quick-localization but that actually works without a language distinction)
As those 2 copy parts (“launch project btn text” and “share project title”) need to be translated according to the language in use (EN or IT), shouldn’t that be set up in the Polylang setting (translated strings), so following the same way we did for “portfolio tag title” above?
thx!
-
AuthorPosts