Skip Navigation

[Resolved] Question about WPML and Toolset

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 1 reply, has 1 voice.

Last updated by shannonM-4 18 hours, 38 minutes ago.

Assisted by: Minesh.

Author
Posts
#2863206

Hi there,

I am creating a website with two languages, English (primary) and Spanish (secondary). I've installed and configured WPML to handle the multilingual aspect of the site. (I'm aware Toolset and WPML are owned by the same parent company.) Here are two questions related to translating taxonomies:

+ When displaying a Toolset view with taxonomy terms, will WordPress/WPML automatically know to display the correct language that a visitor has chosen? For example, if a visitor has chosen Spanish and they view a webpage with the taxonomy terms, I would like the terms to be in Spanish (not English).

+ Using custom PHP, how do I display a taxonomy's terms in the correct language? I think I need to use the wpml_current_language function (https://wpml.org/wpml-hook/wpml_current_language/), but how would I retrieve the translated terms? For example, if a visitor has chosen Spanish and they view a webpage with the taxonomy terms, I would like the terms to be in Spanish (not English).

Thank you.

Saul

#2863263

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

+ When displaying a Toolset view with taxonomy terms, will WordPress/WPML automatically know to display the correct language that a visitor has chosen? For example, if a visitor has chosen Spanish and they view a webpage with the taxonomy terms, I would like the terms to be in Spanish (not English).
====>
Yes - that's correct.

+ Using custom PHP, how do I display a taxonomy's terms in the correct language? I think I need to use the wpml_current_language function (https://wpml.org/wpml-hook/wpml_current_language/), but how would I retrieve the translated terms? For example, if a visitor has chosen Spanish and they view a webpage with the taxonomy terms, I would like the terms to be in Spanish (not English).
====>
If you're working with a term ID and need to ensure you get the translation:

$current_language = apply_filters( 'wpml_current_language', null );

$translated_term_id = apply_filters(
    'wpml_object_id',
    $term_id,
    'your_taxonomy',
    true,
    $current_language
);

$term = get_term( $translated_term_id, 'your_taxonomy' );

echo $term->name;

Example:

$current_language = apply_filters( 'wpml_current_language', null );

$translated_term_id = apply_filters(
    'wpml_object_id',
    123,
    'project_country',
    true,
    $current_language
);

$term = get_term( $translated_term_id, 'project_country' );

Please check the followingg related ticket that may help you as well:
- https://wpml.org/forums/topic/when-a-taxonomy-is-attached-to-a-post-in-a-non-default-language-the-taxonomy-of-the-default-langua/

Please check the following Docs:
- https://toolset.com/course-lesson/how-to-prepare-the-site-to-run-multilingual/
- https://toolset.com/course-chapter/translating-business-sites/
- https://toolset.com/course-chapter/translating-membership-sites/

#2863318

Thanks, Minesh! This is exactly what I needed. And I'll review the other documentation you referenced, too.

Saul