1
0
Fork 1
mirror of https://github.com/elk-zone/elk.git synced 2024-11-05 16:39:58 +00:00

chore: add a script to cleanup old translations (#1963)

This commit is contained in:
Ivan Demchuk 2023-04-16 15:28:45 +03:00 committed by GitHub
parent dac044e6ad
commit 2267556b8b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 68 additions and 91 deletions

View file

@ -91,11 +91,6 @@
"toggle_zen_mode": "تبديل الوضع الهادئ"
},
"common": {
"confirm_dialog": {
"cancel": "لا",
"confirm": "نعم",
"title": "هل أنت متأكد؟"
},
"end_of_list": "نهاية القائمة",
"error": "حدث خطأ",
"in": "في",
@ -191,11 +186,6 @@
"copy_original_link_to_post": "انسخ الرابط الأصلي لهذا المنشور",
"delete": "حذف",
"delete_and_redraft": "حذف وإعادة صياغة",
"delete_confirm": {
"cancel": "إلغاء",
"confirm": "حذف",
"title": "هل أنت متأكد أنك تريد حذف هذا المنشور؟"
},
"direct_message_account": "إرسال رسالة مباشرة إلى {0}",
"edit": "تعديل",
"hide_reblogs": "إخفاء المشاركات من {0}",
@ -314,12 +304,6 @@
"description": "قم بتحرير إعدادات حسابك في موقع ماستودون الأصل",
"label": "إعدادت الحساب"
},
"feature_flags": {
"github_cards": "بطاقات GitHub",
"title": "الميزات التجريبية",
"user_picker": "الشريط الجانبي لمبدل المستخدم",
"virtual_scroll": "التمرير الافتراضي"
},
"interface": {
"color_mode": "وضع اللون",
"dark_mode": "الوضع الداكن",

View file

@ -54,7 +54,6 @@
"not_found": "404 No s'ha trobat",
"offline_desc": "Sembla que estàs fora de línia. Comprova la connexió de xarxa."
},
"compose": {},
"confirm": {
"block_account": {
"cancel": "Cancel·la",
@ -91,7 +90,6 @@
"title": "Segur que vols deixar de seguir-lo?"
}
},
"conversation": {},
"custom_cards": {
"stackblitz": {
"open": "Obri",
@ -119,7 +117,6 @@
"footer_team": "L'equip d'Elk",
"title": "Elk està en proves!"
},
"language": {},
"list": {
"add_account": "Afig el compte a una llista",
"create": "Crea",

View file

@ -142,13 +142,6 @@
"replying": "Sem napište odpověď",
"the_thread": "vlákno"
},
"settings": {
"feature_flags": {
"github_cards": "GitHub Cards",
"user_picker": "User Picker",
"virtual_scroll": "Virtual Scrolling"
}
},
"state": {
"edited": "(Upraveno)",
"editing": "Upravuje se",

View file

@ -28,7 +28,6 @@
"muted_users": "Stummgeschaltete Accounts",
"muting": "Stummgeschaltet",
"mutuals": "Freunde",
"notify_on_post": "Benachrichtige mich, wenn {username} etwas postet",
"pinned": "Angepinnt",
"posts": "Beiträge",
"posts_count": "{0} Beiträge",
@ -102,8 +101,7 @@
"confirm": {
"common": {
"cancel": "Abbrechen",
"confirm": "OK",
"title": "Bist du sicher, {0}?"
"confirm": "OK"
},
"delete_posts": {
"cancel": "Abbrechen",
@ -256,12 +254,6 @@
"description": "Bearbeite Kontoeinstellungen in der Mastodon-Benutzeroberfläche",
"label": "Account Einstellungen"
},
"feature_flags": {
"github_cards": "GitHub Cards",
"title": "Experimentelle Funktionen",
"user_picker": "Benutzerauswahl",
"virtual_scroll": "Virtuelles Scrollen"
},
"interface": {
"color_mode": "Farbschema",
"dark_mode": "Dunkles Farbschema",

View file

@ -295,13 +295,6 @@
"font_size": "Kirjasinkoko",
"label": "Käyttöliittymä",
"light_mode": "Vaalea",
"size_label": {
"lg": "Suuri",
"md": "Keski",
"sm": "Pieni",
"xl": "Ekstra-suuri",
"xs": "Ekstra-pieni"
},
"system_mode": "Laitteen asetus",
"theme_color": "Korostusväri"
},

View file

@ -30,7 +30,6 @@
"mutuals": "Terkait",
"notifications_on_post_disable": "Berhenti memberi tahu saya saat {username} memposting",
"notifications_on_post_enable": "Beri tahu saya jika {username} memposting",
"notify_on_post": "Beri tahu saya jika {username} memposting",
"pinned": "Dilekatkan",
"posts": "Posting",
"posts_count": "{0} Pos|{0} Pos|{0} Pos",
@ -92,11 +91,6 @@
"toggle_zen_mode": "Beralih ke modus zen"
},
"common": {
"confirm_dialog": {
"cancel": "Tidak",
"confirm": "Ya",
"title": "Apakah Anda yakin {0}?"
},
"end_of_list": "Akhir dari daftar",
"error": "KESALAHAN",
"in": "di dalam",
@ -180,11 +174,6 @@
"copy_link_to_post": "Salin tautan pos ini",
"delete": "Hapus",
"delete_and_redraft": "Hapus dan buat ulang draf",
"delete_confirm": {
"cancel": "Batalkan",
"confirm": "Hapus",
"title": "Yakin ingin menghapus postingan ini?"
},
"direct_message_account": "Pesan langsung {0}",
"edit": "Sunting",
"hide_reblogs": "Sembunyikan dukungan dari {0}",

View file

@ -193,12 +193,6 @@
"about": {
"label": "Over"
},
"feature_flags": {
"github_cards": "GitHub Cards",
"title": "Experimentele Functies",
"user_picker": "Gebruiker Kiezer",
"virtual_scroll": "Virtueel Scrollen"
},
"interface": {
"color_mode": "Kleur Modus",
"dark_mode": "Donkere Modus",
@ -284,7 +278,6 @@
}
},
"state": {
"attachments_exceed_server_limit": "De hoeveelheid bijlagen is meer dan het limiet per post.",
"attachments_limit_error": "Limiet per post overschreden",
"edited": "(Aangepast)",

View file

@ -59,7 +59,6 @@
"more": "Больше",
"next": "Следующее",
"prev": "Предыдущее",
"previous": "Предыдущее",
"publish": "Опубликовать",
"reply": "Ответить",
"reply_count": "{0}",
@ -90,11 +89,6 @@
"toggle_zen_mode": "Переключить режим дзен"
},
"common": {
"confirm_dialog": {
"cancel": "Нет",
"confirm": "Да",
"title": "Вы уверены?"
},
"end_of_list": "Конец списка",
"error": "ОШИБКА",
"in": "в",
@ -171,11 +165,6 @@
"copy_link_to_post": "Скопировать ссылку на этот пост",
"delete": "Удалить",
"delete_and_redraft": "Удалить и переписать",
"delete_confirm": {
"cancel": "Отменить",
"confirm": "Удалить",
"title": "Вы уверены, что хотите удалить этот пост?"
},
"direct_message_account": "Отправьте личное сообщение {0}",
"edit": "Редактировать",
"hide_reblogs": "Скрыть репосты от {0}",
@ -295,13 +284,6 @@
"font_size": "Размер текста",
"label": "Интерфейс",
"light_mode": "Светлая",
"size_label": {
"lg": "Большой",
"md": "Средний",
"sm": "Маленький",
"xl": "Очень большой",
"xs": "Очень маленький"
},
"system_mode": "Системная",
"theme_color": "Цвет"
},

View file

@ -99,8 +99,7 @@
"confirm": {
"common": {
"cancel": "Hayır",
"confirm": "Evet",
"title": "Emin misiniz?"
"confirm": "Evet"
},
"delete_posts": {
"cancel": "İptal et",

View file

@ -216,10 +216,6 @@
"description": "Відредагуйте налаштування облікового запису використовуєчи інтерфейс Mastodon",
"label": "Налаштування облікового запису"
},
"feature_flags": {
"github_cards": "GitHub картки",
"title": "Експериментальні налаштування"
},
"interface": {
"color_mode": "Кольорова тема",
"dark_mode": "Темна",

View file

@ -30,7 +30,6 @@
"mutuals": "互相關注",
"notifications_on_post_disable": "當 {username} 發布時,停止通知我",
"notifications_on_post_enable": "當 {username} 發布時,通知我",
"notify_on_post": "{username} 發文時通知我",
"pinned": "置頂的貼文",
"posts": "貼文",
"posts_count": "{0} 則貼文",
@ -63,7 +62,6 @@
"more": "更多",
"next": "下一個",
"prev": "上一個",
"previous": "之前的",
"publish": "發布",
"reply": "回覆",
"reply_count": "{0}",
@ -94,11 +92,6 @@
"toggle_zen_mode": "切換禪模式"
},
"common": {
"confirm_dialog": {
"cancel": "取消",
"confirm": "確認",
"title": "你確定嗎?"
},
"end_of_list": "清單到底了",
"error": "錯誤",
"in": "在",

View file

@ -23,6 +23,7 @@
"test:typecheck": "stale-dep && vue-tsc --noEmit && vue-tsc --noEmit --project service-worker/tsconfig.json",
"test": "nr test:unit",
"update:team:avatars": "esno scripts/avatars.ts",
"cleanup-translations": "esno scripts/cleanup-translations.ts",
"prepare-translation-status": "esno scripts/prepare-translation-status.ts",
"postinstall": "ignore-dependency-scripts \"stale-dep -u && simple-git-hooks && nuxi prepare && nr prepare-translation-status\"",
"release": "stale-dep && bumpp && esno scripts/release.ts"

View file

@ -0,0 +1,65 @@
import flatten from 'flat'
import { createResolver } from '@nuxt/kit'
import fs from 'fs-extra'
import { currentLocales } from '../config/i18n'
const resolver = createResolver(import.meta.url)
const sourceLanguageLocale = currentLocales.find(l => l.code === 'en-US')!
function merge(src: Record<string, any>, dst: Record<string, any>) {
for (const key in src) {
if (typeof src[key] === 'object') {
if (!dst[key])
dst[key] = {}
merge(src[key], dst[key])
}
else {
dst[key] = src[key]
}
}
}
const sourceFiles: string[] = sourceLanguageLocale.files ? sourceLanguageLocale.files : [sourceLanguageLocale.file!]
const sourceTranslations: Record<string, string> = {}
for (const file of sourceFiles) {
const data = JSON.parse(Buffer.from(
await fs.readFile(resolver.resolve(`../locales/${file}`), 'utf-8'),
).toString()) as Record<string, unknown>
merge(flatten(data), sourceTranslations)
}
async function removeOutdatedTranslations() {
for (const locale of currentLocales.filter(l => l.code !== 'en-US')) {
const files: string[] = locale.files ? locale.files : [locale.file!]
for (const file of files) {
const path = resolver.resolve(`../locales/${file}`)
const data = JSON.parse(Buffer.from(
await fs.readFile(path, 'utf-8'),
).toString())
const targetTranslations: Record<string, string> = flatten(data)
for (const key in targetTranslations) {
if (!sourceTranslations[key])
delete targetTranslations[key]
}
const unflattened = flatten.unflatten(targetTranslations)
await fs.writeFile(
path,
`${JSON.stringify(unflattened, null, 2)}\n`,
{ encoding: 'utf-8' },
)
}
}
}
removeOutdatedTranslations()