Skip to content

Commit

Permalink
handle language tagging
Browse files Browse the repository at this point in the history
  • Loading branch information
videah committed Jan 16, 2024
1 parent 5b9a6e8 commit ecf15c1
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 89 deletions.
4 changes: 4 additions & 0 deletions lib/models/forms/new_post_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class NewPostForm {
required this.status,
required this.mediaIds,
required this.inReplyToId,
required this.language,
});

/// Converts JSON into a [NewPostForm] instance.
Expand All @@ -33,6 +34,9 @@ class NewPostForm {
/// The ID of the post being replied to.
@JsonKey(name: 'in_reply_to_id', fromJson: handleReplyId)
final int? inReplyToId;

/// ISO 639 language code for this post.
final String? language;
}

BlueskyText stringToBluesky(String? value) =>
Expand Down
2 changes: 2 additions & 0 deletions lib/models/forms/new_post_form.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions lib/models/mastodon/mastodon_post.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class MastodonPost {
var repostCount = post.repostCount;
var replyCount = post.replyCount;
final mediaAttachments = <MastodonMediaAttachment>[];
String? language = 'en';
String? language = post.record.langs?.first ?? 'en';

// Handle embedded content.
final embed = post.embed;
Expand Down Expand Up @@ -273,7 +273,7 @@ class MastodonPost {
sensitive: false,
spoilerText: '',
visibility: PostVisibility.public,
language: 'en',
language: post.record.langs?.first ?? 'en',
uri: url,
url: url,
repliesCount: post.replyCount,
Expand Down
Loading

0 comments on commit ecf15c1

Please sign in to comment.