Mastodonで任意の言語のトレンドを取得したい

セルフホストダッシュボードアプリのGlanceが先日v0.8.0がリリース.大型アップデートされました.

新機能の一つにCommunity widgetsがあります.これにより各種のJSONで帰ってくるコンテンツをカスタムウィジットとして表示できそうです.v0.8.0リリース時点ですでに40以上公開されています.
設定はglanceのyamlに書くだけです.

この中のMastodonのトレンドを表示するものがありました.

手元のウェブブラウザだと日本語のコンテンツが表示されるのにこのウィジットだと英語のものになります.
次のAPIを利用しているようです.getなんかでlang=jaのように指定できると便利そうですが言語選択はなさそうです.

curlで叩くと英語に.

$ curl -s https://mastodon.social/api/v1/trends/links | jq . | head
[
  {
    "url": "https://arstechnica.com/tech-policy/2025/05/meta-is-making-users-who-opted-out-of-ai-training-opt-out-again-watchdog-says/",
    "title": "Meta is making users who opted out of AI training opt out again, watchdog says",
    "description": "EU users have less than two weeks to opt out of Meta’s AI training.",
    "language": "en",
    "type": "link",
    "author_name": "Ashley Belanger",
    "author_url": "https://arstechnica.com/author/ashleybelanger/",
    "provider_name": "Ars Technica",

Accept-Language で ja を指定すると日本語に

$ curl -s -H 'Accept-Language: ja' https://mastodon.social/api/v1/trends/links | jq . | head
[
  {
    "url": "https://www.cnn.co.jp/fringe/35232941.html",
    "title": "長時間勤務で脳の構造が変化、認知や感情制御に影響も 韓国調査",
    "description": "長時間勤務が続くと脳の構造が変化して、認知機能や感情制御に影響を及ぼす恐れがあるという研究結果が、13日の医学誌に発表された。働き過ぎると身体的、精神的な無理が重なり、休養不足も加わって脳に
  重大な変化」が起きると指摘している。",
    "language": "ja",
    "type": "link",
    "author_name": "翻訳:CNN.co.jp編集部",
    "author_url": "",
    "provider_name": "CNN.co.jp",

Accept-Language で fr を指定するとフランス語になりました.

$ curl -s -H 'Accept-Language: fr' https://mastodon.social/api/v1/trends/links | jq . | head
[
  {
    "url": "https://www.huffingtonpost.fr/justice/article/la-justice-prend-une-decision-inedite-pour-une-personne-trans-en-france_250035.html",
    "title": "La justice prend une décision « inédite » pour une personne trans en France",
    "description": "Un homme trans, qui contestait en justice le refus de CPAM du Bas-Rhin de prendre en charge sa mastectomie, a obtenu gain de cause au tribunal de Strasbourg.",
    "language": "fr",
    "type": "link",
    "author_name": "Éva Craine",
    "author_url": "https://www.huffingtonpost.fr/author/eva-craine",
    "provider_name": "Le HuffPost",

ということでこのあたりを見て判断していそうです.Glance側で日本語を表示するには本体のsourceを修正しないといけなさそうです.

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

To respond on your own website, enter the URL of your response which should contain a link to this post's permalink URL. Your response will then appear (possibly after moderation) on this page. Want to update or remove your response? Update or delete your post and re-enter your post's URL again. (Find out more about Webmentions.)