Add transforming options

This commit is contained in:
shilangyu 2021-03-02 22:53:29 +01:00
parent d5f1d45b06
commit b9e042b1d7
28 changed files with 144 additions and 27 deletions

View File

@ -60,5 +60,7 @@
"registration_closed": "إنشاء الحسابات معطل", "registration_closed": "إنشاء الحسابات معطل",
"passwords_dont_match": "الكلمات السرية غير متطابقة.", "passwords_dont_match": "الكلمات السرية غير متطابقة.",
"email_already_exists": "عنوان البريد الإلكتروني هذا موجود بالفعل.", "email_already_exists": "عنوان البريد الإلكتروني هذا موجود بالفعل.",
"user_already_exists": "هذا المستخدِم موجود بالفعل." "user_already_exists": "هذا المستخدِم موجود بالفعل.",
"unsubscribe": "إلغاء الإشتراك",
"subscribe": "اتبع"
} }

View File

@ -108,5 +108,8 @@
"captcha_incorrect": "Captcha incorrecte.", "captcha_incorrect": "Captcha incorrecte.",
"bio_length_overflow": "La biografia d'usuari no pot excedir els 300 caràcters.", "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_comments": "{count,plural, =1{{count} comentari} other{{count} comentaris}}",
"number_of_posts": "{count,plural, =1{{count} Publicació} other{{count} Publicacions}}" "number_of_posts": "{count,plural, =1{{count} Publicació} other{{count} Publicacions}}",
"number_of_subscribers": "{count,plural, =1{{count} subscriptor} other{{count} subscriptors}}",
"unsubscribe": "Dónat de baixa",
"subscribe": "Subscriu-thi"
} }

View File

@ -108,5 +108,8 @@
"user_already_exists": "Brugeren 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_comments": "{count,plural, =1{{count} Kommentar} other{{count} Kommentarer}}",
"number_of_posts": "{count,plural, =1{{count} Indlæg} other{{count} Indlæg}}" "number_of_posts": "{count,plural, =1{{count} Indlæg} other{{count} Indlæg}}",
"number_of_subscribers": "{count,plural, =1{{count} Abonnent} other{{count} Abonnenter}}",
"unsubscribe": "Afmeld abbonement",
"subscribe": "Abboner"
} }

View File

@ -104,5 +104,8 @@
"user_already_exists": "Nutzer 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_comments": "{count,plural, =1{{count} Kommentar} other{{count} Kommentare}}",
"number_of_posts": "{count,plural, =1{{count} Beitrag} other{{count} Beiträge}}" "number_of_posts": "{count,plural, =1{{count} Beitrag} other{{count} Beiträge}}",
"number_of_subscribers": "{count,plural, =1{{count} Abonnent} other{{count} Abonnent*innen}}",
"unsubscribe": "Deabonnieren",
"subscribe": "Abonnieren"
} }

View File

@ -108,5 +108,8 @@
"user_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_comments": "{count,plural, =1{{count} Σχόλιο} other{{count} Σχόλια}}",
"number_of_posts": "{count,plural, =1{{count} Δημοσίευση} other{{count} Δημοσιεύσεις}}" "number_of_posts": "{count,plural, =1{{count} Δημοσίευση} other{{count} Δημοσιεύσεις}}",
"number_of_subscribers": "{count,plural, =1{{count} εγγεγραμμένος} other{{count} εγγεγραμμένοι}}",
"unsubscribe": "Απεγγραφή",
"subscribe": "Εγγραφή"
} }

View File

@ -253,5 +253,17 @@
"format": "compact" "format": "compact"
} }
} }
} },
"number_of_subscribers": "{count,plural, =1{{count} subscriber} other{{count} subscribers}}",
"@number_of_subscribers": {
"placeholders": {
"count": {
"type": "int"
}
}
},
"unsubscribe": "unsubscribe",
"@unsubscribe": {},
"subscribe": "subscribe",
"@subscribe": {}
} }

View File

@ -108,5 +108,8 @@
"user_already_exists": "Uzanto 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_comments": "{count,plural, =1{{count} komento} other{{count} komentoj}}",
"number_of_posts": "{count,plural, =1{{count} afiŝo} other{{count} afiŝoj}}" "number_of_posts": "{count,plural, =1{{count} afiŝo} other{{count} afiŝoj}}",
"number_of_subscribers": "{count,plural, =1{{count} abonanto} other{{count} abonantoj}}",
"unsubscribe": "Malaboni",
"subscribe": "Aboni"
} }

View File

@ -108,5 +108,8 @@
"user_already_exists": "El usuario ya existe.", "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_comments": "{count,plural, =1{{count} Comentario} other{{count} Comentarios}}",
"number_of_posts": "{count,plural, =1{{count} Publicación} other{{count} Publicaciones}}" "number_of_posts": "{count,plural, =1{{count} Publicación} other{{count} Publicaciones}}",
"number_of_subscribers": "{count,plural, =1{{count} suscriptor} other{{count} suscriptores}}",
"unsubscribe": "Desuscribirse",
"subscribe": "Suscribirse"
} }

View File

@ -108,5 +108,8 @@
"user_already_exists": "Erabiltzaile 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_comments": "{count,plural, =1{Iruzkin {count}} other{{count} iruzkin}}",
"number_of_posts": "{count,plural, =1{Bidalketa {count}} other{{count} bidalketa}}" "number_of_posts": "{count,plural, =1{Bidalketa {count}} other{{count} bidalketa}}",
"number_of_subscribers": "{count,plural, =1{Harpidetu {count}} other{{count} harpidetu}}",
"unsubscribe": "Ezabatu harpidetza",
"subscribe": "Harpidetu"
} }

View File

@ -93,5 +93,8 @@
"user_already_exists": "Käyttäjä 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_comments": "{count,plural, =1{{count} kommentti} other{{count} kommenttia}}",
"number_of_posts": "{count,plural, =1{{count} viesti} other{{count} viestiä}}" "number_of_posts": "{count,plural, =1{{count} viesti} other{{count} viestiä}}",
"number_of_subscribers": "{count,plural, =1{{count} tilaaja} other{{count} tilaajaa}}",
"unsubscribe": "Poista tilaus",
"subscribe": "Tilaa"
} }

View File

@ -107,5 +107,8 @@
"user_already_exists": "Lutilisateur·rice 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_comments": "{count,plural, =1{{count} Commentaire} other{{count} Commentaires}}",
"number_of_posts": "{count,plural, =1{{count} Publication} other{{count} Publications}}" "number_of_posts": "{count,plural, =1{{count} Publication} other{{count} Publications}}",
"number_of_subscribers": "{count,plural, =1{{count} Abonné} other{{count} Abonnés}}",
"unsubscribe": "Se désabonner",
"subscribe": "Sabonner"
} }

View File

@ -101,5 +101,7 @@
"no_private_message_edit_allowed": "Ní cheadaítear teachtaireacht phríobháideach a chur in eagar.", "no_private_message_edit_allowed": "Ní cheadaítear teachtaireacht phríobháideach a chur in eagar.",
"post_title_too_long": "Tá teideal an postáil ró-fhada.", "post_title_too_long": "Tá teideal an postáil ró-fhada.",
"email_already_exists": "Tá ríomhphost ann cheana féin.", "email_already_exists": "Tá ríomhphost ann cheana féin.",
"user_already_exists": "Úsáideoir ann cheana." "user_already_exists": "Úsáideoir ann cheana.",
"unsubscribe": "Díliostáil",
"subscribe": "Liostáil"
} }

View File

@ -94,5 +94,8 @@
"user_already_exists": "A felhasználó 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_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}}" "number_of_posts": "{count,plural, =1{{count} bejegyzés} other{{count} bejegyzés}}",
"number_of_subscribers": "{count,plural, =1{{count} feliratkozó} other{{count} feliratkozó}}",
"unsubscribe": "Leiratkozás",
"subscribe": "Feliratkozás"
} }

View File

@ -108,5 +108,8 @@
"user_already_exists": "L'utente esiste già.", "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_comments": "{count,plural, =1{{count} Commento} other{{count} Commenti}}",
"number_of_posts": "{count,plural, =1{{count} Pubblicazione} other{{count} Pubblicazioni}}" "number_of_posts": "{count,plural, =1{{count} Pubblicazione} other{{count} Pubblicazioni}}",
"number_of_subscribers": "{count,plural, =1{{count} iscritto} other{{count} iscritti}}",
"unsubscribe": "Disiscriviti",
"subscribe": "Iscriviti"
} }

View File

@ -96,5 +96,8 @@
"user_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_comments": "{count,plural, =1{{count} 件のコメント}}",
"number_of_posts": "{count,plural, =1{{count} 件の投稿}}" "number_of_posts": "{count,plural, =1{{count} 件の投稿}}",
"number_of_subscribers": "{count,plural, =1{{count} 名の登録者}}",
"unsubscribe": "登録解除",
"subscribe": "登録"
} }

View File

@ -89,5 +89,8 @@
"user_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_comments": "{count,plural, =1{კომენტარი} other{კომანტარები}}",
"number_of_posts": "{count,plural, =1{თარგმნა} other{თარგმნა}}" "number_of_posts": "{count,plural, =1{თარგმნა} other{თარგმნა}}",
"number_of_subscribers": "{count,plural, =1{გამომწერი} other{გამომწერები}}",
"unsubscribe": "გამოწერის გაუქმნება",
"subscribe": "გამოწერა"
} }

View File

@ -108,5 +108,8 @@
"user_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_comments": "{count,plural, =1{덧글수 {count}}}",
"number_of_posts": "{count,plural, =1{게시물 수 {count}}}" "number_of_posts": "{count,plural, =1{게시물 수 {count}}}",
"number_of_subscribers": "{count,plural, =1{구독자수{count}}}",
"unsubscribe": "구독취소",
"subscribe": "구독"
} }

View File

@ -94,5 +94,8 @@
"user_already_exists": "Gebruiker 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_comments": "{count,plural, =1{{count} reactie} other{{count} reacties}}",
"number_of_posts": "{count,plural, =1{{count} post} other{{count} posts}}" "number_of_posts": "{count,plural, =1{{count} post} other{{count} posts}}",
"number_of_subscribers": "{count,plural, =1{{count} abonnee} other{{count} abonnees}}",
"unsubscribe": "Afmelden",
"subscribe": "Abonneren"
} }

View File

@ -107,5 +107,7 @@
"no_private_message_edit_allowed": "Brak uprawnień do edycji prywatnej wiadomości.", "no_private_message_edit_allowed": "Brak uprawnień do edycji prywatnej wiadomości.",
"post_title_too_long": "Tytuł posta zbyt długi.", "post_title_too_long": "Tytuł posta zbyt długi.",
"email_already_exists": "Email już istnieje.", "email_already_exists": "Email już istnieje.",
"user_already_exists": "Użytkownik już istnieje." "user_already_exists": "Użytkownik już istnieje.",
"unsubscribe": "Odsubskrybuj",
"subscribe": "Subskrybuj"
} }

View File

@ -104,5 +104,8 @@
"user_already_exists": "Este usuário 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_comments": "{count,plural, =1{{count} comentário} other{{count} comentários}}",
"number_of_posts": "{count,plural, =1{{count} publicação} other{{count} publicações}}" "number_of_posts": "{count,plural, =1{{count} publicação} other{{count} publicações}}",
"number_of_subscribers": "{count,plural, =1{{count} inscrito} other{{count} inscritos}}",
"unsubscribe": "Cancelar inscrição",
"subscribe": "Inscrever-se"
} }

View File

@ -105,5 +105,7 @@
"no_private_message_edit_allowed": "Не разрешается редактировать личное сообщение.", "no_private_message_edit_allowed": "Не разрешается редактировать личное сообщение.",
"post_title_too_long": "Длина названия записи превышает допустимый лимит.", "post_title_too_long": "Длина названия записи превышает допустимый лимит.",
"email_already_exists": "E-mail уже существует.", "email_already_exists": "E-mail уже существует.",
"user_already_exists": "Пользователь уже существует." "user_already_exists": "Пользователь уже существует.",
"unsubscribe": "Отписаться",
"subscribe": "Подписаться"
} }

View File

@ -94,5 +94,8 @@
"user_already_exists": "Përdoruesi 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_comments": "{count,plural, =1{{count} Koment} other{{count} Komente}}",
"number_of_posts": "{count,plural, =1{{count} Postim} other{{count} Postime}}" "number_of_posts": "{count,plural, =1{{count} Postim} other{{count} Postime}}",
"number_of_subscribers": "{count,plural, =1{{count} i abonuar} other{{count} të abonuar}}",
"unsubscribe": "Ndalo Abonimin",
"subscribe": "Abonohu"
} }

View File

@ -108,5 +108,8 @@
"user_already_exists": "Användaren 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_comments": "{count,plural, =1{{count} kommentar} other{{count} kommentarer}}",
"number_of_posts": "{count,plural, =1{{count} inlägg} other{{count} inlägg}}" "number_of_posts": "{count,plural, =1{{count} inlägg} other{{count} inlägg}}",
"number_of_subscribers": "{count,plural, =1{{count} prenumerant} other{{count} prenumeranter}}",
"unsubscribe": "Avsluta prenumeration",
"subscribe": "Prenumerera"
} }

View File

@ -94,5 +94,8 @@
"user_already_exists": "Böyle bir kullanıcı 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_comments": "{count,plural, =1{{count} Yorum} other{{count} Yorum}}",
"number_of_posts": "{count,plural, =1{{count} Paylaşım} other{{count} Paylaşım}}" "number_of_posts": "{count,plural, =1{{count} Paylaşım} other{{count} Paylaşım}}",
"number_of_subscribers": "{count,plural, =1{{count} Takipçi} other{{count} Takipçi}}",
"unsubscribe": "Takibi bırak",
"subscribe": "Takip et"
} }

View File

@ -91,5 +91,7 @@
"no_private_message_edit_allowed": "Не можна редагувати особисті повідомлення.", "no_private_message_edit_allowed": "Не можна редагувати особисті повідомлення.",
"post_title_too_long": "Довжина назви перебільшує допустимий ліміт.", "post_title_too_long": "Довжина назви перебільшує допустимий ліміт.",
"email_already_exists": "E-mail вже існує.", "email_already_exists": "E-mail вже існує.",
"user_already_exists": "Користувач вже існує." "user_already_exists": "Користувач вже існує.",
"unsubscribe": "Відписатися",
"subscribe": "Підписатися"
} }

View File

@ -108,5 +108,8 @@
"user_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_comments": "{count,plural, =1{{count} 条评论} other{{count} 条评论}}",
"number_of_posts": "{count,plural, =1{{count} 个帖子} other{{count} 条帖子}}" "number_of_posts": "{count,plural, =1{{count} 个帖子} other{{count} 条帖子}}",
"number_of_subscribers": "{count,plural, =1{{count} 订阅者} other{{count} 名订阅者}}",
"unsubscribe": "取消订阅",
"subscribe": "订阅"
} }

View File

@ -122,6 +122,9 @@ abstract class L10nStrings {
static const not_a_mod_or_admin = 'not_a_mod_or_admin'; static const not_a_mod_or_admin = 'not_a_mod_or_admin';
static const number_of_comments = 'number_of_comments'; static const number_of_comments = 'number_of_comments';
static const number_of_posts = 'number_of_posts'; static const number_of_posts = 'number_of_posts';
static const number_of_subscribers = 'number_of_subscribers';
static const unsubscribe = 'unsubscribe';
static const subscribe = 'subscribe';
} }
extension L10nFromString on String { extension L10nFromString on String {
@ -355,6 +358,10 @@ extension L10nFromString on String {
return L10n.of(context).user_already_exists; return L10n.of(context).user_already_exists;
case L10nStrings.not_a_mod_or_admin: case L10nStrings.not_a_mod_or_admin:
return L10n.of(context).not_a_mod_or_admin; return L10n.of(context).not_a_mod_or_admin;
case L10nStrings.unsubscribe:
return L10n.of(context).unsubscribe;
case L10nStrings.subscribe:
return L10n.of(context).subscribe;
default: default:
return this; return this;

View File

@ -11,8 +11,9 @@ class _ {
final String key; final String key;
final String rename; final String rename;
/// make all letters except the first one lower case in the base language /// make all letters except the first one lower case
final bool decapitalize; final bool decapitalize;
final bool toLowerCase;
/// arb format for the placeholder /// arb format for the placeholder
final String format; final String format;
@ -24,11 +25,21 @@ class _ {
this.key, { this.key, {
this.rename, this.rename,
this.decapitalize = false, this.decapitalize = false,
this.toLowerCase = false,
this.format, this.format,
this.type, this.type,
}); });
String get renamedKey => rename ?? key; String get renamedKey => rename ?? key;
// will transform a value of a translation of the base language
String transform(String input) {
if (toLowerCase) return input.toLowerCase();
if (decapitalize) return '${input[0]}${input.substring(1).toLowerCase()}';
return input;
}
} }
const toMigrate = <_>[ const toMigrate = <_>[
@ -142,6 +153,9 @@ const toMigrate = <_>[
_('number_online', rename: 'number_users_online', type: 'int'), _('number_online', rename: 'number_users_online', type: 'int'),
_('number_of_comments', type: 'int', format: 'compact'), _('number_of_comments', type: 'int', format: 'compact'),
_('number_of_posts', type: 'int', format: 'compact'), _('number_of_posts', type: 'int', format: 'compact'),
_('number_of_subscribers', type: 'int'),
_('unsubscribe', toLowerCase: true),
_('subscribe', toLowerCase: true),
]; ];
const repoName = 'lemmy-translations'; const repoName = 'lemmy-translations';
@ -151,6 +165,8 @@ const flutterIntlPrefix = 'intl_';
Future<void> main(List<String> args) async { Future<void> main(List<String> args) async {
final force = args.contains('-f') || args.contains('--force'); final force = args.contains('-f') || args.contains('--force');
checkDuplicateKeys();
final repoCleanup = await cloneLemmyTranslations(); final repoCleanup = await cloneLemmyTranslations();
final lemmyTranslations = await loadLemmyStrings(); final lemmyTranslations = await loadLemmyStrings();
@ -167,6 +183,16 @@ Future<void> main(List<String> args) async {
await gen.main(args); await gen.main(args);
} }
/// check if `toMigrate` has duplicate keys
void checkDuplicateKeys() {
final hasDuplicates =
toMigrate.map((e) => e.key).toSet().length != toMigrate.length;
if (hasDuplicates) {
printError('"toMigrate" contains duplicate keys');
}
}
/// returns a cleanup function /// returns a cleanup function
Future<Future<void> Function()> cloneLemmyTranslations() async { Future<Future<void> Function()> cloneLemmyTranslations() async {
await Process.run('git', ['clone', 'https://github.com/LemmyNet/$repoName']); await Process.run('git', ['clone', 'https://github.com/LemmyNet/$repoName']);
@ -282,6 +308,8 @@ void portStrings(
lemmurTranslations[language][migrate.renamedKey] = transformer(strings); lemmurTranslations[language][migrate.renamedKey] = transformer(strings);
} }
lemmurTranslations[baseLanguage][migrate.renamedKey] =
migrate.transform(transformer(lemmyTranslations[baseLanguage]));
lemmurTranslations[baseLanguage]['@${migrate.renamedKey}'] = metadata; lemmurTranslations[baseLanguage]['@${migrate.renamedKey}'] = metadata;
} }
} }