about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorChristian Schmidt <github@chsc.dk>2023-02-24 20:04:38 +0100
committerGitHub <noreply@github.com>2023-02-24 20:04:38 +0100
commit8000a8f2309d428c2ce72fe5ffba940754d55339 (patch)
treea783169411a449b2c9b3dcb07345e0c4f4ab69fa /app
parent19614ba2477f3d12468f5ec251ce1cc5f8c6210c (diff)
Add `lang` attribute to preview card (#23869)
Diffstat (limited to 'app')
-rw-r--r--app/javascript/mastodon/features/status/components/card.jsx3
-rw-r--r--app/serializers/rest/preview_card_serializer.rb2
2 files changed, 3 insertions, 2 deletions
diff --git a/app/javascript/mastodon/features/status/components/card.jsx b/app/javascript/mastodon/features/status/components/card.jsx
index 34fac1010..b588c83e4 100644
--- a/app/javascript/mastodon/features/status/components/card.jsx
+++ b/app/javascript/mastodon/features/status/components/card.jsx
@@ -196,11 +196,12 @@ export default class Card extends React.PureComponent {
     const interactive = card.get('type') !== 'link';
     const className   = classnames('status-card', { horizontal, compact, interactive });
     const title       = interactive ? <a className='status-card__title' href={card.get('url')} title={card.get('title')} rel='noopener noreferrer' target='_blank'><strong>{card.get('title')}</strong></a> : <strong className='status-card__title' title={card.get('title')}>{card.get('title')}</strong>;
+    const language    = card.get('language') || '';
     const ratio       = card.get('width') / card.get('height');
     const height      = (compact && !embedded) ? (width / (16 / 9)) : (width / ratio);
 
     const description = (
-      <div className='status-card__content'>
+      <div className='status-card__content' lang={language}>
         {title}
         {!(horizontal || compact) && <p className='status-card__description'>{trim(card.get('description') || '', maxDescription)}</p>}
         <span className='status-card__host'>{provider}</span>
diff --git a/app/serializers/rest/preview_card_serializer.rb b/app/serializers/rest/preview_card_serializer.rb
index 66ff47d22..8413b23d8 100644
--- a/app/serializers/rest/preview_card_serializer.rb
+++ b/app/serializers/rest/preview_card_serializer.rb
@@ -3,7 +3,7 @@
 class REST::PreviewCardSerializer < ActiveModel::Serializer
   include RoutingHelper
 
-  attributes :url, :title, :description, :type,
+  attributes :url, :title, :description, :language, :type,
              :author_name, :author_url, :provider_name,
              :provider_url, :html, :width, :height,
              :image, :embed_url, :blurhash