Support Forum
Hi,
I have this in a view:
{% set group = attribute( site, 'site-configuration' ) %}
{{ group.site_settings_texts_more_itineraries }}
The site is using WPML and the setting (a text field) is translated via string translations. It is displayed fine for English but remains empty for German.
How do I get it to display the German value?
Hi Arno,
The translation text displays as well on my demo site, here is the screen record https://monosnap.com/file/dqnBAr28wdYPOqXVamzAQdjm64IV9x
Hi Long,
Thanks, good to see that this should work. You only have one view, right? It's not duplicated for each language?
Is there any other setting I need to check? Somehow I don't get the value in the secondary language, only in the default language.
Follow up: I've done a few additional tests.
The normal way to display a setting in a view works fine in English but not in German (no value is displayed):
{% set group = attribute( site, 'site-configuration' ) %}
{{ group.site_settings_texts_more_itineraries }}
I can see that the text value of the 'site_settings_texts_more_itineraries' field is stored in the database table wp_options, in the record with option_name = 'site-configuration'. So, I tried to get the value through the WordPress get_option function (https://developer.wordpress.org/reference/functions/get_option/):
{% set atext = mb.get_option('site_settings_texts_more_itineraries') %}
{{atext}}
Even for English, this does return a value. I would expect a standard function to access this data to work.
So far, I could only fine one work around: using WPML, I can duplicate the view for German, give it a slug with the "-de" suffix, and then use a hardcoded string instead of the setting value.
Do you have any suggestions, or would you like to take a look into a copy of the website?
Thanks!
Hi,
Please share your site credentials via this contact form https://metabox.io/contact/
I will take a closer look.
Hi Long,
Thanks, I will e-mail you.
By the way, in my last post I meant to write "Even for English, this does NOT return a value".
Can you get me an update of the status? Many thanks!
Hi,
I'm not quite sure why the translation text does not display in the German language if I use MB Views on your site. If I use the WordPress function get_option()
and output the field value on a template file, the translation text display as well.
$site_options = get_option( 'site-configuration' );
echo $site_options['site_settings_texts_more_itineraries'];
Maybe there is an issue with the WPML settings on your site. If you don't mind, please use the PHP function as I tried.
Hi Long,
Thanks a lot, the work around works in my view as well. That allows us to continue the project.
A couple of questions please:
1) Is there documentation about how to use MB Views with WPML?
2) What are the recommended translation settings? I now have Field Groups (meta-box) set to Translatable. Also, Views (mb-views) is set to Translatable. Is that correct?
3) Can you try and get this fully solved, so I can eventually use the normal (and shorter) Meta Box syntax to display the translated settings? I can give you a full copy of the project for local debugging. Meanwhile, I will use the work around.
4) The work around works fine for Text fields, but not for a field of the type URL: it only returns the English value but not the German value. I don't understand why. The URL field basically is a Text field, right?
5) I tried creating a German version of the Setting Page. That seemed to help: all settings were now available in both languages. But if I changed one in German, it also changed in English!
I need your input here. Translating fields in MB Settings Pages seems quite difficult.
Hi,
1, 2, 3. I've not tested fully WPML and MB Views, Field Group (meta box) but I think it does not work like post, or CPT to display content on the front end. Currently, there isn't an integration between MB extensions and WPML. It's very hard to investigate the issue in a few days from our end only. You can also need some help from WPML support to translate the settings page (like theme options).
4. Yes, it works like a text field.
5. I think the issue relates to the default language of the site when setting up with WPML.
Hi Long,
Alright, we'll proceed with setting fields of the type Text instead of URL, translate them through WPML string translation, and read them through get_option as you explained. That's a work around that seems to be fine.
From pages like this: https://wpml.org/plugin/meta-box/ and this: https://docs.metabox.io/compatibility/, I was under the impression that WPML is fully supported for all of the Meta Box products. But if I understand you correctly, only the free Meta Box plugin for custom fields is fully supported. I purchased the full license for all extensions, but not all of that works.
Please do work on full support for WPML. It's essential for many websites.
My offer to give you a full site backup still stands. That gives you a way to see what's going wrong. It must be little things, as a lot works fine, but not everything.
Hi Long,
Unfortunately I found an issue, even when using get_option. I have switched the field type to Text to keep things as simple as possible. But still, some fields return the translated value, while others return the English value. Both fields are Text, and translated.
Can I e-mail you a login? I have very simple test view you can take a look at.
Hi Arno,
Yes, you can share the admin site account again and some screenshots of the issue.