Skip to content

Commit

Permalink
Test: Added new WrongTranslationVariablesTest and fix it's issues
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexeySafronov committed Nov 13, 2021
1 parent 478ca32 commit c7c7267
Show file tree
Hide file tree
Showing 25 changed files with 130 additions and 53 deletions.
77 changes: 77 additions & 0 deletions common/Tests/Frontend.Translations.Tests/LocalesTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,83 @@ public void NotTranslatedToastsTest()
Assert.AreEqual(0, NotTranslatedToasts.Count, message);
}

[Test]
public void WrongTranslationVariablesTest()
{
var message = $"Next keys have wrong variables:\r\n\r\n";
var regVariables = new Regex("\\{\\{([^\\{].?[^\\}]+)\\}\\}", RegexOptions.Compiled | RegexOptions.Multiline);

var groupedByLng = TranslationFiles
.GroupBy(t => t.Language)
.Select(g => new
{
Language = g.Key,
TranslationsWithVariables = g.ToList()
.SelectMany(t => t.Translations)
.Where(k => k.Value.IndexOf("{{") != -1)
.Select(t => new
{
t.Key,
t.Value,
Variables = regVariables.Matches(t.Value)
.Select(m => m.Groups[1]?.Value?.Trim().Replace(", lowercase", ""))
.ToList()
})
.ToList()
})
.ToList();

var enWithVariables = groupedByLng
.Where(t => t.Language == "en")
.SelectMany(t => t.TranslationsWithVariables)
.ToList();

var otherLanguagesWithVariables = groupedByLng
.Where(t => t.Language != "en")
.ToList();

var i = 0;
var errorsCount = 0;

foreach (var lng in otherLanguagesWithVariables)
{
foreach (var t in lng.TranslationsWithVariables)
{
var enKey = enWithVariables
.Where(en => en.Key == t.Key)
.FirstOrDefault();

if (enKey == null)
{
// wrong
message += $"{++i}. lng='{lng.Language}' key='{t.Key}' has no 'en' language variant (!!!useless key!!!)\r\n\r\n";
errorsCount++;
continue;
}

if (enKey.Variables.Count != t.Variables.Count)
{
// wrong
message += $"{++i}. lng='{lng.Language}' key='{t.Key}' has less variables then 'en' language have " +
$"(en={enKey.Variables.Count}|{lng.Language}={t.Variables.Count})\r\n" +
$"'en': '{enKey.Value}'\r\n'{lng.Language}': '{t.Value}'\r\n\r\n";
errorsCount++;
}

if (!t.Variables.All(v => enKey.Variables.Contains(v)))
{
// wrong
errorsCount++;
message += $"{++i}. lng='{lng.Language}' key='{t.Key}' has not equals variables of 'en' language have\r\n\r\n" +
$"Have to be:\r\n'{enKey.Value}'\r\n\r\n{string.Join("\r\n", enKey.Variables)}\r\n\r\n" +
$"But in real:\r\n'{t.Value}'\r\n\r\n{string.Join("\r\n", t.Variables)} \r\n\r\n";
}
}
}

Assert.AreEqual(0, errorsCount, message);
}

/*[Test]
public void TempTest()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"DeleteThirdPartyAlert": "Voulez-vous supprimer {{service}} du module \"Documents\" ? . Cela n'affectera en aucun cas votre compte : {{compte}} .",
"DeleteThirdPartyAlert": "Voulez-vous supprimer {{service}} du module \"Documents\" ? . Cela n'affectera en aucun cas votre compte : {{account}} .",
"SuccessDeleteThirdParty": "Le {{service}} tiers est supprimé."
}
}
2 changes: 1 addition & 1 deletion products/ASC.Files/Client/public/locales/fr/Home.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"TitleUploaded": "Téléchargé",
"TooltipElementCopyMessage": "Copier {{element}}",
"TooltipElementsCopyMessage": "Copier {{element}} des elements",
"TooltipElementsMoveMessage": "Déplacer les éléments {{élément}}",
"TooltipElementsMoveMessage": "Déplacer les éléments {{element}}",
"TrashEmptyContainerDescription": "La Corbeille est l'endroit où sont déplacés tous les fichiers supprimés. Vous pouvez les restaurer ou les supprimer définitivement en vidant la Corbeille. ",
"UnblockVersion": "Débloquer/enregistrer",
"UploadToFolder": "Télécharger le dossier",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"ChangeOwner": "ປ່ຽນເຈົ້າຂອງ ({{ຊື່ເອກະສານ}})",
"ChangeOwner": "ປ່ຽນເຈົ້າຂອງ ({{fileName}})",
"ChangeOwnerDescription": "ຫລັງຈາກເຈົ້າຂອງປ່ຽນແລ້ວ, ເຈົ້າຂອງປະຈຸບັນໄດ້ຮັບສິດລະດັບດຽວກັນກັບສະມາຊິກຄົນອື່ນໆໃນກຸ່ມຂອງພວກເຂົາ"
}
}
8 changes: 4 additions & 4 deletions products/ASC.Files/Client/public/locales/lo/Home.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"PrivateRoomDescriptionSecure": "ແບ່ງປັນຢ່າງປອດໄພກັບເພື່ອນຮ່ວມທີມທີ່ໄວ້ໃຈໄດ້.",
"PrivateRoomDescriptionUnbreakable": "ສູດການຄິດໄລ່ AES-256 ບໍ່ສາມາດ ທຳລາຍໄດ້.",
"PrivateRoomHeader": "ຍິນດີຕ້ອນຮັບເຂົ້າສູ່ ONLYOFFICE ສ່ວນຕົວ ທີ່ທຸກໆສັນຍາລັກທີ່ທ່ານພິມຖືກເຂົ້າລະຫັດ",
"PrivateRoomSupport": "ເຮັດວຽກຢູ່ໃນຫ້ອງສ່ວນຕົວໄດ້ທາງ {{ຊື່ອົງກອນ}} desktop app. <3> ຄຳແນະນຳ </3>",
"PrivateRoomSupport": "ເຮັດວຽກຢູ່ໃນຫ້ອງສ່ວນຕົວໄດ້ທາງ {{organizationName}} desktop app. <3> ຄຳແນະນຳ </3>",
"RecentEmptyContainerDescription": "ສ່ວນ 'ລ້າສຸດ' ຈະສະແດງໃຫ້ທ່ານເຫັນໄຟລ໌ທີ່ຖືກເບິ່ງ ແລະ ແກ້ໄຂຄັ້ງສຸດທ້າຍ.",
"RemovedFromFavorites": "ລຶບອອກຈາກລາຍການທີ່ມັກແລ້ວ",
"RemoveFromFavorites": "ລຶບອອກຈາກລາຍການທີ່ມັກ",
Expand All @@ -67,9 +67,9 @@
"TitleModified": "ອັບເດດແລ້ວ",
"TitleSubfolders": "Flds",
"TitleUploaded": "ອັບໂຫລດ",
"TooltipElementCopyMessage": "ຄັດລອກ {{ອົງປະກອບ}}",
"TooltipElementsCopyMessage": "ຄັດລອກ {{ອົງປະກອບ}} ອົງປະກອບ",
"TooltipElementsMoveMessage": "ຍ້າຍ {{ອົງປະກອບ}} ອົງປະກອບ",
"TooltipElementCopyMessage": "ຄັດລອກ {{element}}",
"TooltipElementsCopyMessage": "ຄັດລອກ {{element}} ອົງປະກອບ",
"TooltipElementsMoveMessage": "ຍ້າຍ {{element}} ອົງປະກອບ",
"TrashEmptyContainerDescription": "ຖັງຂີ້ເຫຍື້ອແມ່ນບ່ອນທີ່ຍ້າຍໄຟລ໌ທີ່ຖືກລົບທັງໝົດທ່ານສາມາດກູ້ຄືນ ຫຼື ລົບອອກຢ່າງຖາວອນໂດຍການລ້າງຖັງຂີ້ເຫຍື້ອ",
"UnblockVersion": "ເລິກການບ໋ອກ/ເຊັກອິນ",
"UploadToFolder": "ອັບໂຫລດໄປຍັງໂຟຣເດີ",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"MoveConfirmation": "ຍ້າຍການຢືນຢັນ",
"MoveConfirmationAlert": "ທ່ານແນ່ໃຈບໍວ່າທ່ານຕ້ອງການຍ້າຍອົງປະກອບ?",
"MoveConfirmationMessage": "ທ່ານ ກຳລັງຈະຍ້າຍອົງປະກອບອອກຈາກໄດເລກະທໍລີ {{ຜູ້ໃຫ້ບໍລິການ}}. ພວກເຂົາຈະຖືກລຶບອອກຈາກບັນຊີ {{ຜູ້ໃຫ້ບໍລິການ}} ຂອງທ່ານແລະຈະບໍ່ສາມາດເຂົ້າເຖິງຜູ້ໃຊ້ອື່ນໄດ້ອີກຕໍ່ໄປ."
}
"MoveConfirmationMessage": "ທ່ານ ກຳລັງຈະຍ້າຍອົງປະກອບອອກຈາກໄດເລກະທໍລີ {{provider}}. ພວກເຂົາຈະຖືກລຶບອອກຈາກບັນຊີ {{provider}} ຂອງທ່ານແລະຈະບໍ່ສາມາດເຂົ້າເຖິງຜູ້ໃຊ້ອື່ນໄດ້ອີກຕໍ່ໄປ."
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"ConflictResolveDescription": "O arquivo com o nome {{{file}} já existe na pasta {{folder}}.",
"ConflictResolveDescriptionFiles": "Os documentos com o mesmo nome já existem na pasta '{{folder}}}.",
"ConflictResolveDescriptionFiles": "{{filesCount}} Os documentos com o mesmo nome já existem na pasta '{{folder}}}.",
"ConflictResolveSelectAction": "Selecione a ação:",
"ConflictResolveTitle": "Confirmação de substituição",
"CreateDescription": "Haverão dois arquivos diferentes na pasta.",
Expand All @@ -9,4 +9,4 @@
"OverwriteTitle": "Substituir por versão atualizada",
"SkipDescription": "Nenhum arquivo será copiado. O arquivo original será mantido na pasta de destino.",
"SkipTitle": "Pular"
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"DeleteThirdPartyAlert": "Remover {{service}} do módulo 'Documentos'? Isto não afetará de forma alguma sua conta {{account}}.",
"SuccessDeleteThirdParty": "O {{serviço}} de terceiros é excluído"
}
"SuccessDeleteThirdParty": "O {{service}} de terceiros é excluído"
}
4 changes: 2 additions & 2 deletions products/ASC.Files/Client/public/locales/pt-BR/Home.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
"EmptyRecycleBin": "Esvaziar lixeira",
"FavoritesEmptyContainerDescription": "Para marcar os arquivos como favoritos ou removê-los desta lista, use o menu de contexto.",
"FileRemoved": "Arquivo movido para a lixeira",
"FileRenamed": "O documento '{{doTitle}}' é renomeado para '{novoTitle''.",
"FileRenamed": "O documento '{{oldTitle}}' é renomeado para '{{newTitle}}'.",
"Filter": "Filtro",
"FinalizeVersion": "Finalizar versão",
"Folder": "Pasta",
"FolderRemoved": "Pasta movida para a lixeira",
"FolderRenamed": "A pasta '{{folderTitle}}' é renomeada para '{newFoldedTitle}}'.",
"FolderRenamed": "A pasta '{{folderTitle}}' é renomeada para '{{newFoldedTitle}}'.",
"GoToMyButton": "Ir aos Meus Documentos",
"Images": "Imagens",
"LinkForPortalUsers": "Link para usuários do portal",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
"Notify users": "Notificar os usuários",
"Owner": "Proprietário",
"ReadOnly": "Somente leitura",
"ShareEmailBody": "Foi-lhe concedido acesso ao documento {{itemNome}}. Clique no link abaixo para abrir o documento agora mesmo: {{{shareLink}}}",
"ShareEmailSubject": "Você obteve acesso ao documento {{itemNome}}.",
"ShareEmailBody": "Foi-lhe concedido acesso ao documento {{itemName}}. Clique no link abaixo para abrir o documento agora mesmo: {{shareLink}}",
"ShareEmailSubject": "Você obteve acesso ao documento {{itemName}}.",
"ShareEveryone": "Todos",
"ShareVia": "Compartilhar via",
"SharingSettingsTitle": "Configurações de compartilhamento"
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"DeleteThirdPartyAlert": "Вы действительно хотите удалить {{service}} из модуля 'Документы'? Это никак не повлияет на Ваш аккаунт.",
"DeleteThirdPartyAlert": "Вы действительно хотите удалить {{service}} из модуля 'Документы'? Это никак не повлияет на Ваш {{account}} аккаунт.",
"SuccessDeleteThirdParty": "Сторонний ресурс {{service}} отключен"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"ChangeUsersActiveStatus": "ປິດການໃຊ້ງານ",
"ChangeUsersDisableStatus": "ເປີດໃຊ້ງານ",
"ChangeUsersStatusButton": "ປ່ຽນສະຖານະຜູ້ໃຊ້",
"ChangeUserStatusDialog": "ສະຖານະຂອງຜູ້ໃຊ້ທີ່ມີ '{{ສະຖານະ}}' ຈະຖືກປິດໃຊ້ງານ.",
"ChangeUserStatusDialog": "ສະຖານະຂອງຜູ້ໃຊ້ທີ່ມີ '{{ status }}' ຈະຖືກປິດໃຊ້ງານ.",
"ChangeUserStatusDialogHeader": "ປ່ຽນສະຖານະຜູ້ໃຊ້",
"ChangeUserStatusDialogMessage": "ທ່ານບໍ່ສາມາດປ່ຽນສະຖານະພາບສຳລັບເຈົ້າຂອງ portal ແລະ ສຳລັບທ່ານເອງ"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"CustomNewDepartment": "{{ກຸ່ມສົນທະນາ}} (ສ້າງ)",
"CustomNewDepartment": "{{groupCaption}} (ສ້າງ)",
"GroupAction": "ກຸ່ມດຳເນີນການ",
"Members": "ສະມາຊິກ",
"SearchAddedMembers": "ຄົ້ນຫາສະມາຊິກເພີ່ມ",
Expand Down
4 changes: 2 additions & 2 deletions products/ASC.People/Client/public/locales/lo/Home.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
"LblSetActive": "ຕັ້ງຄ່າໃຊ້ງານ",
"LblSetDisabled": "ປິດໃຊ້ງານ",
"MakeInvitationLink": "ສ້າງລິ້ງການເຊີນ",
"MessageEmailActivationInstuctionsSentOnEmail": "ຄຳແນະນຳກ່ຽວກັບການເປີດໃຊ້ອີເມວໄດ້ຖືກສົ່ງໄປທີ່ອີເມວ <1> {{ອີເມວ}} </1> ທີ່ຢູ່ເມວ",
"MessageEmailActivationInstuctionsSentOnEmail": "ຄຳແນະນຳກ່ຽວກັບການເປີດໃຊ້ອີເມວໄດ້ຖືກສົ່ງໄປທີ່ອີເມວ <1> {{email}} </1> ທີ່ຢູ່ເມວ",
"NotFoundDescription": "ລອງໃຊ້ຕົວຄົ້ນຫາ ຫຼື ລ້າງເພື່ອເບິ່ງທຸກຄົນໃນສ່ວນນີ້",
"NotFoundTitle": "ບໍ່ພົບເພື່ອນຮ່ວມທີມ",
"SuccessfullyRemovedGroup": "ລົບກຸ່ມສຳເລັດແລ້ວ",
"UserStatus": "ສະຖານະ"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"ChangeButton": "ການປ່ຽນແປງ",
"ChangesSavedSuccessfully": "ການປ່ຽນແປງຖືກບັນທຶກຮຽບຮ້ອຍແລ້ວ",
"ContactInformation": "ຂໍ້​ມູນ​ຕິດ​ຕໍ່",
"CustomCreation": "{{ຜູ້ໃຊ້}} (ການສ້າງ)",
"CustomCreation": "{{user}} (ການສ້າງ)",
"EditPhoto": "ແກ້ໄຂຮູບພາບ",
"EditUserDialogTitle": "ແກ້ໄຂໂປຣໄຟລ໌",
"EmailPopupHelper": "ອີເມວຫຼັກແມ່ນໃຊ້ ສຳ ລັບການແຈ້ງເຕືອນແລະການກູ້ຄືນການເຂົ້າເຖິງ.<1> ທ່ານສາມາດສ້າງອີເມວໃໝ່ໃນໂດເມນນີ້ສຳລັບຜູ້ໃຊ້ແລະຕັ້ງລະຫັດຜ່ານໜຶ່ງຄັ້ງສຳລັບການເຂົ້າສູ່ລະບົບຄັ້ງທຳອິດ.</1>",
Expand Down
4 changes: 2 additions & 2 deletions products/ASC.People/Client/public/locales/pt-BR/Home.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
"LblSetActive": "Ativar",
"LblSetDisabled": "Conjunto desativado",
"MakeInvitationLink": "Criar link para convite",
"MessageEmailActivationInstuctionsSentOnEmail": "As instruções de ativação de e-mail foram enviadas para o endereço de e-mail <1>{{{{email}}</1>",
"MessageEmailActivationInstuctionsSentOnEmail": "As instruções de ativação de e-mail foram enviadas para o endereço de e-mail <1>{{email}}</1>",
"NotFoundDescription": "Tente um filtro diferente ou limpe-o para ver todas as pessoas da seção.",
"NotFoundTitle": "Nenhum colega de equipe encontrado",
"SuccessfullyRemovedGroup": "O grupo foi removido com sucesso",
"UserStatus": "Status"
}
}
4 changes: 2 additions & 2 deletions products/ASC.People/Client/public/locales/pt-BR/Profile.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
"EditUser": "Editar Perfil",
"InviteAgainLbl": "Convidar novamente",
"LoginSettings": "Ajustes de acesso",
"MessageEmailActivationInstuctionsSentOnEmail": "As instruções de ativação de e-mail foram enviadas para o endereço de e-mail <strong>{{{ e-mail }}</strong>",
"MessageEmailActivationInstuctionsSentOnEmail": "As instruções de ativação de e-mail foram enviadas para o endereço de e-mail <strong>{{email}}</strong>",
"PhoneLbl": "Telefone",
"ProviderSuccessfullyConnected": "Provedor conectado com sucesso",
"ProviderSuccessfullyDisconnected": "Provedor desconectado com sucesso",
"ShowBackupCodes": "Mostrar códigos de backup",
"Subscriptions": "Assinaturas",
"TfaLoginSettings": "Ajustes de acesso",
"TwoFactorDescription": "A autenticação de dois fatores por meio de um aplicativo de geração de código foi habilitada para todos os usuários pelo administrador."
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"ChangeUsersActiveStatus": "разблокированы",
"ChangeUsersDisableStatus": "заблокированы",
"ChangeUsersStatusButton": "Изменить статус",
"ChangeUserStatusDialog": "Пользователи со статусом '{{ userStatus }}' будут {{ status }}.",
"ChangeUserStatusDialog": "Пользователи со статусом '{{status}}' будут отключены.",
"ChangeUserStatusDialogHeader": "Изменение статуса пользователя",
"ChangeUserStatusDialogMessage": "Вы не можете изменить статус владельца портала и свой собственный статус"
}
}
8 changes: 4 additions & 4 deletions public/locales/lo/Common.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"Confirmation": "ການຢັ້ງຢືນຕົວຕົນ",
"ContinueButton": "ສືບຕໍ່",
"CopyEmailAndPassword": "ສຳເນົາອີເມວ ແລະ ລະຫັດຜ່ານ",
"CountPerPage": "{{ນັບ}} ຕໍ່ ໜ້າ",
"CountPerPage": "{{count}} ຕໍ່ ໜ້າ",
"Culture_en": "ພາສາອັງກິດ",
"Culture_en-US": "ພາສາອັງກິດ (ອາເມລິກາ)",
"Culture_ru-RU": "ພາສາລັດເຊຍ",
Expand Down Expand Up @@ -43,11 +43,11 @@
"Next": "ຖັດໄປ",
"NotFoundLanguage": "ບໍ່ສາມາດຫາພາສາຂອງທ່ານໄດ້ແມ່ນບໍ່? ຕິດຕໍ່ພວກເຮົາທີ່ <1> {{supportEmail}} </1> ເພື່ອໃຫ້ພວກເຮົາມີສ່ວນຮ່ວມໃນການແປພາສາ.",
"OKButton": "ຕົກລົງ",
"OpenApp": "ເປີດ {{ຫົວຂໍ້}} ແອັບຂອງທ່ານ",
"PageOfTotalPage": "{{ໜ້າ}} ຂອງ {{ໜ້າ ທັງ ໝົດ}}",
"OpenApp": "ເປີດ {{title}} ແອັບຂອງທ່ານ",
"PageOfTotalPage": "{{page}} ຂອງ {{totalPage}}",
"Password": "ລະຫັດຜ່ານ",
"PasswordLimitDigits": "ຕົວເລກ",
"PasswordLimitLength": "ຕັ້ງຄ່າຕົວອັກສອນ {{ຈາກຕົວເລກນີ້}} ເຖິງ {{ຕົວເລກນີ້}}",
"PasswordLimitLength": "ຕັ້ງຄ່າຕົວອັກສອນ {{fromNumber}} ເຖິງ {{toNumber}}",
"PasswordLimitMessage": "ລະຫັດຜ່ານຕ້ອງມີ",
"PasswordLimitSpecialSymbols": "ຕົວອັກສອນພິເສດ",
"PasswordLimitUpperCase": "ໂຕອັກສອນໃຫຍ່",
Expand Down
2 changes: 1 addition & 1 deletion public/locales/pt-BR/Common.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"MeLabel": "Eu",
"More": "Mais",
"Next": "Próximo",
"NotFoundLanguage": "Não consegue encontrar seu idioma? Entre em contato conosco em <1>{{supportEmail}</1> para participar da tradução e receber recompensas.",
"NotFoundLanguage": "Não consegue encontrar seu idioma? Entre em contato conosco em <1>{{supportEmail}}</1> para participar da tradução e receber recompensas.",
"OKButton": "OK",
"OpenApp": "Abra seu {{title}} app",
"PageOfTotalPage": "{{page}} de {{totalPage}}",
Expand Down
Loading

0 comments on commit c7c7267

Please sign in to comment.