Allow for more custom migration

This commit is contained in:
shilangyu 2021-03-02 22:12:08 +01:00
parent 83c12a817c
commit d5f1d45b06
25 changed files with 283 additions and 180 deletions

View File

@ -11,7 +11,7 @@
"title": "Títol",
"body": "Cos",
"nsfw": "Per a adults",
"post": "Publicar",
"post": "publicar",
"save": "desa",
"send_message": "Envia el missatge",
"subscribed": "Subscrit",
@ -95,5 +95,18 @@
"post_title_too_long": "El títol de lapunt és massa llarg.",
"email_already_exists": "Ladreça ja és en ús.",
"user_already_exists": "Lusuari ja existeix.",
"number_users_online": "{count,plural, =1{{count} usuari en línia} other{{count} usuaris en línia}}"
"number_users_online": "{count,plural, =1{{count} usuari en línia} other{{count} usuaris en línia}}",
"bio": "Biografia",
"invalid_url": "URL invàlida.",
"report_reason_required": "Motiu de l'informe necessari.",
"report_too_long": "Informe massa llarg.",
"couldnt_create_report": "No s'ha pogut crear l'informe.",
"couldnt_resolve_report": "No s'ha pogut resoldre l'informe.",
"invalid_post_title": "Títol de la publicació invàlid",
"not_a_moderator": "No ets un moderador.",
"invalid_password": "Contrasenya no vàlida. La contrasenya ha de tenir <= 60 caràcters.",
"captcha_incorrect": "Captcha incorrecte.",
"bio_length_overflow": "La biografia d'usuari no pot excedir els 300 caràcters.",
"number_of_comments": "{count,plural, =1{{count} comentari} other{{count} comentaris}}",
"number_of_posts": "{count,plural, =1{{count} Publicació} other{{count} Publicacions}}"
}

View File

@ -106,5 +106,7 @@
"post_title_too_long": "Indlægstitel for lang.",
"email_already_exists": "Emailen findes allerede.",
"user_already_exists": "Brugeren findes allerede.",
"number_users_online": "{count,plural, =1{{count} Bruger Online} other{{count} Brugere Online}}"
"number_users_online": "{count,plural, =1{{count} Bruger Online} other{{count} Brugere Online}}",
"number_of_comments": "{count,plural, =1{{count} Kommentar} other{{count} Kommentarer}}",
"number_of_posts": "{count,plural, =1{{count} Indlæg} other{{count} Indlæg}}"
}

View File

@ -102,5 +102,7 @@
"post_title_too_long": "Posttitel zu lang.",
"email_already_exists": "Email existiert bereits.",
"user_already_exists": "Nutzer existiert bereits.",
"number_users_online": "{count,plural, =1{{count} Benutzer online} other{{count} Benutzer*innen online}}"
"number_users_online": "{count,plural, =1{{count} Benutzer online} other{{count} Benutzer*innen online}}",
"number_of_comments": "{count,plural, =1{{count} Kommentar} other{{count} Kommentare}}",
"number_of_posts": "{count,plural, =1{{count} Beitrag} other{{count} Beiträge}}"
}

View File

@ -106,5 +106,7 @@
"post_title_too_long": "Η επικεφαλίδα της δημοσίευσης είναι υπερβολικά μεγάλη.",
"email_already_exists": "Η διεύθυνση ηλεκτρονικού ταχυδρομείου υπάρχει ήδη.",
"user_already_exists": "Ο χρήστης υπάρχει ήδη.",
"number_users_online": "{count,plural, =1{{count} ενεργός χρήστης} other{{count} ενεργοί χρήστες}}"
"number_users_online": "{count,plural, =1{{count} ενεργός χρήστης} other{{count} ενεργοί χρήστες}}",
"number_of_comments": "{count,plural, =1{{count} Σχόλιο} other{{count} Σχόλια}}",
"number_of_posts": "{count,plural, =1{{count} Δημοσίευση} other{{count} Δημοσιεύσεις}}"
}

View File

@ -229,7 +229,29 @@
"number_users_online": "{count,plural, =1{{count} user online} other{{count} users online}}",
"@number_users_online": {
"placeholders": {
"count": {}
"count": {
"type": "int"
}
}
},
"not_a_mod_or_admin": "Not a moderator or admin.",
"@not_a_mod_or_admin": {},
"number_of_comments": "{count,plural, =1{{count} Comment} other{{count} Comments}}",
"@number_of_comments": {
"placeholders": {
"count": {
"type": "int",
"format": "compact"
}
}
},
"number_of_posts": "{count,plural, =1{{count} Post} other{{count} Posts}}",
"@number_of_posts": {
"placeholders": {
"count": {
"type": "int",
"format": "compact"
}
}
}
}

View File

@ -106,5 +106,7 @@
"post_title_too_long": "Titolo de afiŝo estas tro longa.",
"email_already_exists": "Retpoŝtadreso jam ekzistas.",
"user_already_exists": "Uzanto jam ekzistas.",
"number_users_online": "{count,plural, =1{{count} uzanto enreta} other{{count} uzantoj enretaj}}"
"number_users_online": "{count,plural, =1{{count} uzanto enreta} other{{count} uzantoj enretaj}}",
"number_of_comments": "{count,plural, =1{{count} komento} other{{count} komentoj}}",
"number_of_posts": "{count,plural, =1{{count} afiŝo} other{{count} afiŝoj}}"
}

View File

@ -106,5 +106,7 @@
"post_title_too_long": "El título de la publicación es muy largo.",
"email_already_exists": "El correo ya está en uso.",
"user_already_exists": "El usuario ya existe.",
"number_users_online": "{count,plural, =1{{count} usuario en línea} other{{count} usuarios en línea}}"
"number_users_online": "{count,plural, =1{{count} usuario en línea} other{{count} usuarios en línea}}",
"number_of_comments": "{count,plural, =1{{count} Comentario} other{{count} Comentarios}}",
"number_of_posts": "{count,plural, =1{{count} Publicación} other{{count} Publicaciones}}"
}

View File

@ -106,5 +106,7 @@
"post_title_too_long": "Bidalketaren izenburua luzeegia da.",
"email_already_exists": "Eposta hori dagoeneko existitzen da.",
"user_already_exists": "Erabiltzaile hori dagoeneko existitzen da.",
"number_users_online": "{count,plural, =1{Erabiltzaile {count} konektatuta} other{{count} erabiltzaile konektatuta}}"
"number_users_online": "{count,plural, =1{Erabiltzaile {count} konektatuta} other{{count} erabiltzaile konektatuta}}",
"number_of_comments": "{count,plural, =1{Iruzkin {count}} other{{count} iruzkin}}",
"number_of_posts": "{count,plural, =1{Bidalketa {count}} other{{count} bidalketa}}"
}

View File

@ -68,5 +68,7 @@
"couldnt_update_post": "ناتوای در به‌روزرسانی مطلب",
"email_already_exists": "این رایانامه از قبل وجود دارد.",
"user_already_exists": "این کاربر از قبل وجود دارد.",
"number_users_online": "{count,plural, =1{{count} کاربر برخط}}"
"number_users_online": "{count,plural, =1{{count} کاربر برخط}}",
"number_of_comments": "{count,plural, =1{{count} نظر}}",
"number_of_posts": "{count,plural, =1{{count} مطلب}}"
}

View File

@ -91,5 +91,7 @@
"post_title_too_long": "Viestin otsikko on liian pitkä.",
"email_already_exists": "Sähköposti on jo olemassa.",
"user_already_exists": "Käyttäjä on jo olemassa.",
"number_users_online": "{count,plural, =1{{count} käyttäjä aktiivisena} other{{count} käyttäjää aktiivisena}}"
"number_users_online": "{count,plural, =1{{count} käyttäjä aktiivisena} other{{count} käyttäjää aktiivisena}}",
"number_of_comments": "{count,plural, =1{{count} kommentti} other{{count} kommenttia}}",
"number_of_posts": "{count,plural, =1{{count} viesti} other{{count} viestiä}}"
}

View File

@ -20,7 +20,7 @@
"replies": "Réponses",
"mentions": "Mentions",
"from": "de",
"to": "vers",
"to": "dans",
"deleted_by_creator": "supprimé par le créateur",
"more": "plus",
"mark_as_read": "marquer comme lu",
@ -105,5 +105,7 @@
"post_title_too_long": "Le titre de la publication est trop long.",
"email_already_exists": "Lemail existe déjà.",
"user_already_exists": "Lutilisateur·rice existe déjà.",
"number_users_online": "{count,plural, =1{{count} Utilisateur en ligne} other{{count} Utilisateurs en ligne}}"
"number_users_online": "{count,plural, =1{{count} Utilisateur en ligne} other{{count} Utilisateurs en ligne}}",
"number_of_comments": "{count,plural, =1{{count} Commentaire} other{{count} Commentaires}}",
"number_of_posts": "{count,plural, =1{{count} Publication} other{{count} Publications}}"
}

View File

@ -17,5 +17,7 @@
"locked": "बंद",
"couldnt_create_comment": "टिप्पणी (कमेंट) नहीं बना पाईं |",
"couldnt_find_community": "समुदायों नहीं ढूंढ़ पाएं |",
"community_already_exists": "यह समुदाय पहले स मौजूद है |"
"community_already_exists": "यह समुदाय पहले स मौजूद है |",
"number_of_comments": "{count,plural, =1{{{ count }} टिप्पणी (कमेंट )} other{{{ count }} टिप्पणियाँ (कोम्मेंट्स )}}",
"number_of_posts": "{count,plural, =1{{count} पोस्ट} other{{count} पोस्ट्स}}"
}

View File

@ -92,5 +92,7 @@
"post_title_too_long": "A bejegyzés címe túl hosszú.",
"email_already_exists": "Az email már létezik.",
"user_already_exists": "A felhasználó már létezik.",
"number_users_online": "{count,plural, =1{{count} online felhasználó} other{{count} online felhasználó}}"
"number_users_online": "{count,plural, =1{{count} online felhasználó} other{{count} online felhasználó}}",
"number_of_comments": "{count,plural, =1{{count} hozzászólás} other{{count} hozzászólás}}",
"number_of_posts": "{count,plural, =1{{count} bejegyzés} other{{count} bejegyzés}}"
}

View File

@ -106,5 +106,7 @@
"post_title_too_long": "Titolo della pubblicazione troppo lungo.",
"email_already_exists": "Indirizzo email già presente.",
"user_already_exists": "L'utente esiste già.",
"number_users_online": "{count,plural, =1{{count} utente connesso} other{{count} utenti connessi}}"
"number_users_online": "{count,plural, =1{{count} utente connesso} other{{count} utenti connessi}}",
"number_of_comments": "{count,plural, =1{{count} Commento} other{{count} Commenti}}",
"number_of_posts": "{count,plural, =1{{count} Pubblicazione} other{{count} Pubblicazioni}}"
}

View File

@ -94,5 +94,7 @@
"post_title_too_long": "投稿のタイトルが長すぎます。",
"email_already_exists": "メールアドレスが既に使用されています。",
"user_already_exists": "ユーザーは既に存在します。",
"number_users_online": "{count,plural, =1{{count} 名のユーザーがオンライン}}"
"number_users_online": "{count,plural, =1{{count} 名のユーザーがオンライン}}",
"number_of_comments": "{count,plural, =1{{count} 件のコメント}}",
"number_of_posts": "{count,plural, =1{{count} 件の投稿}}"
}

View File

@ -87,5 +87,7 @@
"post_title_too_long": "პოსტის სათაური ძალიან გრძელია.",
"email_already_exists": "ელ-პოსტა უკვე არსებობს.",
"user_already_exists": "მომხმარებელი უკვე არსებობს.",
"number_users_online": "{count,plural, =1{მომხმარებელი საიტზე} other{მომხმარებელი საიტზე}}"
"number_users_online": "{count,plural, =1{მომხმარებელი საიტზე} other{მომხმარებელი საიტზე}}",
"number_of_comments": "{count,plural, =1{კომენტარი} other{კომანტარები}}",
"number_of_posts": "{count,plural, =1{თარგმნა} other{თარგმნა}}"
}

View File

@ -20,7 +20,7 @@
"replies": "댓글",
"mentions": "언급",
"from": "에서",
"to": ">>",
"to": "to",
"deleted_by_creator": "글쓴이에 의해 삭제됨",
"more": "더 보기",
"mark_as_read": "읽은 상태로 표시",
@ -106,5 +106,7 @@
"post_title_too_long": "게시물 제목이 너무 깁니다.",
"email_already_exists": "이메일이 이미 존재합니다.",
"user_already_exists": "사용자가 이미 존재합니다.",
"number_users_online": "{count,plural, =1{접속자수 {count}}}"
"number_users_online": "{count,plural, =1{접속자수 {count}}}",
"number_of_comments": "{count,plural, =1{덧글수 {count}}}",
"number_of_posts": "{count,plural, =1{게시물 수 {count}}}"
}

View File

@ -3,7 +3,7 @@
"settings": "Instellingen",
"password": "Wachtwoord",
"email_or_username": "E-mail of gebruikersnaam",
"posts": "posts",
"posts": "Posts",
"comments": "Reacties",
"modlog": "Moderatorlog",
"community": "Community",
@ -39,7 +39,7 @@
"send_notifications_to_email": "Stuur meldingen naar je email",
"delete_account": "Verwijder account",
"saved": "Opgeslagen",
"communities": "Communities",
"communities": "Gemeenschappen",
"users": "Gebruikers",
"theme": "Thema",
"language": "Taal",
@ -92,5 +92,7 @@
"post_title_too_long": "Posttitel te lang.",
"email_already_exists": "Email bestaat al.",
"user_already_exists": "Gebruiker bestaat al.",
"number_users_online": "{count,plural, =1{{count} gebruiker online} other{{count} gebruikers online}}"
"number_users_online": "{count,plural, =1{{count} gebruiker online} other{{count} gebruikers online}}",
"number_of_comments": "{count,plural, =1{{count} reactie} other{{count} reacties}}",
"number_of_posts": "{count,plural, =1{{count} post} other{{count} posts}}"
}

View File

@ -102,5 +102,7 @@
"post_title_too_long": "Título da publicação muito longo.",
"email_already_exists": "Este e-mail já existe.",
"user_already_exists": "Este usuário já existe.",
"number_users_online": "{count,plural, =1{{count} usuário online} other{{count} usuários online}}"
"number_users_online": "{count,plural, =1{{count} usuário online} other{{count} usuários online}}",
"number_of_comments": "{count,plural, =1{{count} comentário} other{{count} comentários}}",
"number_of_posts": "{count,plural, =1{{count} publicação} other{{count} publicações}}"
}

View File

@ -92,5 +92,7 @@
"post_title_too_long": "Titulli i postimit ishte shumë i gjatë.",
"email_already_exists": "Email-i tashmë ekziston.",
"user_already_exists": "Përdoruesi tashmë ekziston.",
"number_users_online": "{count,plural, =1{{count} Përdorues Online} other{{count} Përdoruesa Online}}"
"number_users_online": "{count,plural, =1{{count} Përdorues Online} other{{count} Përdoruesa Online}}",
"number_of_comments": "{count,plural, =1{{count} Koment} other{{count} Komente}}",
"number_of_posts": "{count,plural, =1{{count} Postim} other{{count} Postime}}"
}

View File

@ -106,5 +106,7 @@
"post_title_too_long": "Inläggstiteln är för lång.",
"email_already_exists": "E-post finns redan.",
"user_already_exists": "Användaren finns redan.",
"number_users_online": "{count,plural, =1{{count} användare inloggad} other{{count} användare inloggade}}"
"number_users_online": "{count,plural, =1{{count} användare inloggad} other{{count} användare inloggade}}",
"number_of_comments": "{count,plural, =1{{count} kommentar} other{{count} kommentarer}}",
"number_of_posts": "{count,plural, =1{{count} inlägg} other{{count} inlägg}}"
}

View File

@ -92,5 +92,7 @@
"post_title_too_long": "Paylaşım başlığı çok uzun.",
"email_already_exists": "Böyle bir e-mail adresi zaten var.",
"user_already_exists": "Böyle bir kullanıcı zaten var.",
"number_users_online": "{count,plural, =1{{count} Kullanıcı Hatta} other{{count} Kullanıcı Hatta}}"
"number_users_online": "{count,plural, =1{{count} Kullanıcı Hatta} other{{count} Kullanıcı Hatta}}",
"number_of_comments": "{count,plural, =1{{count} Yorum} other{{count} Yorum}}",
"number_of_posts": "{count,plural, =1{{count} Paylaşım} other{{count} Paylaşım}}"
}

View File

@ -106,5 +106,7 @@
"post_title_too_long": "帖子标题过长。",
"email_already_exists": "邮箱已占用.",
"user_already_exists": "用户已存在。",
"number_users_online": "{count,plural, =1{{count} 在线用户} other{{count} 名在线用户}}"
"number_users_online": "{count,plural, =1{{count} 在线用户} other{{count} 名在线用户}}",
"number_of_comments": "{count,plural, =1{{count} 条评论} other{{count} 条评论}}",
"number_of_posts": "{count,plural, =1{{count} 个帖子} other{{count} 条帖子}}"
}

View File

@ -95,17 +95,14 @@ abstract class L10nStrings {
static const couldnt_update_site = 'couldnt_update_site';
static const invalid_community_name = 'invalid_community_name';
static const community_already_exists = 'community_already_exists';
static const community_moderator_already_exists =
'community_moderator_already_exists';
static const community_follower_already_exists =
'community_follower_already_exists';
static const community_moderator_already_exists = 'community_moderator_already_exists';
static const community_follower_already_exists = 'community_follower_already_exists';
static const not_a_moderator = 'not_a_moderator';
static const couldnt_update_community = 'couldnt_update_community';
static const no_community_edit_allowed = 'no_community_edit_allowed';
static const system_err_login = 'system_err_login';
static const community_user_already_banned = 'community_user_already_banned';
static const couldnt_find_that_username_or_email =
'couldnt_find_that_username_or_email';
static const couldnt_find_that_username_or_email = 'couldnt_find_that_username_or_email';
static const password_incorrect = 'password_incorrect';
static const registration_closed = 'registration_closed';
static const invalid_password = 'invalid_password';
@ -114,17 +111,17 @@ abstract class L10nStrings {
static const invalid_username = 'invalid_username';
static const bio_length_overflow = 'bio_length_overflow';
static const couldnt_update_user = 'couldnt_update_user';
static const couldnt_update_private_message =
'couldnt_update_private_message';
static const couldnt_update_private_message = 'couldnt_update_private_message';
static const couldnt_update_post = 'couldnt_update_post';
static const couldnt_create_private_message =
'couldnt_create_private_message';
static const no_private_message_edit_allowed =
'no_private_message_edit_allowed';
static const couldnt_create_private_message = 'couldnt_create_private_message';
static const no_private_message_edit_allowed = 'no_private_message_edit_allowed';
static const post_title_too_long = 'post_title_too_long';
static const email_already_exists = 'email_already_exists';
static const user_already_exists = 'user_already_exists';
static const number_users_online = 'number_users_online';
static const not_a_mod_or_admin = 'not_a_mod_or_admin';
static const number_of_comments = 'number_of_comments';
static const number_of_posts = 'number_of_posts';
}
extension L10nFromString on String {
@ -356,6 +353,8 @@ extension L10nFromString on String {
return L10n.of(context).email_already_exists;
case L10nStrings.user_already_exists:
return L10n.of(context).user_already_exists;
case L10nStrings.not_a_mod_or_admin:
return L10n.of(context).not_a_mod_or_admin;
default:
return this;

View File

@ -6,120 +6,143 @@ import 'dart:io';
import 'common.dart';
import 'gen_l10n_from_string.dart' as gen;
/// Map<key, renamedKey>, if `renamedKey` is null then no rename is performed
const toExtract = {
'settings': null,
'password': null,
'email_or_username': null,
'posts': null,
'comments': null,
'modlog': null,
'community': null,
'url': null,
'title': null,
'body': null,
'nsfw': null,
'post': null,
'save': null,
'send_message': null,
'subscribed': null,
'local': null,
'all': null,
'replies': null,
'mentions': null,
'from': null,
'to': null,
'deleted': 'deleted_by_creator',
'more': null,
'mark_as_read': null,
'mark_as_unread': null,
'reply': null,
'edit': null,
'delete': null,
'restore': null,
'yes': null,
'no': null,
'avatar': null,
'banner': null,
'display_name': null,
'bio': null,
'email': null,
'matrix_user_id': 'matrix_user',
'sort_type': null,
'type': null,
'show_nsfw': null,
'send_notifications_to_email': null,
'delete_account': null,
'saved': null,
'communities': null,
'users': null,
'theme': null,
'language': null,
'hot': null,
'new': null,
'old': null,
'top': null,
'chat': null,
'admin': null,
'by': null,
'not_a_mod_or_admin': null,
'not_an_admin': null,
'couldnt_find_post': null,
'not_logged_in': null,
'site_ban': null,
'community_ban': null,
'downvotes_disabled': null,
'invalid_url': null,
'locked': null,
'couldnt_create_comment': null,
'couldnt_like_comment': null,
'couldnt_update_comment': null,
'no_comment_edit_allowed': null,
'couldnt_save_comment': null,
'couldnt_get_comments': null,
'report_reason_required': null,
'report_too_long': null,
'couldnt_create_report': null,
'couldnt_resolve_report': null,
'invalid_post_title': null,
'couldnt_create_post': null,
'couldnt_like_post': null,
'couldnt_find_community': null,
'couldnt_get_posts': null,
'no_post_edit_allowed': null,
'couldnt_save_post': null,
'site_already_exists': null,
'couldnt_update_site': null,
'invalid_community_name': null,
'community_already_exists': null,
'community_moderator_already_exists': null,
'community_follower_already_exists': null,
'not_a_moderator': null,
'couldnt_update_community': null,
'no_community_edit_allowed': null,
'system_err_login': null,
'community_user_already_banned': null,
'couldnt_find_that_username_or_email': null,
'password_incorrect': null,
'registration_closed': null,
'invalid_password': null,
'passwords_dont_match': null,
'captcha_incorrect': null,
'invalid_username': null,
'bio_length_overflow': null,
'couldnt_update_user': null,
'couldnt_update_private_message': null,
'couldnt_update_post': null,
'couldnt_create_private_message': null,
'no_private_message_edit_allowed': null,
'post_title_too_long': null,
'email_already_exists': null,
'user_already_exists': null,
'number_online': 'number_users_online',
};
// config for migration of a single key
class _ {
final String key;
final String rename;
// TODO: migrate those with changed capitalization
// 'number_of_comments': null,
/// make all letters except the first one lower case in the base language
final bool decapitalize;
/// arb format for the placeholder
final String format;
/// arb type for the placeholder
final String type;
const _(
this.key, {
this.rename,
this.decapitalize = false,
this.format,
this.type,
});
String get renamedKey => rename ?? key;
}
const toMigrate = <_>[
_('settings'),
_('password'),
_('email_or_username'),
_('posts'),
_('comments'),
_('modlog'),
_('community'),
_('url'),
_('title'),
_('body'),
_('nsfw'),
_('post'),
_('save'),
_('send_message'),
_('subscribed'),
_('local'),
_('all'),
_('replies'),
_('mentions'),
_('from'),
_('to'),
_('deleted', rename: 'deleted_by_creator'),
_('more'),
_('mark_as_read'),
_('mark_as_unread'),
_('reply'),
_('edit'),
_('delete'),
_('restore'),
_('yes'),
_('no'),
_('avatar'),
_('banner'),
_('display_name'),
_('bio'),
_('email'),
_('matrix_user_id', rename: 'matrix_user'),
_('sort_type'),
_('type'),
_('show_nsfw'),
_('send_notifications_to_email'),
_('delete_account'),
_('saved'),
_('communities'),
_('users'),
_('theme'),
_('language'),
_('hot'),
_('new', rename: '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_online', rename: 'number_users_online', type: 'int'),
_('number_of_comments', type: 'int', format: 'compact'),
_('number_of_posts', type: 'int', format: 'compact'),
];
const repoName = 'lemmy-translations';
const baseLanguage = 'en';
@ -201,61 +224,65 @@ void portStrings(
// port all languages
for (final language in lemmyTranslations.keys) {
if (!lemmurTranslations.containsKey(language)) {
lemmurTranslations[language] = {};
lemmurTranslations[language]['@@locale'] = language;
lemmurTranslations[language] = {'@@locale': language};
}
}
for (final extract in toExtract.entries) {
final key = extract.key;
final renamedKey = extract.value ?? key;
if (!lemmyTranslations[baseLanguage].containsKey(key)) {
printError('"$key" does not exist in $repoName');
for (final migrate in toMigrate) {
if (!lemmyTranslations[baseLanguage].containsKey(migrate.key)) {
printError('"${migrate.key}" does not exist in $repoName');
}
if (lemmurTranslations[baseLanguage].containsKey(renamedKey) && !force) {
confirm('"$key" already exists in lemmur, overwrite?');
if (lemmurTranslations[baseLanguage].containsKey(migrate.renamedKey) &&
!force) {
confirm('"${migrate.key}" already exists in lemmur, overwrite?');
}
final metadata = <String, dynamic>{};
final variableName = RegExp(r'{{([\w_]+)}|')
.firstMatch(lemmyTranslations[baseLanguage][migrate.key])
?.group(1);
final metadata = <String, dynamic>{
if (variableName != null)
'placeholders': {
variableName: {
if (migrate.type != null) 'type': migrate.type,
if (migrate.format != null) 'format': migrate.format,
},
},
};
// ignore: omit_local_variable_types
String Function(Map<String, String> translations) transformer =
(translations) => translations[key];
(translations) => translations[migrate.key];
// check if it has a plural form
if (lemmyTranslations[baseLanguage].containsKey('${key}_plural')) {
final variable = RegExp(r'{([\w_]+)}')
.firstMatch(lemmyTranslations[baseLanguage][key])
.group(1);
if (lemmyTranslations[baseLanguage].containsKey('${migrate.key}_plural')) {
transformer = (translations) {
if (translations[key] == null) return null;
if (translations[migrate.key] == null) return null;
final fixedVariables =
translations[key].replaceAll('{{$variable}}', '{$variable}');
final fixedVariables = translations[migrate.key]
.replaceAll('{{$variableName}}', '{$variableName}');
final pluralForm = () {
if (translations.containsKey('${key}_plural')) {
return translations['${key}_plural']
.replaceAll('{{$variable}}', '{$variable}');
if (translations.containsKey('${migrate.key}_plural')) {
return translations['${migrate.key}_plural']
.replaceAll('{{$variableName}}', '{$variableName}');
}
return null;
}();
return '{$variable,plural, =1{$fixedVariables}${pluralForm != null ? ' other{$pluralForm}' : ''}}';
return '{$variableName,plural, =1{$fixedVariables}${pluralForm != null ? ' other{$pluralForm}' : ''}}';
};
metadata['placeholders'] = {variable: {}};
}
for (final trans in lemmyTranslations.entries) {
final language = trans.key;
final strings = trans.value;
lemmurTranslations[language][renamedKey] = transformer(strings);
lemmurTranslations[language][migrate.renamedKey] = transformer(strings);
}
lemmurTranslations[baseLanguage]['@$renamedKey'] = metadata;
lemmurTranslations[baseLanguage]['@${migrate.renamedKey}'] = metadata;
}
}