Skip to content

Commit cd98757

Browse files
committed
improve locales validation script. AG-26104
Squashed commit of the following: commit 0500480 Merge: 1fada97 3ac9cb5 Author: Slava Leleka <[email protected]> Date: Tue Sep 26 17:18:25 2023 +0300 Merge branch 'master' into feature/AG-26104 commit 1fada97 Author: Slava Leleka <[email protected]> Date: Tue Sep 26 15:28:34 2023 +0300 update translations commit c3bd719 Author: Slava Leleka <[email protected]> Date: Tue Sep 26 15:27:25 2023 +0300 clean up commit ad6b12d Author: Slava Leleka <[email protected]> Date: Tue Sep 26 15:13:13 2023 +0300 improve locales validation script commit 1ccfdc4 Author: Slava Leleka <[email protected]> Date: Tue Sep 26 15:12:31 2023 +0300 update translate to v1.0.2
1 parent 3ac9cb5 commit cd98757

File tree

13 files changed

+43
-20
lines changed

13 files changed

+43
-20
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
"zip-webpack-plugin": "^4.0.1"
115115
},
116116
"dependencies": {
117-
"@adguard/translate": "^0.3.2",
117+
"@adguard/translate": "^1.0.2",
118118
"@babel/runtime": "^7.12.0",
119119
"@xstate/react": "^2.0.1",
120120
"buffer": "^6.0.3",

src/_locales/cs/messages.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@
824824
"description": "Respect spaces between text, tags and placeholders"
825825
},
826826
"popup_free_traffic_info_days_left": {
827-
"message": "Provoz se obnoví dnes | Provoz se obnoví za %days% den | Provoz se obnoví za %days% dny | Provoz se obnoví za %count% dní",
827+
"message": "Provoz se obnoví dnes | Provoz se obnoví za %days% den | Provoz se obnoví za %days% dny | Provoz se obnoví za %days% dní",
828828
"description": "Respect spaces between text, tags and placeholders. 40 characters max limit for every plural form"
829829
},
830830
"popup_hint_popup_content": {

src/_locales/fr/messages.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@
222222
"message": "Code d’authentification"
223223
},
224224
"official_website": {
225-
"message": "Site web officiel"
225+
"message": "Site Web officiel"
226226
},
227227
"eula": {
228228
"message": "CLUF"
@@ -345,7 +345,7 @@
345345
"message": "Ajouter un serveur DNS de l’utilisateur"
346346
},
347347
"settings_dns_edit_custom_server": {
348-
"message": "Modifier le serveur DNS personnalisé"
348+
"message": "Éditer le serveur DNS personnalisé"
349349
},
350350
"settings_dns_add_custom_server_info": {
351351
"message": "<a>En savoir plus</a> sur les serveurs DNS"
@@ -390,13 +390,13 @@
390390
"message": "AdGuard DNS"
391391
},
392392
"settings_dns_selector_adguard_desc": {
393-
"message": "Supprime les publicités et les pisteurs de votre appareil"
393+
"message": "Supprime les publicités et traqueurs de votre appareil"
394394
},
395395
"settings_dns_selector_adguard_nonfiltering_title": {
396396
"message": "AdGuard DNS sans filtrage"
397397
},
398398
"settings_dns_selector_adguard_nonfiltering_desc": {
399-
"message": "DNS sécurisé sans journalisation des activités (ne filtre pas les publicités et les pisteurs)"
399+
"message": "DNS sécurisé sans journalisation des activités (ne filtre pas les publicités et traqueurs)"
400400
},
401401
"settings_dns_selector_adguard_family_title": {
402402
"message": "AdGuard DNS Protection familiale"

src/_locales/ja/messages.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@
237237
"message": "無料GBをGET!"
238238
},
239239
"settings_referral_info": {
240-
"message": "お友だちをAdGuard VPN部に招待して、無料月間通信量を増やしましょう。お友だちが登録すると、1人につき%your_gb%GBが招待した方にプレゼントされ、さらに、招待されたお友だちにも%friend_gb%GBがプラスされます。"
240+
"message": "お友だちをAdGuard VPN部に招待して、無料月間通信量を増やしましょう。お友だちが登録すると、1人につき%your_gb%GBが招待した方にプレゼントされます(最大%total_gb%まで)。さらに、招待されたお友だちにも%friend_gb%GBがプラスされます。"
241241
},
242242
"settings_referral_invited_friends": {
243243
"message": "招待済みお友だち数: %count%/%limit%"

src/_locales/pl/messages.json

+8
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,14 @@
819819
"popup_upgrade_screen_continue_free": {
820820
"message": "Kontynuuj za darmo"
821821
},
822+
"popup_free_traffic_info_left": {
823+
"message": "Zostało %value% %unit%",
824+
"description": "Respect spaces between text, tags and placeholders"
825+
},
826+
"popup_free_traffic_info_days_left": {
827+
"message": "Ruch odnawia się dzisiaj | Ruch odnawia się za %days% dzień | Ruch odnawia się za %days% dni | Ruch odnawia się za %days% dni",
828+
"description": "Respect spaces between text, tags and placeholders. 40 characters max limit for every plural form"
829+
},
822830
"popup_hint_popup_content": {
823831
"message": "Swoją drogą, możesz wyłączyć VPN dla tej witryny, jeśli chcesz"
824832
},

src/_locales/ru/messages.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@
824824
"description": "Respect spaces between text, tags and placeholders"
825825
},
826826
"popup_free_traffic_info_days_left": {
827-
"message": "Трафик обновится сегодня | Трафик обновится через %days% день | Трафик обновится через %days% дня | Трафик обновится через %count% дней",
827+
"message": "Трафик обновится сегодня | Трафик обновится через %days% день | Трафик обновится через %days% дня | Трафик обновится через %days% дней",
828828
"description": "Respect spaces between text, tags and placeholders. 40 characters max limit for every plural form"
829829
},
830830
"popup_hint_popup_content": {

src/_locales/sk/messages.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@
824824
"description": "Respect spaces between text, tags and placeholders"
825825
},
826826
"popup_free_traffic_info_days_left": {
827-
"message": "Komunikácia bude dnes obnovená | Komunikácia sa obnoví o %days% deň | Komunikácia sa obnoví o %days% dni | Komunikácia sa obnoví o %count% dní",
827+
"message": "Komunikácia bude dnes obnovená | Komunikácia sa obnoví o %days% deň | Komunikácia sa obnoví o %days% dni | Komunikácia sa obnoví o %days% dní",
828828
"description": "Respect spaces between text, tags and placeholders. 40 characters max limit for every plural form"
829829
},
830830
"popup_hint_popup_content": {

src/_locales/sl/messages.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@
824824
"description": "Respect spaces between text, tags and placeholders"
825825
},
826826
"popup_free_traffic_info_days_left": {
827-
"message": "Promet je danes obnovljen | Promet se obnovi čez %days% dan | Promet se obnovi čez %days% dni",
827+
"message": "Promet je danes obnovljen | Promet se obnovi čez %days% dan | Promet se obnovi čez %days% dni | Promet se obnovi čez %days% dni | Promet se obnovi čez %days% dni",
828828
"description": "Respect spaces between text, tags and placeholders. 40 characters max limit for every plural form"
829829
},
830830
"popup_hint_popup_content": {

src/_locales/sr-Latn/messages.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@
669669
"message": "Brzina veze je smanjena"
670670
},
671671
"popup_traffic_limit_exceeded_description": {
672-
"message": "Potrošili ste brze gigabajte :( <br/> Samo su oni spori preostali"
672+
"message": "Ponestalo vam je besplatnog saobraćaja i Adguard VPN je sada spor."
673673
},
674674
"popup_traffic_limit_exceeded_cta_btn": {
675675
"message": "Povećaj brzinu"

src/_locales/sv/messages.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
"message": "FAQ"
6161
},
6262
"options_support_faq_description": {
63-
"message": "Frågor och svar"
63+
"message": "FAQ"
6464
},
6565
"options_support_report_title": {
6666
"message": "Rapportera ett fel"

src/_locales/uk/messages.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -947,4 +947,4 @@
947947
"resend_confirm_registration_link_notification": {
948948
"message": "Посилання для підтвердження надіслано повторно"
949949
}
950-
}
950+
}

tasks/translations/validate.js

+18-3
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,28 @@ const printCriticalResults = (criticals) => {
6666
};
6767

6868
/**
69-
* Validates that localized string correspond by structure to base locale string
69+
* Validates that localized string correspond by structure to base locale string.
70+
*
71+
* @param {string} baseKey Key of the base locale string.
72+
* @param {object} baseLocaleTranslations Translations of the base locale.
73+
* @param {string} locale Locale to validate.
74+
* @param {object} localeTranslations Translations of the locale to validate.
75+
*
76+
* @returns {object} Validation result if error occurred, otherwise undefined.
7077
*/
71-
const validateMessage = (baseKey, baseLocaleTranslations, localeTranslations) => {
78+
const validateMessage = (baseKey, baseLocaleTranslations, locale, localeTranslations) => {
7279
const baseMessageValue = baseLocaleTranslations[baseKey].message;
7380
const localeMessageValue = localeTranslations[baseKey].message;
7481
let validation;
7582
try {
76-
validator.isTranslationValid(baseMessageValue, localeMessageValue);
83+
if (!validator.isTranslationValid(
84+
baseMessageValue,
85+
localeMessageValue,
86+
// locale should be lowercase, e.g. 'pt_br', not 'pt_BR'
87+
locale.toLowerCase(),
88+
)) {
89+
throw new Error('Invalid translation');
90+
}
7791
} catch (error) {
7892
validation = { key: baseKey, error };
7993
}
@@ -115,6 +129,7 @@ export const checkTranslations = async (locales, flags) => {
115129
const validationError = validateMessage(
116130
baseKey,
117131
baseLocaleTranslations,
132+
locale,
118133
localeTranslations,
119134
);
120135
if (validationError) {

yarn.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
# yarn lockfile v1
33

44

5-
"@adguard/translate@^0.3.2":
6-
version "0.3.2"
7-
resolved "https://registry.yarnpkg.com/@adguard/translate/-/translate-0.3.2.tgz#63a204332505a2a419f39ec2c99d2b6636a0d577"
8-
integrity sha512-CLv6MZZPbOEocvNNcKdkDOh/Ue+51jZUiYVClbSDRT7ctXzVL4eqLsUrUtJheQKIDQuBaaboSG9G7IvumLNcWQ==
5+
"@adguard/translate@^1.0.2":
6+
version "1.0.2"
7+
resolved "https://registry.yarnpkg.com/@adguard/translate/-/translate-1.0.2.tgz#e8076902f0950a62d40519d6eb389778516928a0"
8+
integrity sha512-TeQV4ngse/fcpFDCrtU5VqjZfQsdytSuGT8wF4biIM6c6v6W/tkUdrTDhNItq126hAZe65V8QgipTAp8qHdeZw==
99

1010
"@adobe/css-tools@^4.0.1":
1111
version "4.2.0"

0 commit comments

Comments
 (0)