Open BenceSzalai opened 3 years ago
Taken from #949:
Thank you for looking at this. I must admit i never cared about that filter option mode, i've always used the default. The related code comes from the qtranxf_filter_options
function:
I have never looked at the performance of this. Perhaps it could be improved by refining a bit the WHERE query, or maybe building some index. I performance were really an issue it would be nice to find a solution that is maybe more generic.
To be honest I've not seen any performance issues. I've just read the explanation for the setting and thought to myself, it's best to turn this off, because the description itself suggested to do so.
Speculating that some plugins may store quite huge objects and arrays serialised in wp_options
I can imagine applying translation to all of them may cause slowdowns.
If i18n-config.json
would provide a way to define the options to be filtered, that would be a good step to move away from relying on the global options filtering, as then all integrations could define the options they need to get filtered.
Split from #949.
Apparently some translations are not working, when 'Filter all WordPress options for translation at front-end' is disabled under Advanced. Since the explanatory text on the Advanced tab says “...this may cause a considerable performance degradation...” it is to be expected that users may turn off this option, so modules should be prepared to continue working even in that case.
These "missing" translations can be fixed by either applying additional filters or by including additional options to be translated. So generally speaking Modules should be able to detect if 'Filter all WordPress options for translation at front-end' is disabled, and load additional filters and include additional options to be translated. (Should probably be another issue, but this may be already possible with some PHP if-s and so.)
For the WooCommerce module one of the option wildcards required is:
woocommerce_%_settings
- responsible for the translation of text related to shipping methods. While these are translated fine when they appear in the frontend, these text are also included in the default email templates and there they appear as raw, untranslated text. Also I couldn't find any usable filters for these, so the only way to get this working is to include these options in ranslation. Each shipping method is stored in the options table aswoocommerce_{shipping_class_slug}_{shipping_method_id}_settings
, e.g.:woocommerce_flat_rate_1_settings
orwoocommerce_free_shipping_3_settings
etc. as json, which include title and description.Some filters that are also required to make sure the emails are sent fully translated are:
Please note that
woocommerce_gateway_title
is included in theqwc-front.php
config of the WC module, but is most likely not loaded when the emails are being sent. (To be checked.) My assumption is that$url_info['doing_front_end']
is false inqwc_init_language()
, so the wholeqwc-front.php
may not be loaded, when WooCommerce is processing the submitted order and sending the emails. However adding the above filters toi18n-config.json
works fine for the emails.