diff --git a/azote/langs/de_DE.json b/azote/langs/de_DE.json new file mode 100644 index 0000000..955fc9f --- /dev/null +++ b/azote/langs/de_DE.json @@ -0,0 +1,65 @@ +{ + "about_azote": "Über azote", + "app_desc": "Bildschirmhintergrund & Color-Manager für Sway, i3 und andere Window Manager", + "apply_settings": "Auf {} anwenden", + "apply_to_all": "Auf allen Bildschirmen anwenden", + "background_color": "Hintergrundfarbe", + "cancel": "Abbrechen", + "check_log": "Überprüfen Sie {}", + "clear_unused_thumbnails": "Unbenutzte Thumbnails löschen", + "clipboard_empty": "Zwischenablage leer", + "close": "Schließen", + "closest": "Am nächsten: {}", + "color_dictionary": "Farbauswahl", + "colors": "Farben", + "copied": "Kopiert", + "copy": "Kopieren", + "copy_as": "Kopieren als:", + "copy_paste_into": "Kopieren & Einfügen in {}", + "create_palette": "Farbpalette erstellen", + "current": "Aktuell", + "custom_display": "Benutzerdefinierter Bildschirm", + "delete": "Löschen", + "display_mode": "Anzeigemodus", + "dotfiles": ".dotfiles", + "dual_height": "dreifache Höhe", + "dual_width": "dreifache Breite", + "triple_height": "triple height", + "triple_width": "triple width", + "exact": "Exakt: {}", + "exit": "Beenden", + "flip_image": "Bild spiegeln", + "flip_wallpaper_horizontally": "Bild horizontal spiegeln", + "grim_slurp_required": "grim, slurp & imagemagick-Pakete erforderlich", + "height": "Höhe", + "image_menu_button": "Bildmenütaste", + "include_when_splitting": "beim Teilen einschließen", + "maim_slop_required": "maim & slop-Pakete erforderlich", + "move": "In den Papierkorb verschieben", + "move_to_trash": "Auswahl in den Papierkorb verschieben", + "name": "Name", + "no_colour_definitions": "Keine Farbdefinitionen in {}", + "no_picture_selected": "Kein Bild ausgewählt", + "ok": "OK", + "open_another_folder": "Anderen Ordner öffnen", + "open_folder": "Ordner öffnen", + "open_with": "Mit {} öffnen", + "preferences": "Einstellungen", + "refresh_folder_preview": "Ordnervorschau aktualisieren", + "reload": "Neu laden", + "remove_image": "Bild entfernen", + "scale_and_crop": "Skalieren und Zuschneiden", + "screen_color_picker": "Bildschirm-Farbwähler", + "set_selected_wallpaper": "Ausgewählten Hintergrund verwenden", + "sorting_order": "Sortierreihenfolge", + "sorting_az": "Alphabetisch", + "sorting_za": "Alphabetisch, umgekehrt", + "sorting_new": "Alter, aufsteigend", + "sorting_old": "Alter, absteigend", + "split_selection_between_displays": "Auswahl zwischen Bildschirmen aufteilen", + "thumbnail_tooltip": "Einfach-Klicken zum Auswählen, Doppel-Klicken zum sofortigen Verwenden, Rechts-Klick für mehr Optionen", + "thumbnails_in_cache": "{} Vorschaubilder im Zwischenspeicher ({})", + "track_file_changes": "Dateiänderungen überwachen", + "use_display_names": "Verwend generische Anzeigenamen", + "width": "Breite" +} \ No newline at end of file diff --git a/azote/langs/en_US.json b/azote/langs/en_US.json new file mode 100644 index 0000000..203b391 --- /dev/null +++ b/azote/langs/en_US.json @@ -0,0 +1,65 @@ +{ + "about_azote": "About Azote", + "app_desc": "Wallpaper & color manager for Sway, i3 and WMs", + "apply_settings": "Apply to: {}", + "apply_to_all": "Apply selected picture to all screens", + "background_color": "Background color", + "cancel": "Cancel", + "check_log": "Check {}", + "clear_unused_thumbnails": "Clear unused thumbnails", + "clipboard_empty": "Clipboard empty", + "close": "Close", + "closest": "Closest: {}", + "color_dictionary": "Color dictionary", + "colors": "colors", + "copied": "Copied", + "copy": "Copy", + "copy_as": "Copy as:", + "copy_paste_into": "Copy & paste into {}", + "create_palette": "Create palette", + "current": "Current", + "custom_display": "Custom display", + "delete": "Delete", + "display_mode": "Display mode", + "dotfiles": ".dotfiles", + "dual_height": "dual height", + "dual_width": "dual width", + "triple_height": "triple height", + "triple_width": "triple width", + "exact": "Exact: {}", + "exit": "Exit", + "flip_image": "Flip image", + "flip_wallpaper_horizontally": "Flip wallpaper horizontally", + "grim_slurp_required": "grim, slurp & imagemagick packages required", + "height": "Height", + "image_menu_button": "Image menu button", + "include_when_splitting": "Include when splitting", + "maim_slop_required": "maim & slop packages required", + "move": "To trash", + "move_to_trash": "Move selected to trash", + "name": "Name", + "no_colour_definitions": "No colour definitions in {}", + "no_picture_selected": "No picture selected", + "ok": "OK", + "open_another_folder": "Open another folder", + "open_folder": "Open folder", + "open_with": "Open with {}", + "preferences": "Preferences", + "refresh_folder_preview": "Refresh folder preview", + "reload": "Reload", + "remove_image": "Remove image", + "scale_and_crop": "Scale and crop", + "screen_color_picker": "Screen color picker", + "set_selected_wallpaper": "Set selected wallpaper", + "sorting_order": "Sorting order", + "sorting_az": "A -> Z", + "sorting_za": "Z -> A", + "sorting_new": "New on top", + "sorting_old": "Old on top", + "split_selection_between_displays": "Split selection between displays", + "thumbnail_tooltip": "Click to select, double to set, right for menu", + "thumbnails_in_cache": "{} thumbnails in cache ({})", + "track_file_changes": "Track file changes", + "use_display_names": "Use generic display names", + "width": "Width" +} \ No newline at end of file diff --git a/azote/langs/fr_FR.json b/azote/langs/fr_FR.json new file mode 100644 index 0000000..e28ba06 --- /dev/null +++ b/azote/langs/fr_FR.json @@ -0,0 +1,65 @@ +{ + "about_azote": "À propos d’Azote", + "app_desc": "Gestionnaire de fonds d’écran & couleurs pour Sway, i3 et d’autres gestionnaires de fenêtres", + "apply_settings": "Appliquer à: {}", + "apply_to_all": "Appliquer l'image sélectionnée à tous les écrans", + "background_color": "Couleur de fonds", + "cancel": "Annuler", + "check_log": "Vérifier {}", + "clear_unused_thumbnails": "Effacer les vignettes inutilisées", + "clipboard_empty": "Presse-papiers vide", + "close": "Fermer", + "closest": "Le plus proche: {}", + "color_dictionary": "Dictionnaire de couleur", + "colors": "couleurs", + "copied": "Copié", + "copy": "Copier", + "copy_as": "Copier en tant que:", + "copy_paste_into": "Copier et coller dans {}", + "create_palette": "Créer une palette", + "current": "Actuel", + "custom_display": "Écran personnalisé", + "delete": "Effacer", + "display_mode": "Mode d’affichage", + "dotfiles": ".dotfiles", + "dual_height": "triple hauteur", + "dual_width": "triple largeur", + "triple_height": "triple height", + "triple_width": "triple width", + "exact": "Exact: {}", + "exit": "Terminer", + "flip_image": "Retourner l’image", + "flip_wallpaper_horizontally": "Retourner le fond d’écran horizontalement", + "grim_slurp_required": "paquets grim, slurp et imagemagick requis", + "height": "La taille", + "image_menu_button": "Bouton de menu Image", + "include_when_splitting": "inclure lors du fractionnement", + "maim_slop_required": "paquets maim et slop requis", + "move": "Vers la corbeille", + "move_to_trash": "Déplacer la sélection vers la corbeille", + "name": "Nom", + "no_colour_definitions": "Aucune définition de couleur dans {}", + "no_picture_selected": "Aucune image sélectionnée", + "ok": "OK", + "open_another_folder": "Ouvrir un autre dossier", + "open_folder": "Ouvrir le dossier", + "open_with": "Ovrir avec {}", + "preferences": "Préférences", + "refresh_folder_preview": "Rafraîchir l'aperçu du dossier", + "reload": "Recharger", + "remove_image": "Enlever l'image", + "scale_and_crop": "Échelle et recadrer", + "screen_color_picker": "Sélecteur de couleur d'écran", + "set_selected_wallpaper": "Définir le fond d'écran sélectionné", + "sorting_order": "Ordre de tri", + "sorting_az": "A -> Z", + "sorting_za": "Z -> A", + "sorting_new": "Nouveau en haut", + "sorting_old": "Ancien en haut", + "split_selection_between_displays": "Répartition de la sélection entre les écrans", + "thumbnail_tooltip": "Click to select, double to set, right for menu", + "thumbnails_in_cache": "{} miniatures en cache ({})", + "track_file_changes": "Suivre les modifications du fichier", + "use_display_names": "Utiliser des noms d'affichage génériques", + "width": "Largeur" +} \ No newline at end of file diff --git a/azote/langs/pl_PL.json b/azote/langs/pl_PL.json new file mode 100644 index 0000000..1acd57b --- /dev/null +++ b/azote/langs/pl_PL.json @@ -0,0 +1,65 @@ +{ + "about_azote": "O programie Azote", + "app_desc": "Menedżer tapet i kolorów dla Sway, i3 i innych menedżerów okien", + "apply_settings": "Zastosuj do: {}", + "apply_to_all": "Zastosuj wybrany obraz do wszystkich ekranów", + "background_color": "Kolor tła", + "cancel": "Anuluj", + "check_log": "Sprawdź {}", + "clear_unused_thumbnails": "Usuń nieużywane miniatury", + "clipboard_empty": "Schowek pusty", + "close": "Zamknij", + "closest": "Najbliższy: {}", + "color_dictionary": "Słownik kolorów", + "colors": "kolorów", + "copied": "Skopiowano", + "copy": "Kopiuj", + "copy_as": "Kopiuj jako:", + "copy_paste_into": "Skopiuj i wklej do {}", + "create_palette": "Utwórz paletę", + "current": "Aktualny", + "custom_display": "Niestandardowy ekran", + "delete": "Usuń", + "display_mode": "Tryb wyświetlania", + "dotfiles": ".dotfiles", + "dual_height": "podwójna wysokość", + "dual_width": "podwójna szerokość", + "triple_height": "potrójna wysokość", + "triple_width": "potrójna szerokość", + "exact": "Dokładny: {}", + "exit": "Zakończ", + "flip_image": "Odwróć obraz", + "flip_wallpaper_horizontally": "Odwróć tapetę w poziomie", + "grim_slurp_required": "Wymagane paczki grim, slurp i imagemagick", + "height": "Wysokość", + "image_menu_button": "Przycisk menu obrazu", + "include_when_splitting": "Uwzględniaj przy podziale", + "maim_slop_required": "Wymagane paczki maim & slop", + "move": "Do kosza", + "move_to_trash": "Przenieś wybrany do kosza", + "name": "Nazwa", + "no_colour_definitions": "Brak definicji kolorów w {}", + "no_picture_selected": "Nie wybrano obrazu", + "ok": "OK", + "open_another_folder": "Wybierz inny folder", + "open_folder": "Otwórz folder", + "open_with": "Otwórz w {}", + "preferences": "Preferencje", + "refresh_folder_preview": "Odśwież podgląd folderu", + "reload": "Wczytaj ponownie", + "remove_image": "Usuń obraz", + "scale_and_crop": "Skaluj i przytnij", + "screen_color_picker": "Próbnik kolorów ekranu", + "set_selected_wallpaper": "Ustaw wybraną tapetę", + "sorting_order": "Sortowanie", + "sorting_az": "A -> Z", + "sorting_za": "Z -> A", + "sorting_new": "Od najnowszych", + "sorting_old": "Od najstarszych", + "split_selection_between_displays": "Podziel wybrany obraz pomiędzy ekrany", + "thumbnail_tooltip": "Kliknij by wybrać, podwójnie by ustawić, prawym dla menu", + "thumbnails_in_cache": "{} miniatur w cache ({})", + "track_file_changes": "Śledź zmiany w plikach", + "use_display_names": "Używaj ogólnych nazw wyświetlaczy", + "width": "Szerokość" +} \ No newline at end of file diff --git a/azote/languages/README.md b/azote/languages/README.md deleted file mode 100644 index 524415e..0000000 --- a/azote/languages/README.md +++ /dev/null @@ -1,26 +0,0 @@ -# How to contribute? - -**Azote** uses simple text files to store language strings. If you'd like to see the UI in your own language, first -check what python `locale` module returns for you: - -```text -$ python3 -Python 3.7.3 (default, Mar 26 2019, 21:43:19) -[GCC 8.2.1 20181127] on linux -Type "help", "copyright", "credits" or "license" for more information. ->>> import locale ->>> locale.getlocale() -('pl_PL', 'UTF-8') ->>> -``` - -Use the first element of returned tuple as the file name (as `pl_PL` for Polish). Copy the `en_EN` file, edit translations -and save under the name you determined. Fork the repository, add your file and make a pull request. - -To force use of a certain language (if available), use the `lang` argument: - -```bash -azote lang pl_PL -``` - --> starts Azote in Polish. \ No newline at end of file diff --git a/azote/languages/de_DE b/azote/languages/de_DE deleted file mode 100644 index 21f0346..0000000 --- a/azote/languages/de_DE +++ /dev/null @@ -1,65 +0,0 @@ -# Beim Erstellen einer Übersetzung, bitte die ‘{}’ unverändert belassen! -# '=' ist ein Separator, der nicht in Strings verwendet werden kann. - -about_azote = Über azote -app_desc = Bildschirmhintergrund & Color-Manager für Sway, i3 und andere Window Manager -apply_settings = Auf {} anwenden -apply_to_all = Auf allen Bildschirmen anwenden -background_color = Hintergrundfarbe -cancel = Abbrechen -check_log = Überprüfen Sie {} -clear_unused_thumbnails = Unbenutzte Thumbnails löschen -clipboard_empty = Zwischenablage leer -close = Schließen -closest = Am nächsten: {} -color_dictionary = Farbauswahl -colors = Farben -copied = Kopiert -copy = Kopieren -copy_as = Kopieren als: -copy_paste_into = Kopieren & Einfügen in {} -create_palette = Farbpalette erstellen -current = Aktuell -custom_display = Benutzerdefinierter Bildschirm -delete = Löschen -display_mode = Anzeigemodus -dual_height = doppelte Höhe -dual_width = doppelte Breite -dual_height = dreifache Höhe -dual_width = dreifache Breite -exact = Exakt: {} -exit= Beenden -flip_image = Bild spiegeln -flip_wallpaper_horizontally = Bild horizontal spiegeln -grim_slurp_required = grim, slurp & imagemagick-Pakete erforderlich -height = Höhe -image_menu_button = Bildmenütaste -include_when_splitting = beim Teilen einschließen -maim_slop_required = maim & slop-Pakete erforderlich -move = In den Papierkorb verschieben -move_to_trash = Auswahl in den Papierkorb verschieben -name = Name -no_colour_definitions = Keine Farbdefinitionen in {} -no_picture_selected = Kein Bild ausgewählt -ok = OK -open_another_folder = Anderen Ordner öffnen -open_folder = Ordner öffnen -open_with = Mit {} öffnen -preferences = Einstellungen -refresh_folder_preview = Ordnervorschau aktualisieren -reload = Neu laden -remove_image = Bild entfernen -scale_and_crop = Skalieren und Zuschneiden -screen_color_picker = Bildschirm-Farbwähler -set_selected_wallpaper = Ausgewählten Hintergrund verwenden -sorting_order = Sortierreihenfolge -sorting_az = Alphabetisch -sorting_za = Alphabetisch, umgekehrt -sorting_new = Alter, aufsteigend -sorting_old = Alter, absteigend -split_selection_between_displays = Auswahl zwischen Bildschirmen aufteilen -thumbnail_tooltip = Einfach-Klicken zum Auswählen, Doppel-Klicken zum sofortigen Verwenden, Rechts-Klick für mehr Optionen -thumbnails_in_cache = {} Vorschaubilder im Zwischenspeicher ({}) -track_file_changes = Dateiänderungen überwachen -use_display_names = Verwend generische Anzeigenamen -width = Breite diff --git a/azote/languages/en_EN b/azote/languages/en_EN deleted file mode 100644 index 01251bb..0000000 --- a/azote/languages/en_EN +++ /dev/null @@ -1,66 +0,0 @@ -# While adding own translation, leave all '{}' untouched! -# As '=' is a separator, don't use it inside strings - -about_azote = About Azote -app_desc = Wallpaper & color manager for Sway, i3 and WMs -apply_settings = Apply to: {} -apply_to_all = Apply selected picture to all screens -background_color = Background color -cancel = Cancel -check_log = Check {} -clear_unused_thumbnails = Clear unused thumbnails -clipboard_empty = Clipboard empty -close = Close -closest = Closest: {} -color_dictionary = Color dictionary -colors = colors -copied = Copied -copy = Copy -copy_as = Copy as: -copy_paste_into = Copy & paste into {} -create_palette = Create palette -current = Current -custom_display = Custom display -delete = Delete -display_mode = Display mode -dotfiles = .dotfiles -dual_height = dual height -dual_width = dual width -triple_height = triple height -triple_width = triple width -exact = Exact: {} -exit = Exit -flip_image = Flip image -flip_wallpaper_horizontally = Flip wallpaper horizontally -grim_slurp_required = grim, slurp & imagemagick packages required -height = Height -image_menu_button = Image menu button -include_when_splitting = Include when splitting -maim_slop_required = maim & slop packages required -move = To trash -move_to_trash = Move selected to trash -name = Name -no_colour_definitions = No colour definitions in {} -no_picture_selected = No picture selected -ok = OK -open_another_folder = Open another folder -open_folder = Open folder -open_with = Open with {} -preferences = Preferences -refresh_folder_preview = Refresh folder preview -reload = Reload -remove_image = Remove image -scale_and_crop = Scale and crop -screen_color_picker = Screen color picker -set_selected_wallpaper = Set selected wallpaper -sorting_order = Sorting order -sorting_az = A -> Z -sorting_za = Z -> A -sorting_new = New on top -sorting_old = Old on top -split_selection_between_displays = Split selection between displays -thumbnail_tooltip = Click to select, double to set, right for menu -thumbnails_in_cache = {} thumbnails in cache ({}) -track_file_changes = Track file changes -use_display_names = Use generic display names -width = Width \ No newline at end of file diff --git a/azote/languages/fr_FR b/azote/languages/fr_FR deleted file mode 100644 index d03d1e0..0000000 --- a/azote/languages/fr_FR +++ /dev/null @@ -1,65 +0,0 @@ -# While adding own translation, leave all '{}' untouched! -# As '=' is a separator, don't use it inside strings - -about_azote = À propos d’Azote -app_desc = Gestionnaire de fonds d’écran & couleurs pour Sway, i3 et d’autres gestionnaires de fenêtres -apply_settings = Appliquer à: {} -apply_to_all = Appliquer l'image sélectionnée à tous les écrans -background_color = Couleur de fonds -cancel = Annuler -check_log = Vérifier {} -clear_unused_thumbnails = Effacer les vignettes inutilisées -clipboard_empty = Presse-papiers vide -close = Fermer -closest = Le plus proche: {} -color_dictionary = Dictionnaire de couleur -colors = couleurs -copied = Copié -copy = Copier -copy_as = Copier en tant que: -copy_paste_into = Copier et coller dans {} -create_palette = Créer une palette -current = Actuel -custom_display = Écran personnalisé -delete = Effacer -display_mode = Mode d’affichage -dual_height = double hauteur -dual_width = double largeur -dual_height = triple hauteur -dual_width = triple largeur -exact = Exact: {} -exit= Terminer -flip_image = Retourner l’image -flip_wallpaper_horizontally = Retourner le fond d’écran horizontalement -grim_slurp_required = paquets grim, slurp et imagemagick requis -height = La taille -image_menu_button = Bouton de menu Image -include_when_splitting = inclure lors du fractionnement -maim_slop_required = paquets maim et slop requis -move = Vers la corbeille -move_to_trash = Déplacer la sélection vers la corbeille -name = Nom -no_colour_definitions = Aucune définition de couleur dans {} -no_picture_selected = Aucune image sélectionnée -ok = OK -open_another_folder = Ouvrir un autre dossier -open_folder = Ouvrir le dossier -open_with = Ovrir avec {} -preferences = Préférences -refresh_folder_preview = Rafraîchir l'aperçu du dossier -reload = Recharger -remove_image = Enlever l'image -scale_and_crop = Échelle et recadrer -screen_color_picker = Sélecteur de couleur d'écran -set_selected_wallpaper = Définir le fond d'écran sélectionné -sorting_order = Ordre de tri -sorting_az = A -> Z -sorting_za = Z -> A -sorting_new = Nouveau en haut -sorting_old = Ancien en haut -split_selection_between_displays = Répartition de la sélection entre les écrans -thumbnail_tooltip = Click to select, double to set, right for menu -thumbnails_in_cache = {} miniatures en cache ({}) -track_file_changes = Suivre les modifications du fichier -use_display_names = Utiliser des noms d'affichage génériques -width = Largeur \ No newline at end of file diff --git a/azote/languages/pl_PL b/azote/languages/pl_PL deleted file mode 100644 index 80eff08..0000000 --- a/azote/languages/pl_PL +++ /dev/null @@ -1,65 +0,0 @@ -# While adding own translation, leave all '{}' untouched! -# As '=' is a separator, don't use it inside strings - -about_azote = O programie Azote -app_desc = Menedżer tapet i kolorów dla Sway, i3 i innych menedżerów okien -apply_settings = Zastosuj do: {} -apply_to_all = Zastosuj wybrany obraz do wszystkich ekranów -background_color = Kolor tła -cancel = Anuluj -check_log = Sprawdź {} -clear_unused_thumbnails = Usuń nieużywane miniatury -clipboard_empty = Schowek pusty -close = Zamknij -closest = Najbliższy: {} -color_dictionary = Słownik kolorów -colors = kolorów -copied = Skopiowano -copy = Kopiuj -copy_as = Kopiuj jako: -copy_paste_into = Skopiuj i wklej do {} -create_palette = Utwórz paletę -current = Aktualny -custom_display = Niestandardowy ekran -delete = Usuń -display_mode = Tryb wyświetlania -dual_height = podwójna wysokość -dual_width = podwójna szerokość -triple_height = potrójna wysokość -triple_width = potrójna szerokość -exact = Dokładny: {} -exit = Zakończ -flip_image = Odwróć obraz -flip_wallpaper_horizontally = Odwróć tapetę w poziomie -grim_slurp_required = Wymagane paczki grim, slurp i imagemagick -height = Wysokość -image_menu_button = Przycisk menu obrazu -include_when_splitting = Uwzględniaj przy podziale -maim_slop_required = Wymagane paczki maim & slop -move = Do kosza -move_to_trash = Przenieś wybrany do kosza -name = Nazwa -no_colour_definitions = Brak definicji kolorów w {} -no_picture_selected = Nie wybrano obrazu -ok = OK -open_another_folder = Wybierz inny folder -open_folder = Otwórz folder -open_with = Otwórz w {} -preferences = Preferencje -refresh_folder_preview = Odśwież podgląd folderu -reload = Wczytaj ponownie -remove_image = Usuń obraz -scale_and_crop = Skaluj i przytnij -screen_color_picker = Próbnik kolorów ekranu -set_selected_wallpaper = Ustaw wybraną tapetę -sorting_order = Sortowanie -sorting_az = A -> Z -sorting_za = Z -> A -sorting_new = Od najnowszych -sorting_old = Od najstarszych -split_selection_between_displays = Podziel wybrany obraz pomiędzy ekrany -thumbnail_tooltip = Kliknij by wybrać, podwójnie by ustawić, prawym dla menu -thumbnails_in_cache = {} miniatur w cache ({}) -track_file_changes = Śledź zmiany w plikach -use_display_names = Używaj ogólnych nazw wyświetlaczy -width = Szerokość \ No newline at end of file diff --git a/azote/main.py b/azote/main.py index dbafd3f..e4c95ee 100644 --- a/azote/main.py +++ b/azote/main.py @@ -487,7 +487,6 @@ def on_apply_button(button): restore_from.append(entry) with open(common.cmd_file, 'w') as f: - # print(batch_content) for item in batch_content: f.write("%s\n" % item) # make the file executable @@ -1041,6 +1040,11 @@ def __init__(self, height): status_box.pack_start(common.status_bar, True, True, 0) update_status_bar() + btn = Gtk.Button.new_with_label(common.lang["close"]) + btn.connect("clicked", Gtk.main_quit) + btn.set_property("valign", Gtk.Align.CENTER) + status_box.pack_end(btn, False, False, 0) + main_box.add(status_box) window.show_all() @@ -1802,7 +1806,7 @@ def switch_indication(self, item): def main(): - lang = None + lang_from_args = None clear_thumbs, clear_all = False, False common.color_names = WikiColours() for i in range(1, len(sys.argv)): @@ -1812,7 +1816,7 @@ def main(): if sys.argv[i].upper() == '-L' or sys.argv[i].upper() == '--LANG': try: - lang = sys.argv[i + 1] + lang_from_args = sys.argv[i + 1] except: pass @@ -1900,7 +1904,7 @@ def main(): """ provider.load_from_data(css) - set_env(lang) # detect displays, check installed modules, set paths and stuff + set_env(lang_from_args) # detect displays, check installed modules, set paths and stuff if clear_thumbs: clear_thumbnails(clear_all) exit() diff --git a/azote/tools.py b/azote/tools.py index bb10e0c..c8ba4a4 100644 --- a/azote/tools.py +++ b/azote/tools.py @@ -247,7 +247,7 @@ def current_display(): return display_number -def set_env(language=None): +def set_env(lang_from_args=None): xdg_config_home = os.getenv('XDG_CONFIG_HOME') common.config_home = xdg_config_home if xdg_config_home else os.path.join(os.getenv("HOME"), ".config") common.azote_config_home = os.path.join(xdg_config_home, "azote") if xdg_config_home else os.path.join( @@ -313,17 +313,7 @@ def set_env(language=None): if migration_error: log('Data migration error: {}'.format(migration_error), common.ERROR) - # We will preload the en_EN dictionary as default values - common.lang = Language() - - if not language: - # Lets check locale value - # If running with LC_ALL=C, we'll get (None, None) here. Let's use en_EN in such case. - lang = locale.getlocale()[0] if locale.getlocale()[0] is not None else 'en_EN' - else: - lang = language - - common.lang.load(lang) + common.lang = Language(lang_from_args) common.displays = check_displays() @@ -362,7 +352,7 @@ def set_env(language=None): # Sway comes with some sample wallpapers if common.sway and os.path.isdir('/usr/share/backgrounds/sway'): common.sample_dir = '/usr/share/backgrounds/sway' - + if os.path.isdir('/usr/share/backgrounds/archlabs'): common.sample_dir = '/usr/share/backgrounds/archlabs' @@ -516,7 +506,7 @@ def copy_backgrounds(): used.append(fn) fn = item.thumbnail_path.split("/")[-1] used.append(fn) - + # Clear unused files for file in os.listdir(common.bcg_dir): f2delete = os.path.join(common.bcg_dir, file) @@ -955,9 +945,9 @@ def save_rc(self, set_defaults=False): json.dump(rc, f, indent=2) -def save_json(src_dict, path): +def save_json(src_dict, path, en_ascii=False): with open(path, 'w') as f: - json.dump(src_dict, f, indent=2) + json.dump(src_dict, f, indent=2, ensure_ascii=en_ascii) def load_json(path): @@ -966,33 +956,62 @@ def load_json(path): return json.load(f) except Exception as e: print(e) + return {} class Language(dict): - def __init__(self): + def __init__(self, lang_from_args): super().__init__() - self.lang = 'en_EN' - # We'll initialize with values from en_EN - with open(os.path.join('languages', 'en_EN')) as f: - lines = f.read().splitlines() - for line in lines: - if line and not line.startswith('#'): - pair = line.split('=') - key, value = pair[0].strip(), pair[1].strip() - self[key] = value + self.dir_name = os.path.dirname(__file__) + shell_data = load_shell_data() - def load(self, lang): - try: - # Overwrite initial values if translation found - with open(os.path.join('languages', lang)) as f: - lines = f.read().splitlines() - for line in lines: - if line and not line.startswith('#'): - pair = line.split('=') - key, value = pair[0].strip(), pair[1].strip() - self[key] = value - self.lang = lang - log("Loaded lang: {}".format(lang), common.INFO) + self.lang = os.getenv("LANG").split(".")[0] if not shell_data["interface-locale"] else shell_data[ + "interface-locale"] - except FileNotFoundError: - log("Couldn't load lang: {}".format(lang), common.WARNING) + if lang_from_args: + self.lang = lang_from_args + log("Lang: '{}' (from args)".format(self.lang), common.INFO) + else: + log("Lang: '{}'".format(self.lang), common.INFO) + + base_dict = load_json(os.path.join(self.dir_name, "langs", "en_US.json".format(self.lang))) + for key in base_dict: + self[key] = base_dict[key] + + if self.lang != "en_US": + user_dict = load_json(os.path.join(self.dir_name, "langs", "{}.json".format(self.lang))) + if len(user_dict) == 0: + log("No translations found for '{}'".format(self.lang), common.INFO) + else: + log("{} translation phrases found in '{}'".format(len(user_dict), self.lang), common.INFO) + for key in user_dict: + self[key] = user_dict[key] + + +def get_shell_data_dir(): + data_dir = "" + home = os.getenv("HOME") + xdg_data_home = os.getenv("XDG_DATA_HOME") + + if xdg_data_home: + data_dir = os.path.join(xdg_data_home, "nwg-shell/") + else: + if home: + data_dir = os.path.join(home, ".local/share/nwg-shell/") + + return data_dir + + +def load_shell_data(): + shell_data_file = os.path.join(get_shell_data_dir(), "data") + shell_data = load_json(shell_data_file) if os.path.isfile(shell_data_file) else {} + + defaults = { + "interface-locale": "" + } + + for key in defaults: + if key not in shell_data: + shell_data[key] = defaults[key] + + return shell_data diff --git a/setup.py b/setup.py index d0da24b..49b575f 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ def read(f_name): setup( name='azote', - version='1.9.7', + version='1.10.0', description='Wallpaper manager for Sway, i3 and some other WMs', packages=['azote'], include_package_data=True,