• Hello!

    I am currently setting up a website that has content in two languages: primary is German, secondary English. I am using Sublanguage to manage multilinguality, including setting up different permalinks, etc.

    However, when using ALM to display posts, they are always displayed in the primary language, no matter how often I switch to English and check if the URL actually contains /en/, which it does.
    Not only the post content remains in German but everything else too, including the template parts for which my theme provides translations (i.e. “read more” link text). Considering that, I figured that the problem most likely isn’t query related. It appears as if ALM doesn’t recognize the language variable or something like that.

    Sublanguage does support AJAX, as stated in the FAQ, but since my knowledge of AJAX is close to zero, the information provided doesn’t really help me..

    Do you have any idea how to fix this problem?

    Thanks!

    PS: I don’t know if this has anything to do with the above, but I also noticed that the_excerpt() produces a different output when used in my ALM repeater template than when in theme template files. While the latter show a “read more” link by themselves, the_excerpt() within the ALM repeater template only puts out “[…]” without a link at the end of the excerpt’s text.

    • This topic was modified 7 years, 10 months ago by 1name.
    • This topic was modified 7 years, 10 months ago by 1name.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Darren Cooney

    (@dcooney)

    Hi @1name,
    Sorry for the delay as I was away.

    ALM does not officially support sublanguage plugin so I’m not sure how to get it working.
    It does support Polylang and WPML.

    Do you know if there is documentation on how to use sublanguage with a custom WP Query?

    Cheers,

    Thread Starter 1name

    (@1name)

    Hi @dcooney,

    thanks for your reply!

    Unfortunately, I couldn’t find any info on how Sublanguage deals with custom queries. I don’t know what exactely to look for, maybe you’re more successful than I was browsing the plugin’s Git repo. It does say something about the case:

    If you need to access data through AJAX, you just need to add the wanted language slug into the ajax request […]

    but having no knowledge of JavaScript, I didn’t understand most of what came afterwards.

    I found quite a few discussions dealing with issues concerning ALM and Polylang or WPML, which mostly concluded with setting the lang parameter in the call to ajax-admin.php. I tried to play around with it a little but got no result – literally, nothing changed, no matter if it was set to en, en-US or en_US :/ I also tried setting it using the global $sublanguage variable, as proposed in the plugin’s readme. This one should also be available through JS

    However, if I changed the site’s language (from the admin panel’s settings) to English, so did the content loaded by ALM.

    If it is any help: I am currently testing the setup here. As you can see, the URL contains /en/ and menu and tab tags are loaded in English.

    get_bloginfo('language') shows the correct value. I am querying it to determine which widget shall be displayed.

    Thanks again for your reply and any further help you can provide 🙂

    Plugin Author Darren Cooney

    (@dcooney)

    I asked on the support forums… https://ww.wp.xz.cn/support/topic/wp_query-2/

    Ill try to add built in for this soon.

    You could also try using the <a href="https://connekthq.com/plugins/ajax-load-more/docs/filter-hooks/#alm_query_args" rel="noopener" target="_blank">alm_query_args</a> filter if you have development knowledge.

    Thread Starter 1name

    (@1name)

    Thanks for your reply, @dcooney!

    I tried to use the alm_query_args filter, but setting $args['lang'] = 'en' or $args['language'] = 'en' both didn’t change the output to English – not even after I added the code from the support forum thread you linked above to my child theme’s functions.php (if this is where this kind of code would go..)

    Furthermore, when inspecting using Firefox’ built-in function, the AJAX query’s argument for lang still appeared as empty, despite the new id argument showing up correctly. When I tried setting $args['language'] no language argument showed up in this view at all, the empty lang argument remained.

    HOWEVER!
    When I manipulate the AJAX query by myself and set an argument language=en, the JSON reply appears to be partly English: see here.
    The links to the single entries are now to the respective English versions (/en/ in URL), but article title and text, translated by Sublanguage, as well as the meta-labels, translated using __() are still in German.

    Any ideas? 😀

    Thanks a lot for your effort and interest!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Multilingual Content not working’ is closed to new replies.