GNU social JP
  • FAQ
  • Login
GNU social JPは日本のGNU socialサーバーです。
Usage/ToS/admin/test/Pleroma FE
  • Public

    • Public
    • Network
    • Groups
    • Featured
    • Popular
    • People

Embed Notice

HTML Code

Corresponding Notice

  1. Embed this notice
    Jeremy Herve (jeremy@herve.bzh)'s status on Thursday, 10-Oct-2024 00:07:44 JSTJeremy HerveJeremy Herve

    Quick tip if you use the ActivityPub plugin on your WordPress site, and if you write in multiple languages on your site. Use the activitypub_post_locale filter to make sure your posts on the Fediverse are set to the locale matching the post on your site.

    /** * Set a post's language in its ActivityPub representation * based on post tags. * The post tags must match an array of language codes you use on your site (in my example, English, Hungarian, and French). * When no tags are found, the post's language uses the default (the blog's language). * * @param string $lang The locale of the post. * @param int $post_id The post ID. * @param WP_Post $post The post object. * * @return string The filtered locale of the post. */function jeherve_custom_ap_language( $lang, $post_id, $post ) {// Get the post's hashtags.$post_tags = get_the_tags( $post_id );if ( ! empty( $post_tags ) ) {// Is there a "en, "hu", or "fr" tag?foreach ( $post_tags as $tag ) {if ( in_array( $tag->slug, array( 'en', 'fr', 'hu' ), true ) ) {$lang = $tag->slug;break;}}}return $lang;}add_filter( 'activitypub_post_locale', 'jeherve_custom_ap_language', 10, 3 );

    This way, I can add the #en tag to this post, and ensure the post will be shown as an English-language post for folks on the Fediverse.

    This is important for folks who filter posts per language on the Fediverse, or who use translation tools to automatically translate posts in foreign languages.

    #ActivityPub #EN #WordPress

    In conversationabout 7 months ago from herve.bzhpermalink
  • Help
  • About
  • FAQ
  • TOS
  • Privacy
  • Source
  • Version
  • Contact

GNU social JP is a social network, courtesy of GNU social JP管理人. It runs on GNU social, version 2.0.2-dev, available under the GNU Affero General Public License.

Creative Commons Attribution 3.0 All GNU social JP content and data are available under the Creative Commons Attribution 3.0 license.