Skip to content

Commit

Permalink
Update localization keys, add validation
Browse files Browse the repository at this point in the history
  • Loading branch information
BPerlakiH authored and kelson42 committed Jan 26, 2025
1 parent 54b6bf9 commit 41fe136
Show file tree
Hide file tree
Showing 40 changed files with 166 additions and 169 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ repos:
hooks:
- id: generate_localizations
name: "Generate localization swift file"
entry: python localizations.py Support/en.lproj/Localizable.strings generate
entry: python localizations.py generate
language: python
always_run: true
stages: [post-checkout, post-merge, post-rewrite]
Expand Down
36 changes: 0 additions & 36 deletions Model/Utilities/String+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,42 +17,6 @@ import Foundation

extension String {

var localized: String {
localizedWithFallback()
}

func localizedWithFormat(withArgs: CVarArg...) -> String {
let format = localizedWithFallback()
switch withArgs.count {
case 1: return String.localizedStringWithFormat(format, withArgs[0])
case 2: return String.localizedStringWithFormat(format, withArgs[0], withArgs[1])
default: return String.localizedStringWithFormat(format, withArgs)
}
}

private func localizedWithFallback(
bundle: Bundle = Bundle.main,
comment: String = ""
) -> String {
let englishValue: String
if let path = Bundle.main.path(forResource: "en", ofType: "lproj"),
let bundle = Bundle(path: path) {
englishValue = NSLocalizedString(self, bundle: bundle, comment: comment)
if NSLocale.preferredLanguages.first == "en" {
return englishValue
}
} else {
englishValue = ""
}
return NSLocalizedString(
self,
tableName: nil,
bundle: bundle,
value: englishValue, // fall back to this, if translation not found
comment: comment
)
}

func removingPrefix(_ value: String) -> String {
guard hasPrefix(value) else { return self }
return String(dropFirst(value.count))
Expand Down
56 changes: 56 additions & 0 deletions Support/StringLocalExtension.swift_temp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// This file is part of Kiwix for iOS & macOS.
//
// Kiwix is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// any later version.
//
// Kiwix is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Kiwix; If not, see https://www.gnu.org/licenses/.

import Foundation

fileprivate extension String {

var localized: String {
localizedWithFallback()
}

func localizedWithFormat(withArgs: CVarArg...) -> String {
let format = localizedWithFallback()
switch withArgs.count {
case 1: return String.localizedStringWithFormat(format, withArgs[0])
case 2: return String.localizedStringWithFormat(format, withArgs[0], withArgs[1])
default: return String.localizedStringWithFormat(format, withArgs)
}
}

private func localizedWithFallback(
bundle: Bundle = Bundle.main,
comment: String = ""
) -> String {
let englishValue: String
if let path = Bundle.main.path(forResource: "en", ofType: "lproj"),
let bundle = Bundle(path: path) {
englishValue = NSLocalizedString(self, bundle: bundle, comment: comment)
if NSLocale.preferredLanguages.first == "en" {
return englishValue
}
} else {
englishValue = ""
}
return NSLocalizedString(
self,
tableName: nil,
bundle: bundle,
value: englishValue, // fall back to this, if translation not found
comment: comment
)
}
}

6 changes: 2 additions & 4 deletions Support/br.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
"common.tab.list.close" = "Serriñ ar steudenn";
"common.tab.menu.library" = "Levraoueg";
"common.tab.menu.settings" = "Arventennoù";
"common.support.app_name" = "Skoazellañ %@";
"common.export_file.alert.title" = "Ezporzhiañ ar restr";
"common.export_file.alert.description" = "Fellout a ra deoc'h ezporzhiañ ar restr %@?";
"common.export_file.alert.button.title" = "Ezporzhiañ";
Expand All @@ -51,7 +50,7 @@
"flavor_tag.help.no_pic" = "lamet eo bet darn vrasañ ar skeudennoù";
"library_refresh_time.last" = "Nevez zo";
"library_refresh_time.never" = "James";
"zim_file_cell_article_count_suffix" = "pennadoù";
"zim_file_cell.article_count.suffix" = "pennadoù";
"zim_file_missing_indicator.help" = "Ar restr ZIM a vank.";
"library.zim_file_context.main_page.label" = "Degemer";
"library.zim_file_context.random.label" = "Pajenn dre zegouezh";
Expand All @@ -65,7 +64,7 @@
"zim_file_category.section.empty.message" = "Restr ZIM ebet er rummad-mañ.";
"zim_file_downloads.toolbar.show_sidebar.label" = "Diskouez ar varrenn-gostez";
"zim_file_new_overlay.empty" = "Restr ZIM nevez ebet";
"zim_file_new_button_refresh" = "Freskaat";
"zim_file_new.button.refresh" = "Freskaat";
"zim_file.list.name.text" = "Anv";
"zim_file.list.description.text" = "Deskrivadur";
"zim_file.list.actions.text" = "Oberoù";
Expand Down Expand Up @@ -144,7 +143,6 @@
"app_macos_commands.open_file" = "Digeriñ...";
"app_macos_commands.new" = "Steudenn nevez";
"app_macos_navigation.button.library" = "Levraoueg";
"app_macos_navigation.show_sidebar" = "Diskouez ar varrenn-gostez";
"sidebar_view.navigation.button.close" = "Serriñ";
"sidebar_view.navigation.button.close_all" = "Serriñ an holl steudennoù";
"enum.category.wikipedia" = "Wikipedia";
Expand Down
4 changes: 2 additions & 2 deletions Support/dag.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"flavor_tag.help.mini" = "Sabbu ŋɔ bela koŋko nyɛ din be ni, di yi pa shɛli tuuli yaɣili";
"library_refresh_time.last" = "Kulla saha ŋɔ";
"library_refresh_time.never" = "Abada";
"zim_file_cell_article_count_suffix" = "Lahabaya";
"zim_file_cell.article_count.suffix" = "Lahabaya";
"zim_file_missing_indicator.help" = "Zim fasara nyɛla din kani.";
// Fuzzy
"library.zim_file_details.side_panel.message" = "Piimi zim fasara n- nya bayana";
Expand All @@ -71,7 +71,7 @@
"zim_file_downloads.overlay.empty.message" = "Deebu tuma nima kani";
"zim_file_downloads.toolbar.show_sidebar.label" = "Wuhimi \"Sidebar\"";
"zim_file_new_overlay.empty" = "Zim fasara palli kani";
"zim_file_new_button_refresh" = "Kahigi";
"zim_file_new.button.refresh" = "Kahigi";
"zim_file.list.name.text" = "Yuli";
"zim_file.list.description.text" = "Buɣisibu";
"zim_file.list.actions.text" = "Niŋsim";
Expand Down
6 changes: 2 additions & 4 deletions Support/de.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"common.tab.list.close" = "Tab schließen";
"common.tab.menu.library" = "Bibliothek";
"common.tab.menu.settings" = "Einstellungen";
"common.support.app_name" = "%@ unterstützen";
"outline_button.outline.title" = "Gliederung";
"outline_button.outline.help" = "Artikelgliederung anzeigen";
"outline_button.outline.empty.message" = "Keine Gliederung vorhanden";
Expand Down Expand Up @@ -62,7 +61,7 @@
"flavor_tag.help.mini" = "Es ist nur ein Teil des Textes verfügbar, wahrscheinlich der erste Abschnitt";
"library_refresh_time.last" = "Soeben";
"library_refresh_time.never" = "Niemals";
"zim_file_cell_article_count_suffix" = "Artikel";
"zim_file_cell.article_count.suffix" = "Artikel";
"zim_file_missing_indicator.help" = "Zim-Datei fehlt.";
"library.zim_file_details.side_panel.message" = "Wähle eine ZIM-Datei aus, um Details zu sehen";
"library.zim_file_context.main_page.label" = "Hauptseite";
Expand All @@ -80,7 +79,7 @@
"zim_file_downloads.toolbar.show_sidebar.label" = "Seitenleiste anzeigen";
// Fuzzy
"zim_file_new_overlay.empty" = "Keine neue ZIM-Datei";
"zim_file_new_button_refresh" = "Aktualisieren";
"zim_file_new.button.refresh" = "Aktualisieren";
"zim_file.list.name.text" = "Name";
"zim_file.list.description.text" = "Beschreibung";
"zim_file.list.actions.text" = "Aktionen";
Expand Down Expand Up @@ -196,7 +195,6 @@
"app_macos_commands.open_file" = "Öffnen…";
"app_macos_commands.new" = "Neuer Tab";
"app_macos_navigation.button.library" = "Bibliothek";
"app_macos_navigation.show_sidebar" = "Seitenleiste anzeigen";
"sidebar_view.navigation.button.close" = "Schließen";
"sidebar_view.navigation.button.close_all" = "Alle Tabs schließen";
"enum.category.wikipedia" = "Wikipedia";
Expand Down
6 changes: 2 additions & 4 deletions Support/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
"common.tab.list.close" = "Close Tab";
"common.tab.menu.library" = "Library";
"common.tab.menu.settings" = "Settings";
"common.support.app_name" = "Support %@";
"common.export_file.alert.title" = "Export file";
"common.export_file.alert.description" = "Do you want to export the file %@?";
"common.export_file.alert.button.title" = "Export";
Expand Down Expand Up @@ -91,7 +90,7 @@
"library_refresh_time.last" = "Just Now";
"library_refresh_time.never" = "Never";

"zim_file_cell_article_count_suffix" = "articles";
"zim_file_cell.article_count.suffix" = "articles";

"zim_file_missing_indicator.help" = "Zim file is missing.";

Expand All @@ -113,7 +112,7 @@
"zim_file_downloads.toolbar.show_sidebar.label" = "Show Sidebar";

"zim_file_new_overlay.empty" = "No new ZIM file";
"zim_file_new_button_refresh" = "Refresh";
"zim_file_new.button.refresh" = "Refresh";

"zim_file.list.name.text" = "Name";
"zim_file.list.description.text" = "Description";
Expand Down Expand Up @@ -234,7 +233,6 @@
"app_macos_commands.open_file" = "Open...";
"app_macos_commands.new" = "New Tab";
"app_macos_navigation.button.library" = "Library";
"app_macos_navigation.show_sidebar" = "Show Sidebar";

"sidebar_view.navigation.button.close_all" = "Close All Tabs";
"sidebar_view.navigation.button.close" = "Close";
Expand Down
6 changes: 2 additions & 4 deletions Support/es.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"common.tab.list.close" = "Cerrar pestaña";
"common.tab.menu.library" = "Biblioteca";
"common.tab.menu.settings" = "Configuración";
"common.support.app_name" = "%@ de apoyo";
"common.export_file.alert.title" = "Exportar archivo";
"common.export_file.alert.description" = "¿Quieres exportar el archivo %@?";
"common.export_file.alert.button.title" = "Exportar";
Expand Down Expand Up @@ -65,7 +64,7 @@
"flavor_tag.help.mini" = "Sólo está disponible un subconjunto del texto, probablemente la primera sección.";
"library_refresh_time.last" = "Ahora mismo";
"library_refresh_time.never" = "Nunca";
"zim_file_cell_article_count_suffix" = "artículos";
"zim_file_cell.article_count.suffix" = "artículos";
"zim_file_missing_indicator.help" = "Falta el archivo Zim.";
"library.zim_file_details.side_panel.message" = "Seleccione un archivo ZIM para ver los detalles";
"library.zim_file_context.main_page.label" = "Página principal";
Expand All @@ -82,7 +81,7 @@
"zim_file_downloads.overlay.empty.message" = "Sin tareas de descarga";
"zim_file_downloads.toolbar.show_sidebar.label" = "Mostrar barra lateral";
"zim_file_new_overlay.empty" = "No hay un nuevo archivo ZIM";
"zim_file_new_button_refresh" = "Actualizar";
"zim_file_new.button.refresh" = "Actualizar";
"zim_file.list.name.text" = "Nombre";
"zim_file.list.description.text" = "Descripción";
"zim_file.list.actions.text" = "Acciones";
Expand Down Expand Up @@ -194,7 +193,6 @@
"app_macos_commands.open_file" = "Abrir...";
"app_macos_commands.new" = "Pestaña nueva";
"app_macos_navigation.button.library" = "Biblioteca";
"app_macos_navigation.show_sidebar" = "Mostrar barra lateral";
"sidebar_view.navigation.button.close" = "Cerrar";
"sidebar_view.navigation.button.close_all" = "Cerrar todas las pestañas";
"enum.category.wikipedia" = "Wikipedia";
Expand Down
4 changes: 1 addition & 3 deletions Support/fi.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"common.tab.list.close" = "Sulje välilehti";
"common.tab.menu.library" = "Kirjasto";
"common.tab.menu.settings" = "Asetukset";
"common.support.app_name" = "Tue %@";
"common.export_file.alert.title" = "Vie tiedosto";
"common.export_file.alert.description" = "Haluatko viedä tiedoston %@?";
"article_shortcut.main.button.title" = "Pääartikkeli";
Expand All @@ -41,7 +40,7 @@
"download_task_cell.status.downloading" = "Ladataan...";
"download_task_cell.status.paused" = "Pysäytetty";
"library_refresh_time.never" = "Ei koskaan";
"zim_file_cell_article_count_suffix" = "artikkelia";
"zim_file_cell.article_count.suffix" = "artikkelia";
"zim_file_missing_indicator.help" = "Zim-tiedosto puuttuu.";
"library.zim_file_context.main_page.label" = "Etusivu";
"library.zim_file_context.random.label" = "Satunnainen sivu";
Expand Down Expand Up @@ -109,7 +108,6 @@
"app_macos_commands.open_file" = "Avaa...";
"app_macos_commands.new" = "Uusi välilehti";
"app_macos_navigation.button.library" = "Kirjasto";
"app_macos_navigation.show_sidebar" = "Näytä sivupalkki";
"sidebar_view.navigation.button.close" = "Sulje";
"sidebar_view.navigation.button.close_all" = "Sulje kaikki välilehdet";
"enum.category.wikibooks" = "Wikikirjasto";
Expand Down
6 changes: 2 additions & 4 deletions Support/fr.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
"common.tab.list.close" = "Fermer l’onglet";
"common.tab.menu.library" = "Bibliothèque";
"common.tab.menu.settings" = "Paramètres";
"common.support.app_name" = "Soutenez-nous %@";
"common.export_file.alert.title" = "Exporter le fichier";
"common.export_file.alert.description" = "Voulez-vous exporter le fichier %@ ?";
"common.export_file.alert.button.title" = "Exporter";
Expand Down Expand Up @@ -75,7 +74,7 @@
"flavor_tag.help.mini" = "seul un sous-ensemble du texte est disponible, probablement la première section";
"library_refresh_time.last" = "À l’instant";
"library_refresh_time.never" = "Jamais";
"zim_file_cell_article_count_suffix" = "articles";
"zim_file_cell.article_count.suffix" = "articles";
"zim_file_missing_indicator.help" = "Le fichier Zim est manquant.";
"library.zim_file_details.side_panel.message" = "Sélectionnez un fichier ZIM pour voir les détails";
"library.zim_file_context.main_page.label" = "Page principale";
Expand All @@ -92,7 +91,7 @@
"zim_file_downloads.overlay.empty.message" = "Aucune tâche de téléchargement";
"zim_file_downloads.toolbar.show_sidebar.label" = "Afficher la barre latérale";
"zim_file_new_overlay.empty" = "Pas de nouveau fichier ZIM";
"zim_file_new_button_refresh" = "Actualiser";
"zim_file_new.button.refresh" = "Actualiser";
"zim_file.list.name.text" = "Nom";
"zim_file.list.description.text" = "Description";
"zim_file.list.actions.text" = "Actions";
Expand Down Expand Up @@ -204,7 +203,6 @@
"app_macos_commands.open_file" = "Ouvrir...";
"app_macos_commands.new" = "Nouvel onglet";
"app_macos_navigation.button.library" = "Bibliothèque";
"app_macos_navigation.show_sidebar" = "Afficher la barre latérale";
"sidebar_view.navigation.button.close" = "Fermer";
"sidebar_view.navigation.button.close_all" = "Fermer tous les onglets";
"enum.category.wikipedia" = "Wikipédia";
Expand Down
5 changes: 2 additions & 3 deletions Support/ha.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"flavor_tag.help.mini" = "Juzu'in rubutu ne kawai yaka samuwa, tayiyu da farkon sashi";
"library_refresh_time.last" = "Yanxu yanxu";
"library_refresh_time.never" = "Ba a taɓa yin hakan ba";
"zim_file_cell_article_count_suffix" = "Makalu";
"zim_file_cell.article_count.suffix" = "Makalu";
"zim_file_missing_indicator.help" = "Fayil ɗin Zim ya ɓace.";
// Fuzzy
"library.zim_file_details.side_panel.message" = "Zabi fayil din zim dan ganin cikakken bayani";
Expand All @@ -78,7 +78,7 @@
"zim_file_downloads.overlay.empty.message" = "Babu ayyukan zazzagewa";
"zim_file_downloads.toolbar.show_sidebar.label" = "Nuna ma'aunin gefe";
"zim_file_new_overlay.empty" = "Babu sabon fayil ɗin Zim";
"zim_file_new_button_refresh" = "Wartsake";
"zim_file_new.button.refresh" = "Wartsake";
"zim_file.list.name.text" = "Suna";
"zim_file.list.description.text" = "Bayani";
"zim_file.list.actions.text" = "Ayyuka";
Expand Down Expand Up @@ -188,7 +188,6 @@
"app_macos_commands.open_file" = "Bude..";
"app_macos_commands.new" = "Sabon shafi";
"app_macos_navigation.button.library" = "Laburare";
"app_macos_navigation.show_sidebar" = "Nuna ma'aunin gefe";
"sidebar_view.navigation.button.close" = "Kulle";
"sidebar_view.navigation.button.close_all" = "Rufe duk shafuka";
"enum.category.wikipedia" = "Wikipedia";
Expand Down
6 changes: 2 additions & 4 deletions Support/he.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
"common.tab.list.close" = "סגירת לשונית";
"common.tab.menu.library" = "ספרייה";
"common.tab.menu.settings" = "הגדרות";
"common.support.app_name" = "תמיכה בפרויקט %@";
"common.export_file.alert.title" = "יצוא קובץ";
"common.export_file.alert.description" = "לייצא את הקובץ %@?";
"common.export_file.alert.button.title" = "יצוא";
Expand Down Expand Up @@ -63,7 +62,7 @@
"flavor_tag.help.mini" = "רק חלק מהטקסט זמין, כנראה הפרק הראשון";
"library_refresh_time.last" = "זה עתה";
"library_refresh_time.never" = "מעולם לא";
"zim_file_cell_article_count_suffix" = "ערכים";
"zim_file_cell.article_count.suffix" = "ערכים";
"zim_file_missing_indicator.help" = "קובץ ה־zim חסר.";
"library.zim_file_details.side_panel.message" = "נא לבחור קובץ ZIM כדי לראות פרטים";
"library.zim_file_context.main_page.label" = "עמוד ראשי";
Expand All @@ -80,7 +79,7 @@
"zim_file_downloads.overlay.empty.message" = "אין משימות הורדה";
"zim_file_downloads.toolbar.show_sidebar.label" = "הצגת סרגל צד";
"zim_file_new_overlay.empty" = "אין קובץ ZIM חדש";
"zim_file_new_button_refresh" = "רענון";
"zim_file_new.button.refresh" = "רענון";
"zim_file.list.name.text" = "שם";
"zim_file.list.description.text" = "תיאור";
"zim_file.list.actions.text" = "פעולות";
Expand Down Expand Up @@ -192,7 +191,6 @@
"app_macos_commands.open_file" = "פתיחה...";
"app_macos_commands.new" = "לשונית חדשה";
"app_macos_navigation.button.library" = "ספרייה";
"app_macos_navigation.show_sidebar" = "הצגת סרגל צד";
"sidebar_view.navigation.button.close" = "סגירה";
"sidebar_view.navigation.button.close_all" = "סגירת כל הלשוניות";
"enum.category.wikipedia" = "ויקיפדיה";
Expand Down
2 changes: 1 addition & 1 deletion Support/hi.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"library.zim_file_context.main_page.label" = "मुखपृष्ठ";
"zim_file_opened.toolbar.open.title" = "खोलें...";
"zim_file_category.title" = "श्रेणी";
"zim_file_new_button_refresh" = "ताजा करें";
"zim_file_new.button.refresh" = "ताजा करें";
"zim_file.list.name.text" = "नाम";
"zim_file.list.description.text" = "विवरण";
"zim_file.list.actions.text" = "क्रियाएँ";
Expand Down
Loading

0 comments on commit 41fe136

Please sign in to comment.