diff --git a/CHANGELOG.md b/CHANGELOG.md index e134fc8..30cb13e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ### Changed -- "Time ago" strings are now localized +- "Time ago" strings, dates, and compact numbers are now localized ## v0.7.0 - 2021-11-04 diff --git a/lib/l10n/l10n.dart b/lib/l10n/l10n.dart index 709aadb..c74ca89 100644 --- a/lib/l10n/l10n.dart +++ b/lib/l10n/l10n.dart @@ -1,5 +1,7 @@ import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; import 'package:json_annotation/json_annotation.dart'; +import 'package:timeago/timeago.dart'; export 'gen/l10n.dart'; export 'l10n_api.dart'; @@ -76,3 +78,22 @@ extension LanguageName on Locale { /// returns the name of the language in the given language String get languageName => _languageNames[toLanguageTag()] ?? toLanguageTag(); } + +extension TimeagoTime on DateTime { + /// returns `this` time as a relative, human-readable string. In short format + String timeagoShort(BuildContext context) => format( + this, + locale: '${Localizations.localeOf(context).toLanguageTag()}_short', + ); + + /// returns `this` time as a relative, human-readable string + String timeago(BuildContext context) => + format(this, locale: Localizations.localeOf(context).toLanguageTag()); +} + +extension NumberFormatExtensions on num { + /// returns `this` as a formatted compact number + String compact(BuildContext context) => NumberFormat.compact( + locale: Localizations.localeOf(context).toLanguageTag(), + ).format(this); +} diff --git a/lib/l10n/untranslated.json b/lib/l10n/untranslated.json deleted file mode 100644 index 082a67a..0000000 --- a/lib/l10n/untranslated.json +++ /dev/null @@ -1,1773 +0,0 @@ -{ - "ar": [ - "couldnt_update_user", - "number_of_users_online", - "number_of_comments", - "number_of_posts", - "number_of_subscribers", - "number_of_users", - "bot_account", - "show_bot_accounts", - "show_read_posts" - ], - - "bg": [ - "bot_account", - "show_bot_accounts", - "show_read_posts" - ], - - "ca": [ - "bot_account", - "show_bot_accounts", - "show_read_posts" - ], - - "da": [ - "not_a_mod_or_admin", - "top_week", - "top_month", - "top_year", - "top_all", - "most_comments", - "new_comments", - "bot_account", - "show_bot_accounts", - "show_read_posts" - ], - - "de": [ - "not_a_mod_or_admin", - "report_reason_required", - "report_too_long", - "couldnt_create_report", - "couldnt_resolve_report", - "top_week", - "top_month", - "top_year", - "top_all", - "most_comments", - "new_comments", - "bot_account", - "show_bot_accounts", - "show_read_posts" - ], - - "el": [ - "bot_account", - "show_bot_accounts", - "show_read_posts" - ], - - "eo": [ - "bot_account", - "show_bot_accounts", - "show_read_posts" - ], - - "es": [ - "bot_account", - "show_bot_accounts", - "show_read_posts" - ], - - "eu": [ - "bot_account", - "show_bot_accounts", - "show_read_posts" - ], - - "fa": [ - "modlog", - "community", - "url", - "body", - "subscribed", - "local", - "from", - "to", - "more", - "banner", - "display_name", - "bio", - "matrix_user", - "saved", - "theme", - "old", - "by", - "not_a_mod_or_admin", - "invalid_url", - "couldnt_get_comments", - "report_reason_required", - "report_too_long", - "couldnt_create_report", - "couldnt_resolve_report", - "invalid_post_title", - "invalid_community_name", - "community_moderator_already_exists", - "community_follower_already_exists", - "not_a_moderator", - "community_user_already_banned", - "invalid_password", - "captcha_incorrect", - "invalid_username", - "bio_length_overflow", - "couldnt_update_private_message", - "couldnt_create_private_message", - "no_private_message_edit_allowed", - "post_title_too_long", - "number_of_subscribers", - "unsubscribe", - "subscribe", - "messages", - "banned_users", - "send_message", - "top_week", - "top_month", - "top_year", - "top_all", - "most_comments", - "new_comments", - "active", - "bot_account", - "show_bot_accounts", - "show_read_posts" - ], - - "fi": [ - "bot_account", - "show_bot_accounts", - "show_read_posts" - ], - - "fr": [ - "bot_account", - "show_bot_accounts", - "show_read_posts" - ], - - "ga": [ - "number_of_users_online", - "number_of_comments", - "number_of_posts", - "number_of_subscribers", - "number_of_users", - "bot_account", - "show_bot_accounts", - "show_read_posts" - ], - - "hi": [ - "password", - "email_or_username", - "modlog", - "url", - "title", - "body", - "nsfw", - "save", - "subscribed", - "local", - "all", - "replies", - "mentions", - "from", - "to", - "deleted_by_creator", - "mark_as_read", - "mark_as_unread", - "delete", - "restore", - "yes", - "no", - "banner", - "display_name", - "bio", - "email", - "matrix_user", - "sort_type", - "type", - "show_nsfw", - "send_notifications_to_email", - "delete_account", - "saved", - "theme", - "language", - "hot", - "new_", - "old", - "top", - "chat", - "by", - "not_a_mod_or_admin", - "not_an_admin", - "not_logged_in", - "site_ban", - "community_ban", - "downvotes_disabled", - "invalid_url", - "couldnt_like_comment", - "couldnt_update_comment", - "no_comment_edit_allowed", - "couldnt_save_comment", - "couldnt_get_comments", - "report_reason_required", - "report_too_long", - "couldnt_create_report", - "couldnt_resolve_report", - "invalid_post_title", - "couldnt_create_post", - "couldnt_like_post", - "couldnt_get_posts", - "no_post_edit_allowed", - "couldnt_save_post", - "site_already_exists", - "couldnt_update_site", - "invalid_community_name", - "community_moderator_already_exists", - "community_follower_already_exists", - "not_a_moderator", - "couldnt_update_community", - "no_community_edit_allowed", - "system_err_login", - "community_user_already_banned", - "couldnt_find_that_username_or_email", - "password_incorrect", - "registration_closed", - "invalid_password", - "passwords_dont_match", - "captcha_incorrect", - "invalid_username", - "bio_length_overflow", - "couldnt_update_user", - "couldnt_update_private_message", - "couldnt_update_post", - "couldnt_create_private_message", - "no_private_message_edit_allowed", - "post_title_too_long", - "email_already_exists", - "user_already_exists", - "number_of_users_online", - "number_of_subscribers", - "number_of_users", - "unsubscribe", - "subscribe", - "messages", - "banned_users", - "delete_account_confirm", - "new_password", - "verify_password", - "old_password", - "search", - "top_day", - "top_week", - "top_month", - "top_year", - "top_all", - "most_comments", - "new_comments", - "active", - "bot_account", - "show_bot_accounts", - "show_read_posts" - ], - - "hr": [ - "settings", - "password", - "email_or_username", - "posts", - "comments", - "modlog", - "community", - "url", - "title", - "body", - "nsfw", - "post", - "save", - "subscribed", - "local", - "all", - "replies", - "mentions", - "from", - "to", - "deleted_by_creator", - "more", - "mark_as_read", - "mark_as_unread", - "reply", - "edit", - "delete", - "restore", - "yes", - "no", - "avatar", - "banner", - "display_name", - "bio", - "email", - "matrix_user", - "sort_type", - "type", - "show_nsfw", - "send_notifications_to_email", - "delete_account", - "saved", - "communities", - "users", - "theme", - "language", - "hot", - "new_", - "old", - "top", - "chat", - "admin", - "by", - "not_a_mod_or_admin", - "not_an_admin", - "couldnt_find_post", - "not_logged_in", - "site_ban", - "community_ban", - "downvotes_disabled", - "invalid_url", - "locked", - "couldnt_create_comment", - "couldnt_like_comment", - "couldnt_update_comment", - "no_comment_edit_allowed", - "couldnt_save_comment", - "couldnt_get_comments", - "report_reason_required", - "report_too_long", - "couldnt_create_report", - "couldnt_resolve_report", - "invalid_post_title", - "couldnt_create_post", - "couldnt_like_post", - "couldnt_find_community", - "couldnt_get_posts", - "no_post_edit_allowed", - "couldnt_save_post", - "site_already_exists", - "couldnt_update_site", - "invalid_community_name", - "community_already_exists", - "community_moderator_already_exists", - "community_follower_already_exists", - "not_a_moderator", - "couldnt_update_community", - "no_community_edit_allowed", - "system_err_login", - "community_user_already_banned", - "couldnt_find_that_username_or_email", - "password_incorrect", - "registration_closed", - "invalid_password", - "passwords_dont_match", - "captcha_incorrect", - "invalid_username", - "bio_length_overflow", - "couldnt_update_user", - "couldnt_update_private_message", - "couldnt_update_post", - "couldnt_create_private_message", - "no_private_message_edit_allowed", - "post_title_too_long", - "email_already_exists", - "user_already_exists", - "number_of_users_online", - "number_of_comments", - "number_of_posts", - "number_of_subscribers", - "number_of_users", - "unsubscribe", - "subscribe", - "messages", - "banned_users", - "delete_account_confirm", - "new_password", - "verify_password", - "old_password", - "show_avatars", - "search", - "send_message", - "top_day", - "top_week", - "top_month", - "top_year", - "top_all", - "most_comments", - "new_comments", - "active", - "bot_account", - "show_bot_accounts", - "show_read_posts" - ], - - "hu": [ - "local", - "banner", - "display_name", - "bio", - "not_a_mod_or_admin", - "invalid_url", - "report_reason_required", - "report_too_long", - "couldnt_create_report", - "couldnt_resolve_report", - "invalid_post_title", - "not_a_moderator", - "invalid_password", - "captcha_incorrect", - "bio_length_overflow", - "top_week", - "top_month", - "top_year", - "top_all", - "most_comments", - "new_comments", - "active", - "bot_account", - "show_bot_accounts", - "show_read_posts" - ], - - "it": [ - "bot_account", - "show_bot_accounts", - "show_read_posts" - ], - - "ja": [ - "local", - "not_a_mod_or_admin", - "invalid_url", - "report_reason_required", - "report_too_long", - "couldnt_create_report", - "couldnt_resolve_report", - "invalid_post_title", - "not_a_moderator", - "invalid_password", - "captcha_incorrect", - "invalid_username", - "banned_users", - "top_week", - "top_month", - "top_year", - "top_all", - "most_comments", - "new_comments", - "bot_account", - "show_bot_accounts", - "show_read_posts" - ], - - "ka": [ - "local", - "banner", - "display_name", - "bio", - "not_a_mod_or_admin", - "invalid_url", - "report_reason_required", - "report_too_long", - "couldnt_create_report", - "couldnt_resolve_report", - "invalid_post_title", - "invalid_community_name", - "not_a_moderator", - "invalid_password", - "captcha_incorrect", - "invalid_username", - "bio_length_overflow", - "couldnt_update_private_message", - "couldnt_create_private_message", - "no_private_message_edit_allowed", - "top_week", - "top_month", - "top_year", - "top_all", - "most_comments", - "new_comments", - "active", - "bot_account", - "show_bot_accounts", - "show_read_posts" - ], - - "km": [ - "settings", - "password", - "email_or_username", - "posts", - "comments", - "modlog", - "community", - "url", - "title", - "body", - "nsfw", - "post", - "save", - "subscribed", - "local", - "all", - "replies", - "mentions", - "from", - "to", - "deleted_by_creator", - "more", - "mark_as_read", - "mark_as_unread", - "reply", - "edit", - "delete", - "restore", - "yes", - "no", - "avatar", - "banner", - "display_name", - "bio", - "email", - "matrix_user", - "sort_type", - "type", - "show_nsfw", - "send_notifications_to_email", - "delete_account", - "saved", - "communities", - "users", - "theme", - "language", - "hot", - "new_", - "old", - "top", - "chat", - "admin", - "by", - "not_a_mod_or_admin", - "not_an_admin", - "couldnt_find_post", - "not_logged_in", - "site_ban", - "community_ban", - "downvotes_disabled", - "invalid_url", - "locked", - "couldnt_create_comment", - "couldnt_like_comment", - "couldnt_update_comment", - "no_comment_edit_allowed", - "couldnt_save_comment", - "couldnt_get_comments", - "report_reason_required", - "report_too_long", - "couldnt_create_report", - "couldnt_resolve_report", - "invalid_post_title", - "couldnt_create_post", - "couldnt_like_post", - "couldnt_find_community", - "couldnt_get_posts", - "no_post_edit_allowed", - "couldnt_save_post", - "site_already_exists", - "couldnt_update_site", - "invalid_community_name", - "community_already_exists", - "community_moderator_already_exists", - "community_follower_already_exists", - "not_a_moderator", - "couldnt_update_community", - "no_community_edit_allowed", - "system_err_login", - "community_user_already_banned", - "couldnt_find_that_username_or_email", - "password_incorrect", - "registration_closed", - "invalid_password", - "passwords_dont_match", - "captcha_incorrect", - "invalid_username", - "bio_length_overflow", - "couldnt_update_user", - "couldnt_update_private_message", - "couldnt_update_post", - "couldnt_create_private_message", - "no_private_message_edit_allowed", - "post_title_too_long", - "email_already_exists", - "user_already_exists", - "number_of_users_online", - "number_of_comments", - "number_of_posts", - "number_of_subscribers", - "number_of_users", - "unsubscribe", - "subscribe", - "messages", - "banned_users", - "delete_account_confirm", - "new_password", - "verify_password", - "old_password", - "show_avatars", - "search", - "send_message", - "top_day", - "top_week", - "top_month", - "top_year", - "top_all", - "most_comments", - "new_comments", - "active", - "bot_account", - "show_bot_accounts", - "show_read_posts" - ], - - "ko": [ - "bot_account", - "show_bot_accounts", - "show_read_posts" - ], - - "nb": [ - "settings", - "password", - "email_or_username", - "posts", - "comments", - "modlog", - "community", - "url", - "title", - "body", - "nsfw", - "post", - "save", - "subscribed", - "local", - "all", - "replies", - "mentions", - "from", - "to", - "deleted_by_creator", - "more", - "mark_as_read", - "mark_as_unread", - "reply", - "edit", - "delete", - "restore", - "yes", - "no", - "avatar", - "banner", - "display_name", - "bio", - "email", - "matrix_user", - "sort_type", - "type", - "show_nsfw", - "send_notifications_to_email", - "delete_account", - "saved", - "communities", - "users", - "theme", - "language", - "hot", - "new_", - "old", - "top", - "chat", - "admin", - "by", - "not_a_mod_or_admin", - "not_an_admin", - "couldnt_find_post", - "not_logged_in", - "site_ban", - "community_ban", - "downvotes_disabled", - "invalid_url", - "locked", - "couldnt_create_comment", - "couldnt_like_comment", - "couldnt_update_comment", - "no_comment_edit_allowed", - "couldnt_save_comment", - "couldnt_get_comments", - "report_reason_required", - "report_too_long", - "couldnt_create_report", - "couldnt_resolve_report", - "invalid_post_title", - "couldnt_create_post", - "couldnt_like_post", - "couldnt_find_community", - "couldnt_get_posts", - "no_post_edit_allowed", - "couldnt_save_post", - "site_already_exists", - "couldnt_update_site", - "invalid_community_name", - "community_already_exists", - "community_moderator_already_exists", - "community_follower_already_exists", - "not_a_moderator", - "couldnt_update_community", - "no_community_edit_allowed", - "system_err_login", - "community_user_already_banned", - "couldnt_find_that_username_or_email", - "password_incorrect", - "registration_closed", - "invalid_password", - "passwords_dont_match", - "captcha_incorrect", - "invalid_username", - "bio_length_overflow", - "couldnt_update_user", - "couldnt_update_private_message", - "couldnt_update_post", - "couldnt_create_private_message", - "no_private_message_edit_allowed", - "post_title_too_long", - "email_already_exists", - "user_already_exists", - "number_of_users_online", - "number_of_comments", - "number_of_posts", - "number_of_subscribers", - "number_of_users", - "unsubscribe", - "subscribe", - "messages", - "banned_users", - "delete_account_confirm", - "new_password", - "verify_password", - "old_password", - "show_avatars", - "search", - "send_message", - "top_day", - "top_week", - "top_month", - "top_year", - "top_all", - "most_comments", - "new_comments", - "active", - "bot_account", - "show_bot_accounts", - "show_read_posts" - ], - - "nb_NO": [ - "settings", - "password", - "email_or_username", - "posts", - "modlog", - "community", - "url", - "title", - "body", - "nsfw", - "post", - "save", - "subscribed", - "local", - "all", - "replies", - "mentions", - "from", - "to", - "deleted_by_creator", - "mark_as_read", - "mark_as_unread", - "delete", - "restore", - "yes", - "no", - "display_name", - "bio", - "email", - "matrix_user", - "sort_type", - "type", - "show_nsfw", - "send_notifications_to_email", - "delete_account", - "saved", - "theme", - "language", - "hot", - "new_", - "old", - "top", - "chat", - "admin", - "by", - "not_a_mod_or_admin", - "not_an_admin", - "couldnt_find_post", - "not_logged_in", - "site_ban", - "community_ban", - "downvotes_disabled", - "invalid_url", - "locked", - "couldnt_create_comment", - "couldnt_like_comment", - "couldnt_update_comment", - "no_comment_edit_allowed", - "couldnt_save_comment", - "couldnt_get_comments", - "report_reason_required", - "report_too_long", - "couldnt_create_report", - "couldnt_resolve_report", - "invalid_post_title", - "couldnt_create_post", - "couldnt_like_post", - "couldnt_find_community", - "couldnt_get_posts", - "no_post_edit_allowed", - "couldnt_save_post", - "site_already_exists", - "couldnt_update_site", - "invalid_community_name", - "community_already_exists", - "community_moderator_already_exists", - "community_follower_already_exists", - "not_a_moderator", - "couldnt_update_community", - "no_community_edit_allowed", - "system_err_login", - "community_user_already_banned", - "couldnt_find_that_username_or_email", - "password_incorrect", - "registration_closed", - "invalid_password", - "passwords_dont_match", - "captcha_incorrect", - "invalid_username", - "bio_length_overflow", - "couldnt_update_user", - "couldnt_update_private_message", - "couldnt_update_post", - "couldnt_create_private_message", - "no_private_message_edit_allowed", - "post_title_too_long", - "email_already_exists", - "user_already_exists", - "number_of_users_online", - "number_of_posts", - "number_of_subscribers", - "number_of_users", - "unsubscribe", - "subscribe", - "messages", - "banned_users", - "delete_account_confirm", - "new_password", - "verify_password", - "old_password", - "search", - "top_day", - "top_week", - "top_month", - "top_year", - "top_all", - "most_comments", - "new_comments", - "active", - "show_read_posts" - ], - - "nl": [ - "bot_account", - "show_bot_accounts", - "show_read_posts" - ], - - "oc": [ - "settings", - "password", - "email_or_username", - "posts", - "comments", - "modlog", - "community", - "url", - "title", - "body", - "nsfw", - "post", - "save", - "subscribed", - "local", - "all", - "replies", - "mentions", - "from", - "to", - "deleted_by_creator", - "more", - "mark_as_read", - "mark_as_unread", - "reply", - "edit", - "delete", - "restore", - "yes", - "no", - "avatar", - "banner", - "display_name", - "bio", - "email", - "matrix_user", - "sort_type", - "type", - "show_nsfw", - "send_notifications_to_email", - "delete_account", - "saved", - "communities", - "users", - "theme", - "language", - "hot", - "new_", - "old", - "top", - "chat", - "admin", - "by", - "not_a_mod_or_admin", - "not_an_admin", - "couldnt_find_post", - "not_logged_in", - "site_ban", - "community_ban", - "downvotes_disabled", - "invalid_url", - "locked", - "couldnt_create_comment", - "couldnt_like_comment", - "couldnt_update_comment", - "no_comment_edit_allowed", - "couldnt_save_comment", - "couldnt_get_comments", - "report_reason_required", - "report_too_long", - "couldnt_create_report", - "couldnt_resolve_report", - "invalid_post_title", - "couldnt_create_post", - "couldnt_like_post", - "couldnt_find_community", - "couldnt_get_posts", - "no_post_edit_allowed", - "couldnt_save_post", - "site_already_exists", - "couldnt_update_site", - "invalid_community_name", - "community_already_exists", - "community_moderator_already_exists", - "community_follower_already_exists", - "not_a_moderator", - "couldnt_update_community", - "no_community_edit_allowed", - "system_err_login", - "community_user_already_banned", - "couldnt_find_that_username_or_email", - "password_incorrect", - "registration_closed", - "invalid_password", - "passwords_dont_match", - "captcha_incorrect", - "invalid_username", - "bio_length_overflow", - "couldnt_update_user", - "couldnt_update_private_message", - "couldnt_update_post", - "couldnt_create_private_message", - "no_private_message_edit_allowed", - "post_title_too_long", - "email_already_exists", - "user_already_exists", - "number_of_users_online", - "number_of_comments", - "number_of_posts", - "number_of_subscribers", - "number_of_users", - "unsubscribe", - "subscribe", - "messages", - "banned_users", - "delete_account_confirm", - "new_password", - "verify_password", - "old_password", - "show_avatars", - "search", - "send_message", - "top_day", - "top_week", - "top_month", - "top_year", - "top_all", - "most_comments", - "new_comments", - "active", - "bot_account", - "show_bot_accounts", - "show_read_posts" - ], - - "pl": [ - "not_a_mod_or_admin", - "number_of_users_online", - "number_of_comments", - "number_of_posts", - "number_of_subscribers", - "number_of_users", - "new_comments", - "bot_account", - "show_bot_accounts", - "show_read_posts" - ], - - "pt": [ - "settings", - "password", - "email_or_username", - "posts", - "comments", - "modlog", - "community", - "url", - "title", - "body", - "nsfw", - "post", - "save", - "subscribed", - "local", - "all", - "replies", - "mentions", - "from", - "to", - "deleted_by_creator", - "more", - "mark_as_read", - "mark_as_unread", - "reply", - "edit", - "delete", - "restore", - "yes", - "no", - "avatar", - "banner", - "display_name", - "bio", - "email", - "matrix_user", - "sort_type", - "type", - "show_nsfw", - "send_notifications_to_email", - "delete_account", - "saved", - "communities", - "users", - "theme", - "language", - "hot", - "new_", - "old", - "top", - "chat", - "admin", - "by", - "not_a_mod_or_admin", - "not_an_admin", - "couldnt_find_post", - "not_logged_in", - "site_ban", - "community_ban", - "downvotes_disabled", - "invalid_url", - "locked", - "couldnt_create_comment", - "couldnt_like_comment", - "couldnt_update_comment", - "no_comment_edit_allowed", - "couldnt_save_comment", - "couldnt_get_comments", - "report_reason_required", - "report_too_long", - "couldnt_create_report", - "couldnt_resolve_report", - "invalid_post_title", - "couldnt_create_post", - "couldnt_like_post", - "couldnt_find_community", - "couldnt_get_posts", - "no_post_edit_allowed", - "couldnt_save_post", - "site_already_exists", - "couldnt_update_site", - "invalid_community_name", - "community_already_exists", - "community_moderator_already_exists", - "community_follower_already_exists", - "not_a_moderator", - "couldnt_update_community", - "no_community_edit_allowed", - "system_err_login", - "community_user_already_banned", - "couldnt_find_that_username_or_email", - "password_incorrect", - "registration_closed", - "invalid_password", - "passwords_dont_match", - "captcha_incorrect", - "invalid_username", - "bio_length_overflow", - "couldnt_update_user", - "couldnt_update_private_message", - "couldnt_update_post", - "couldnt_create_private_message", - "no_private_message_edit_allowed", - "post_title_too_long", - "email_already_exists", - "user_already_exists", - "number_of_users_online", - "number_of_comments", - "number_of_posts", - "number_of_subscribers", - "number_of_users", - "unsubscribe", - "subscribe", - "messages", - "banned_users", - "delete_account_confirm", - "new_password", - "verify_password", - "old_password", - "show_avatars", - "search", - "send_message", - "top_day", - "top_week", - "top_month", - "top_year", - "top_all", - "most_comments", - "new_comments", - "active", - "bot_account", - "show_bot_accounts", - "show_read_posts" - ], - - "pt_BR": [ - "report_reason_required", - "report_too_long", - "couldnt_create_report", - "couldnt_resolve_report", - "top_all", - "bot_account", - "show_bot_accounts", - "show_read_posts" - ], - - "ru": [ - "number_of_users_online", - "number_of_comments", - "number_of_posts", - "number_of_subscribers", - "number_of_users", - "bot_account", - "show_bot_accounts", - "show_read_posts" - ], - - "sq": [ - "local", - "banner", - "display_name", - "bio", - "not_a_mod_or_admin", - "invalid_url", - "report_reason_required", - "report_too_long", - "couldnt_create_report", - "couldnt_resolve_report", - "invalid_post_title", - "not_a_moderator", - "invalid_password", - "captcha_incorrect", - "bio_length_overflow", - "top_week", - "top_month", - "top_year", - "top_all", - "most_comments", - "new_comments", - "active", - "bot_account", - "show_bot_accounts", - "show_read_posts" - ], - - "sr": [ - "settings", - "password", - "email_or_username", - "posts", - "comments", - "modlog", - "community", - "url", - "title", - "body", - "nsfw", - "post", - "save", - "subscribed", - "local", - "all", - "replies", - "mentions", - "from", - "to", - "deleted_by_creator", - "more", - "mark_as_read", - "mark_as_unread", - "reply", - "edit", - "delete", - "restore", - "yes", - "no", - "avatar", - "banner", - "display_name", - "bio", - "email", - "matrix_user", - "sort_type", - "type", - "show_nsfw", - "send_notifications_to_email", - "delete_account", - "saved", - "communities", - "users", - "theme", - "language", - "hot", - "new_", - "old", - "top", - "chat", - "admin", - "by", - "not_a_mod_or_admin", - "not_an_admin", - "couldnt_find_post", - "not_logged_in", - "site_ban", - "community_ban", - "downvotes_disabled", - "invalid_url", - "locked", - "couldnt_create_comment", - "couldnt_like_comment", - "couldnt_update_comment", - "no_comment_edit_allowed", - "couldnt_save_comment", - "couldnt_get_comments", - "report_reason_required", - "report_too_long", - "couldnt_create_report", - "couldnt_resolve_report", - "invalid_post_title", - "couldnt_create_post", - "couldnt_like_post", - "couldnt_find_community", - "couldnt_get_posts", - "no_post_edit_allowed", - "couldnt_save_post", - "site_already_exists", - "couldnt_update_site", - "invalid_community_name", - "community_already_exists", - "community_moderator_already_exists", - "community_follower_already_exists", - "not_a_moderator", - "couldnt_update_community", - "no_community_edit_allowed", - "system_err_login", - "community_user_already_banned", - "couldnt_find_that_username_or_email", - "password_incorrect", - "registration_closed", - "invalid_password", - "passwords_dont_match", - "captcha_incorrect", - "invalid_username", - "bio_length_overflow", - "couldnt_update_user", - "couldnt_update_private_message", - "couldnt_update_post", - "couldnt_create_private_message", - "no_private_message_edit_allowed", - "post_title_too_long", - "email_already_exists", - "user_already_exists", - "number_of_users_online", - "number_of_comments", - "number_of_posts", - "number_of_subscribers", - "number_of_users", - "unsubscribe", - "subscribe", - "messages", - "banned_users", - "delete_account_confirm", - "new_password", - "verify_password", - "old_password", - "show_avatars", - "search", - "send_message", - "top_day", - "top_week", - "top_month", - "top_year", - "top_all", - "most_comments", - "new_comments", - "active", - "bot_account", - "show_bot_accounts", - "show_read_posts" - ], - - "sr_Latn": [ - "settings", - "email_or_username", - "posts", - "comments", - "modlog", - "title", - "post", - "save", - "subscribed", - "local", - "all", - "replies", - "mentions", - "deleted_by_creator", - "more", - "mark_as_read", - "mark_as_unread", - "reply", - "edit", - "delete", - "restore", - "avatar", - "banner", - "display_name", - "bio", - "sort_type", - "type", - "delete_account", - "saved", - "communities", - "users", - "hot", - "new_", - "old", - "top", - "admin", - "not_a_mod_or_admin", - "not_an_admin", - "couldnt_find_post", - "not_logged_in", - "site_ban", - "community_ban", - "invalid_url", - "locked", - "couldnt_create_comment", - "couldnt_like_comment", - "couldnt_update_comment", - "no_comment_edit_allowed", - "couldnt_save_comment", - "couldnt_get_comments", - "report_reason_required", - "report_too_long", - "couldnt_create_report", - "couldnt_resolve_report", - "invalid_post_title", - "couldnt_create_post", - "couldnt_like_post", - "couldnt_find_community", - "couldnt_get_posts", - "no_post_edit_allowed", - "couldnt_save_post", - "site_already_exists", - "couldnt_update_site", - "invalid_community_name", - "community_already_exists", - "community_moderator_already_exists", - "community_follower_already_exists", - "not_a_moderator", - "couldnt_update_community", - "no_community_edit_allowed", - "system_err_login", - "community_user_already_banned", - "couldnt_find_that_username_or_email", - "password_incorrect", - "invalid_password", - "passwords_dont_match", - "captcha_incorrect", - "invalid_username", - "bio_length_overflow", - "couldnt_update_user", - "couldnt_update_private_message", - "couldnt_update_post", - "couldnt_create_private_message", - "no_private_message_edit_allowed", - "post_title_too_long", - "email_already_exists", - "user_already_exists", - "number_of_users_online", - "number_of_comments", - "number_of_posts", - "number_of_subscribers", - "number_of_users", - "unsubscribe", - "subscribe", - "messages", - "banned_users", - "delete_account_confirm", - "show_avatars", - "search", - "send_message", - "top_day", - "top_week", - "top_month", - "top_year", - "top_all", - "most_comments", - "new_comments", - "active", - "bot_account", - "show_bot_accounts", - "show_read_posts" - ], - - "sv": [ - "bot_account", - "show_bot_accounts", - "show_read_posts" - ], - - "th": [ - "modlog", - "community", - "url", - "title", - "body", - "nsfw", - "subscribed", - "local", - "deleted_by_creator", - "restore", - "banner", - "display_name", - "bio", - "matrix_user", - "sort_type", - "type", - "show_nsfw", - "send_notifications_to_email", - "theme", - "hot", - "top", - "admin", - "not_a_mod_or_admin", - "not_an_admin", - "couldnt_find_post", - "site_ban", - "community_ban", - "downvotes_disabled", - "invalid_url", - "locked", - "couldnt_create_comment", - "couldnt_like_comment", - "couldnt_update_comment", - "no_comment_edit_allowed", - "couldnt_save_comment", - "couldnt_get_comments", - "report_reason_required", - "report_too_long", - "couldnt_create_report", - "couldnt_resolve_report", - "invalid_post_title", - "couldnt_create_post", - "couldnt_like_post", - "couldnt_find_community", - "couldnt_get_posts", - "no_post_edit_allowed", - "site_already_exists", - "couldnt_update_site", - "community_already_exists", - "community_moderator_already_exists", - "community_follower_already_exists", - "not_a_moderator", - "couldnt_update_community", - "no_community_edit_allowed", - "system_err_login", - "community_user_already_banned", - "couldnt_find_that_username_or_email", - "invalid_password", - "captcha_incorrect", - "invalid_username", - "bio_length_overflow", - "couldnt_update_user", - "couldnt_update_private_message", - "couldnt_update_post", - "couldnt_create_private_message", - "no_private_message_edit_allowed", - "post_title_too_long", - "user_already_exists", - "number_of_users_online", - "number_of_subscribers", - "banned_users", - "delete_account_confirm", - "show_avatars", - "top_day", - "top_week", - "top_month", - "top_year", - "top_all", - "most_comments", - "new_comments", - "active", - "bot_account", - "show_bot_accounts", - "show_read_posts" - ], - - "tr": [ - "local", - "banner", - "display_name", - "bio", - "not_a_mod_or_admin", - "invalid_url", - "report_reason_required", - "report_too_long", - "couldnt_create_report", - "couldnt_resolve_report", - "invalid_post_title", - "not_a_moderator", - "invalid_password", - "captcha_incorrect", - "bio_length_overflow", - "top_week", - "top_month", - "top_year", - "top_all", - "most_comments", - "new_comments", - "active", - "bot_account", - "show_bot_accounts", - "show_read_posts" - ], - - "uk": [ - "local", - "banner", - "display_name", - "bio", - "not_a_mod_or_admin", - "invalid_url", - "report_reason_required", - "report_too_long", - "couldnt_create_report", - "couldnt_resolve_report", - "invalid_post_title", - "not_a_moderator", - "invalid_password", - "captcha_incorrect", - "bio_length_overflow", - "number_of_users_online", - "number_of_comments", - "number_of_posts", - "number_of_subscribers", - "number_of_users", - "top_week", - "top_month", - "top_year", - "top_all", - "most_comments", - "new_comments", - "active", - "bot_account", - "show_bot_accounts", - "show_read_posts" - ], - - "zh": [ - "bot_account", - "show_bot_accounts", - "show_read_posts" - ], - - "zh_Hant": [ - "settings", - "password", - "email_or_username", - "modlog", - "community", - "url", - "title", - "body", - "nsfw", - "save", - "subscribed", - "local", - "all", - "replies", - "mentions", - "from", - "to", - "deleted_by_creator", - "mark_as_read", - "mark_as_unread", - "delete", - "restore", - "yes", - "no", - "display_name", - "bio", - "email", - "matrix_user", - "sort_type", - "type", - "show_nsfw", - "send_notifications_to_email", - "delete_account", - "saved", - "theme", - "language", - "hot", - "new_", - "old", - "top", - "chat", - "admin", - "by", - "not_a_mod_or_admin", - "not_an_admin", - "couldnt_find_post", - "not_logged_in", - "site_ban", - "community_ban", - "downvotes_disabled", - "invalid_url", - "locked", - "couldnt_create_comment", - "couldnt_like_comment", - "couldnt_update_comment", - "no_comment_edit_allowed", - "couldnt_save_comment", - "couldnt_get_comments", - "report_reason_required", - "report_too_long", - "couldnt_create_report", - "couldnt_resolve_report", - "invalid_post_title", - "couldnt_create_post", - "couldnt_like_post", - "couldnt_find_community", - "couldnt_get_posts", - "no_post_edit_allowed", - "couldnt_save_post", - "site_already_exists", - "couldnt_update_site", - "community_already_exists", - "community_moderator_already_exists", - "community_follower_already_exists", - "not_a_moderator", - "couldnt_update_community", - "no_community_edit_allowed", - "system_err_login", - "community_user_already_banned", - "couldnt_find_that_username_or_email", - "password_incorrect", - "registration_closed", - "invalid_password", - "passwords_dont_match", - "captcha_incorrect", - "invalid_username", - "bio_length_overflow", - "couldnt_update_user", - "couldnt_update_private_message", - "couldnt_update_post", - "couldnt_create_private_message", - "no_private_message_edit_allowed", - "post_title_too_long", - "email_already_exists", - "user_already_exists", - "number_of_users_online", - "number_of_subscribers", - "number_of_users", - "unsubscribe", - "subscribe", - "messages", - "banned_users", - "delete_account_confirm", - "new_password", - "verify_password", - "old_password", - "search", - "top_day", - "top_week", - "top_month", - "top_year", - "top_all", - "most_comments", - "new_comments", - "active", - "show_read_posts" - ] -} diff --git a/lib/pages/community/community_about_tab.dart b/lib/pages/community/community_about_tab.dart index 40a3426..1e3e897 100644 --- a/lib/pages/community/community_about_tab.dart +++ b/lib/pages/community/community_about_tab.dart @@ -5,7 +5,6 @@ import '../../l10n/l10n.dart'; import '../../stores/accounts_store.dart'; import '../../util/extensions/spaced.dart'; import '../../util/goto.dart'; -import '../../util/intl.dart'; import '../../util/observer_consumers.dart'; import '../../widgets/bottom_safe.dart'; import '../../widgets/markdown_text.dart'; @@ -72,10 +71,10 @@ class CommmunityAboutTab extends StatelessWidget { .number_of_subscribers(community.counts.subscribers))), Chip( label: Text( - '${community.counts.posts} post${pluralS(community.counts.posts)}')), + '${community.counts.posts} post${community.counts.posts == 1 ? '' : 's'}')), Chip( label: Text( - '${community.counts.comments} comment${pluralS(community.counts.comments)}')), + '${community.counts.comments} comment${community.counts.comments == 1 ? '' : 's'}')), ].spaced(8), ), ), diff --git a/lib/pages/community/community_overview.dart b/lib/pages/community/community_overview.dart index 39d1d7c..c41e6b1 100644 --- a/lib/pages/community/community_overview.dart +++ b/lib/pages/community/community_overview.dart @@ -2,9 +2,9 @@ import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:lemmy_api_client/v3.dart'; +import '../../l10n/l10n.dart'; import '../../util/extensions/api.dart'; import '../../util/goto.dart'; -import '../../util/intl.dart'; import '../../widgets/avatar.dart'; import '../../widgets/cached_network_image.dart'; import '../../widgets/fullscreenable_image.dart'; @@ -124,11 +124,11 @@ class CommunityOverview extends StatelessWidget { const Spacer(), const Icon(Icons.people, size: 20), const SizedBox(width: 3), - Text(compactNumber(community.counts.subscribers)), + Text(community.counts.subscribers.compact(context)), const Spacer(flex: 4), const Icon(Icons.record_voice_over, size: 20), const SizedBox(width: 3), - Text(compactNumber(fullCommunityView.online)), + Text(fullCommunityView.online.compact(context)), const Spacer(), ], ), diff --git a/lib/pages/inbox.dart b/lib/pages/inbox.dart index c32c0fc..ddc946a 100644 --- a/lib/pages/inbox.dart +++ b/lib/pages/inbox.dart @@ -11,7 +11,6 @@ import '../hooks/stores.dart'; import '../l10n/l10n.dart'; import '../util/delayed_action.dart'; import '../util/extensions/api.dart'; -import '../util/extensions/datetime.dart'; import '../util/goto.dart'; import '../util/icons.dart'; import '../widgets/bottom_modal.dart'; diff --git a/lib/pages/modlog_page.dart b/lib/pages/modlog_page.dart index fea0079..34b0af9 100644 --- a/lib/pages/modlog_page.dart +++ b/lib/pages/modlog_page.dart @@ -3,8 +3,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:lemmy_api_client/v3.dart'; +import '../l10n/l10n.dart'; import '../util/extensions/api.dart'; -import '../util/extensions/datetime.dart'; import '../util/goto.dart'; import '../widgets/avatar.dart'; import '../widgets/bottom_safe.dart'; diff --git a/lib/util/extensions/datetime.dart b/lib/util/extensions/datetime.dart deleted file mode 100644 index 90157aa..0000000 --- a/lib/util/extensions/datetime.dart +++ /dev/null @@ -1,14 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:timeago/timeago.dart'; - -extension FancyTime on DateTime { - /// returns `this` time as a relative, human-readable string. In short format - String timeagoShort(BuildContext context) => format( - this, - locale: '${Localizations.localeOf(context).toLanguageTag()}_short', - ); - - /// returns `this` time as a relative, human-readable string - String timeago(BuildContext context) => - format(this, locale: Localizations.localeOf(context).toLanguageTag()); -} diff --git a/lib/util/intl.dart b/lib/util/intl.dart deleted file mode 100644 index f793d00..0000000 --- a/lib/util/intl.dart +++ /dev/null @@ -1,5 +0,0 @@ -import 'package:intl/intl.dart'; - -String pluralS(int howMany) => howMany == 1 ? '' : 's'; - -String compactNumber(int number) => NumberFormat.compact().format(number); diff --git a/lib/widgets/comment/comment.dart b/lib/widgets/comment/comment.dart index 2857182..4adb3a6 100644 --- a/lib/widgets/comment/comment.dart +++ b/lib/widgets/comment/comment.dart @@ -10,9 +10,7 @@ import '../../stores/config_store.dart'; import '../../util/async_store_listener.dart'; import '../../util/extensions/api.dart'; import '../../util/extensions/cake_day.dart'; -import '../../util/extensions/datetime.dart'; import '../../util/goto.dart'; -import '../../util/intl.dart'; import '../../util/observer_consumers.dart'; import '../../util/text_color.dart'; import '../avatar.dart'; @@ -266,9 +264,8 @@ class _CommentWidget extends StatelessWidget { ) else if (configStore.showScores) Text( - compactNumber( - store.comment.counts.score, - ), + store.comment.counts.score + .compact(context), ), if (configStore.showScores) const Text(' ยท ') diff --git a/lib/widgets/post/post_info_section.dart b/lib/widgets/post/post_info_section.dart index 75e3f3a..d652718 100644 --- a/lib/widgets/post/post_info_section.dart +++ b/lib/widgets/post/post_info_section.dart @@ -5,7 +5,6 @@ import 'package:flutter/material.dart'; import '../../l10n/l10n.dart'; import '../../pages/community/community.dart'; import '../../util/extensions/api.dart'; -import '../../util/extensions/datetime.dart'; import '../../util/goto.dart'; import '../../util/observer_consumers.dart'; import '../avatar.dart'; diff --git a/lib/widgets/post/post_voting.dart b/lib/widgets/post/post_voting.dart index 2b2db0f..b8f8725 100644 --- a/lib/widgets/post/post_voting.dart +++ b/lib/widgets/post/post_voting.dart @@ -4,8 +4,8 @@ import 'package:lemmy_api_client/v3.dart'; import '../../hooks/logged_in_action.dart'; import '../../hooks/stores.dart'; +import '../../l10n/l10n.dart'; import '../../stores/config_store.dart'; -import '../../util/intl.dart'; import '../../util/observer_consumers.dart'; import 'post_store.dart'; @@ -38,7 +38,7 @@ class PostVoting extends HookWidget { child: CircularProgressIndicator.adaptive(), ) else if (showScores) - Text(compactNumber(store.postView.counts.score)), + Text(store.postView.counts.score.compact(context)), IconButton( icon: Icon( Icons.arrow_downward, diff --git a/lib/widgets/user_profile.dart b/lib/widgets/user_profile.dart index 22ce003..6bbeddb 100644 --- a/lib/widgets/user_profile.dart +++ b/lib/widgets/user_profile.dart @@ -9,7 +9,6 @@ import '../l10n/l10n.dart'; import '../pages/manage_account.dart'; import '../util/extensions/api.dart'; import '../util/extensions/cake_day.dart'; -import '../util/extensions/datetime.dart'; import '../util/goto.dart'; import '../util/text_color.dart'; import 'avatar.dart'; @@ -290,8 +289,9 @@ class _UserOverview extends HookWidget { ), const SizedBox(width: 4), Text( - DateFormat('MMM dd, yyyy') - .format(userView.person.published), + DateFormat.yMMMMd( + Localizations.localeOf(context).toLanguageTag(), + ).format(userView.person.published), style: theme.textTheme.bodyText1, ), ],