Product attribute labels untranslated API
-
Hi,
I have a mobile app that uses WooCommerce Json Api to fetch translated entities.
Most endpoints work exactly as expected using query parameter “lang” to translate strings in the response.There is on endpoint that behaves differently, the Product Attributes API API docs
Below is an example request and response made with finnish (lang=fi) query parameter to fetch product attributes. The attribute terms and options are translated correctly (“Gluteeniton”), but the attribute label is always “Food Allergies”, when the translation is “Ruoka-allergiat”. On the web page
Example request:
/wp-json/wc/v3/products/attributes?lang=fiExample response:
[ 0: { id: 6 name: "Food Allergies" options: [ name: "Gluteeniton" taxonomy: "pa_food-allergies" ... ] ... } ]
Other info:
– The site uses “Language URL format” option “Different languages in directories” ({URL}/{language}/…).
– In the web store, all product attribute labels are properly translated, both as search filters and on product details.
– Another endpoint, the products JSON API, has the same issue where attribute label is not translated but options are.What I have tried that had no effect:
– Changing the “Language URL format” (prefix,suffix, query parameter) in WPML
– Hooking into “woocommerce_rest_prepare_product_attribute” filter
– Filter “wpml_translate_single_string” to manually translate the label
– Filter “wpml_object_id” on product attribute id
– Searching in database for the valuesI can find the translated values in the database, but I don’t exactly understand how the WC/WPML/WCML plugins are integrated.
My questions are currently:
1. Is the product attribute label translated by WooCommerce Multilingual in the JSON API, or is it restricted to product attribute terms/options only?
2. How could I go about finding the cause of this issue?
3. Could I manually translate the product attribute labels using the “woocommerce_rest_prepare_product_attribute” filter hook?Installation:
WordPress 5.8.3
PHP 7.3.33
WooCommerce 6.0.0
WooCommerce Multilingual 4.12.1
WPML Multilingual CMS 4.4.12
WPML String Translation 3.1.10
WPML Translation Management 2.10.8
(+ many other plugins)
- The topic ‘Product attribute labels untranslated API’ is closed to new replies.