• Resolved vkovalcik

    (@vkovalcik)


    [All in One SEO version 3.3.5]

    Hi, I might have encountered a problem in different processing of various properties of a Page. The “Description” (which shows as Schema:description in the webpage code) works differently than the Title or Keywords.

    I am using a localization plugin, which allows me to input texts like “[:en]English string[:cs]Czech string”. The correct one is chosen when a page is generated depending on the selected language. It works practically everywhere, including the Title and Keywords. But not in the Description, where the original string is just copied to the output.

    I.e. Title would output correctly “English string”, Keywords “English string” as well, but for Description there is “[:en]English string[:cs]Czech string” on the output.

    My guess is that during the processing of the Description there should be a call to function __(), which localizes the string, i.e.
    correctText = __(originalText);

    It seems that the other two are doing it already.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author arnaudbroes

    (@arnaudbroes)

    @vkovalcik which localization plugin are you using?

    Thread Starter vkovalcik

    (@vkovalcik)

    @arnaudbroes It is “qTranslate Plus” with my own tweaks. Pretty generic ones, no complex things. If you are interested, I can send you my version.

    It works pretty much everywhere – Gutenberg editor, various settings, plugins and All in One SEO plugin as well, except for that single “Description” property.

    Now I have noticed that the same description is used for meta:description, which works great (= is localized properly). There should be the same string in Schema:description, but it isn’t.

    I haven’t analyzed your code much, but it seems that the meta:description is using get_main_description() function from the aioseop_class.php, while the Schema:description is NOT using this function and neither get_post_description() or get_aioseop_description() (haven’t yet found where it gets the description from ?? ).

    • This reply was modified 4 years, 7 months ago by vkovalcik. Reason: Inserted two other methods I have explored
    Plugin Support Steve M

    (@wpsmort)

    @vkovalcik When I search the WordPress plugin repo for qTranslate Plus, that plugin was shutdown. Is this a plugin you purchased or a fork of the old qTranslate Plus plugin from before it was shutdown? If it’s still in the WordPress plugin repo then please provide the link.

    I tested with qTranslate X which looks to be the last of the qTranslate forks still around, and although that plugin hasn’t been updated in 4 years, it works fine with our Schema markup. It too uses that same format of [:en]English Text[:de]Deutsch Text[:] and the meta description is also shown in the Schema markup.

    I also tested with WPML and Polylang and both worked fine.

    Thread Starter vkovalcik

    (@vkovalcik)

    @wpsmort Thank you for the reply, I appreciate you put so much effort into this!

    You are right: The plugin I am using is old, but I made gradual changes, so it still works under newest WordPress. I believe the original plugin is qTranslate Plus before its shutdown.

    I found another fork called qTranslate XP with modification only a month old, but when disabling my plugin and activating this one, my website crashed… not unexpected, there seems to be some inconsistencies. So I am back to my version and I am exploring the AIOSP code.

    I am no expert, but currently I believe the problem is on AIOSP side, here is why:

    I found that the Schema:description is generated by the get_post_description() function in the graph-webpage.php (in all-in-one-seo-pack/inc/schema/graphs directory). It is getting the actual description by calling this:

    $post_description = get_post_meta( $post->ID, '_aioseop_description', true );

    There is no explicit localization at all, perhaps if some qTranslate/WPML plugin has hook to get_post_meta (but that might be too dangerous as it could overwrite it i cases you don’t want to). Anyway the same description is ALSO retrieved in a different part of AIOSP code – in aioseop_class.php, but this time the call is:

    $description = trim( $this->internationalize( get_post_meta( $post->ID, '_aioseop_description', true ) ) );

    That seems really weird, it is obviously explicitly localized in one spot and not localized in another. The internationalize() function seems to be not easily accessible in the first spot, so I put __() there instead which fixed the issue. Hence my quick and dirty fix of the code is:

    $post_description = __(get_post_meta( $post->ID, '_aioseop_description', true ));

    This fixes the original issue.

    I also found that a similar issue is in the Schema:breadcrumbs:name(s). There can be similar fix in graph-breadcrumbs.php, line 63 changed from

    'name' => $list_item['name'],

    to

    'name' => __($list_item['name']),

    Plugin Support Steve M

    (@wpsmort)

    @vkovalcik Thanks for the detailed information on this. I had our dev team look this over and they’ve opened an issue in Github so we can fix it in the next minor release.

    Thread Starter vkovalcik

    (@vkovalcik)

    @wpsmort Sorry to report, but the fixes doesn’t seem to resolve the original issue. I am testing 3.4.3 now and I see a lot of changes, however both the description and the breadcrumbs are still untouched by the translation.

    I can use the same quick&dirty fix for breadcrumbs as described above. For the description I now moved the usage of the __() function, so I changed the method AIOSEOP_Graph_WebPage::prepare() (in graph-webpage.php), specifically changing the line

    $current_desc = $context->get_description();

    to

    $current_desc = __($context->get_description());

    did the trick. I am sure this is not a proper way to do it, but it gets the string to be translated.

    • This reply was modified 4 years, 6 months ago by vkovalcik.
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Possible translation bug in Schema “description” property’ is closed to new replies.