Commit 68c637c8 authored by GabMus's avatar GabMus

Merge branch 'translation' into 'master'

Translation

See merge request !2
parents c42fd5b9 a979d275
Pipeline #71010927 passed with stage
in 50 seconds
......@@ -21,6 +21,7 @@ import os
import sys
import signal
import gettext
import locale
sys.path.insert(1, '@pythondir@')
......@@ -36,7 +37,16 @@ if builddir:
signal.signal(signal.SIGINT, signal.SIG_DFL)
# gettext.install('trg', localedir)
# Why both locale and gettext?
# gettext works for the python part
# but not for the glade/xml files
# they need locale
# don't ask me, it's effin weird
# I copied this from uberwriter
locale.textdomain('hydrapaper')
locale.bindtextdomain('hydrapaper', localedir)
gettext.textdomain('hydrapaper')
gettext.bindtextdomain('hydrapaper', localedir)
if __name__ == '__main__':
import gi
......
......@@ -4,6 +4,7 @@ conf.set('localedir', join_paths(prefix, get_option('localedir')))
conf.set('pkgdatadir', pkgdatadir)
conf.set('PYTHON', python.find_python().path())
conf.set('pythondir', join_paths(prefix, pythondir))
conf.set('localedir', join_paths(prefix, localedir))
conf.set('projectname', meson.project_name())
conf.set('authorfullname', authorfullname)
conf.set('authoremail', authoremail)
......
......@@ -13,16 +13,26 @@ app_id_aspath = '/'.join([
desktop_conf = configuration_data()
desktop_conf.set('bindir', join_paths(prefix, bindir))
desktop_conf.set('prettyname', prettyname)
desktop_conf.set('description', description)
# .desktop comment now hardcoded for better i18n support
#desktop_conf.set('description', description)
desktop_conf.set('appid', app_id)
desktop_conf.set('projectname', meson.project_name())
desktop_file = configure_file(
input: app_id + '.desktop.in',
output: app_id + '.desktop.i18n.in',
#install: true,
#install_dir: join_paths(datadir, 'applications'),
configuration: desktop_conf
)
i18n.merge_file(
input: desktop_file,
output: app_id + '.desktop',
po_dir: '../po',
type: 'desktop',
install: true,
install_dir: join_paths(datadir, 'applications'),
configuration: desktop_conf
install_dir: join_paths(datadir, 'applications')
)
message('Looking for dependencies')
......@@ -89,18 +99,24 @@ app_resources = gnome.compile_resources(app_id,
app_settings = gnome.compile_schemas()
appdata_conf = configuration_data()
appdata_conf.set('description', description)
appdata_conf.set('authorfullname', authorfullname)
appdata_conf.set('gitrepo', gitrepo)
appdata_conf.set('website', website)
appdata_conf.set('authoremail', authoremail)
appdata_conf.set('prettyname', prettyname)
appdata_conf.set('appid', app_id)
appdata_conf.set('prettylicense', prettylicense)
configure_file(
appdata_file = configure_file(
input: app_id + '.appdata.xml.in',
output: app_id + '.appdata.xml.i18n.in',
configuration: appdata_conf
)
i18n.merge_file(
input: app_id + '.appdata.xml.in',
output: app_id + '.appdata.xml',
configuration: appdata_conf,
po_dir: '../po',
install: true,
install_dir: join_paths(datadir, 'metainfo')
)
......@@ -4,12 +4,13 @@
<!-- <translation type="gettext">trg</translation> -->
<name>@prettyname@</name>
<developer_name>@authorfullname@</developer_name>
<summary>@description@</summary>
<summary>Wallpaper manager with multimonitor support</summary>
<metadata_license>CC0-1.0</metadata_license>
<project_license>@prettylicense@</project_license>
<description>
<p>Hydrapaper lets you set different wallpapers for each of your monitors in the GNOME desktop.</p>
<p>It uses Pillow to create a single image merging all of your chosen wallpapers and setting it as your wallpaper with the "Spanned" option.</p>
<p>HydraPaper lets you set different wallpapers for each of your monitors in the GNOME desktop.</p>
<p>It works around this lack of functionality by automatically merging multiple wallpapers into one, and setting it as your wallpaper with the "Spanned" option.</p>
<p>HydraPaper also supports the MATE desktop, and should work on any desktop that is based on GNOME, like Budgie and Pantheon.</p>
</description>
<screenshots>
<screenshot type="default">
......
[Desktop Entry]
Name=@prettyname@
Comment=@description@
Comment=Wallpaper manager with multimonitor support
Exec=@bindir@/@projectname@ %U
Icon=@appid@
Terminal=false
Type=Application
StartupNotify=true
MimeType=
#MimeType=
Categories=Utility;GTK;GNOME;
Keywords=wallpaper;background;monitor;
Actions=set-random-wallpapers
......
......@@ -19,7 +19,7 @@
<object class="GtkHeaderBar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="title">Add a wallpapers folder</property>
<property name="title" translatable="yes">Add a wallpapers folder</property>
<child>
<object class="GtkButton" id="addFolderFileChooserDialogCancelButton">
<property name="label">gtk-cancel</property>
......
......@@ -3,25 +3,25 @@
<menu id="generalMenu">
<section>
<item>
<attribute name="label">Set random wallpapers</attribute>
<attribute name="label" translatable="yes">Set random wallpapers</attribute>
<attribute name="action">app.set_random_wallpaper</attribute>
</item>
</section>
<section>
<item>
<attribute name="label">Settings</attribute>
<attribute name="label" translatable="yes">Settings</attribute>
<attribute name="action">app.settings</attribute>
</item>
<item>
<attribute name="label">Shortcuts</attribute>
<attribute name="label" translatable="yes">Shortcuts</attribute>
<attribute name="action">app.shortcuts</attribute>
</item>
<item>
<attribute name="label">About</attribute>
<attribute name="label" translatable="yes">About</attribute>
<attribute name="action">app.about</attribute>
</item>
<item>
<attribute name="label">Quit</attribute>
<attribute name="label" translatable="yes">Quit</attribute>
<attribute name="action">app.quit</attribute>
</item>
</section>
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface>
<interface domain="hydrapaper">
<requires lib="gtk+" version="3.20"/>
<object class="GtkHeaderBar" id="headerbar">
<property name="visible">True</property>
......@@ -137,7 +137,7 @@
</child>
<child>
<object class="GtkButton" id="resetFavoritesButton">
<property name="label">Clear favorites</property>
<property name="label" translatable="yes">Clear favorites</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
......
......@@ -34,7 +34,7 @@
</child>
<child>
<object class="GtkButton" id="favoriteBtn">
<property name="label" translatable="yes">❤️ Add favorite</property>
<property name="label" translatable="yes">Add favorite</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
......@@ -77,7 +77,6 @@
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="max_width_chars">30</property>
<property name="text" translatable="yes">/home/gabmus/Pictures/Wallpapers/some/other/folder/wp.jpg</property>
</object>
</child>
</object>
......
......@@ -15,6 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from gettext import gettext as _
import sys
import argparse
from gi.repository import Gtk, Gio
......@@ -117,14 +118,14 @@ class HydraPaperApplication(Gtk.Application):
monitors = build_monitors_from_gdk()
if len(wlist_cli) < len(monitors):
print(
'Error: you passed {0} wallpapers for {1} monitors'.format(
_('Error: you passed {0} wallpapers for {1} monitors').format(
len(wlist_cli), len(monitors)
)
)
exit(1)
for wpath in wlist_cli:
if not is_image(wpath):
print('Error: {0} is not a valid image path'.format(wpath))
print(_('Error: {0} is not a valid image path').format(wpath))
exit(1)
for monitor, n_wp in zip(monitors, wlist_cli):
monitor.wallpaper = n_wp
......@@ -158,8 +159,8 @@ class HydraPaperApplication(Gtk.Application):
Gtk.Application.do_command_line(self, args) # call the default commandline handler
# make a command line parser
parser = argparse.ArgumentParser()
parser.add_argument('-c', '--cli', dest='wallpaper_path', nargs='+', action='append', help='set wallpapers from command line')
parser.add_argument('-r', '--random', dest='set_random', action='store_true', help='set wallpapers randomly')
parser.add_argument('-c', '--cli', dest='wallpaper_path', nargs='+', action='append', help=_('set wallpapers from command line'))
parser.add_argument('-r', '--random', dest='set_random', action='store_true', help=_('set wallpapers randomly'))
# parse the command line stored in args, but skip the first element (the filename)
self.args = parser.parse_args(args.get_arguments()[1:])
# call the main program do_activate() to start up the app
......
from gettext import gettext as _
from os import environ as Env
from os.path import isfile
from hashlib import sha256
......@@ -28,7 +29,7 @@ def _apply_wallpapers_worker(monitors):
).hexdigest()
)
if isfile(save_path):
print(f'Hit cache for {save_path}. Skipping merge')
print(_('Hit cache for {0}. Skipping merge').format(save_path))
else:
multi_setup_pillow(monitors, save_path)
set_wallpaper(save_path)
......
from gettext import gettext as _
from gi.repository import Gtk
from .wallpapers_flowbox import HydraPaperWallpapersFlowbox
......@@ -8,6 +9,6 @@ class HydraPapaerMainStack(Gtk.Stack):
self.main_flowbox = HydraPaperWallpapersFlowbox()
self.favs_flowbox = HydraPaperWallpapersFlowbox(is_favorites = True)
self.add_titled(self.main_flowbox, 'Wallpapers', 'Wallpapers')
self.add_titled(self.favs_flowbox, 'Favorites', 'Favorites')
self.add_titled(self.main_flowbox, 'Wallpapers', _('Wallpapers'))
self.add_titled(self.favs_flowbox, 'Favorites', _('Favorites'))
self.set_transition_type(Gtk.StackTransitionType.SLIDE_LEFT_RIGHT)
from gettext import gettext as _
from gi.repository import Gdk
class Monitor:
......@@ -40,7 +41,7 @@ def build_monitors_from_gdk():
monitor.is_primary()
))
except Exception as e:
print('Error parsing monitors (Gdk)')
print(_('Error parsing monitors (Gdk)'))
import traceback
traceback.print_exc()
monitors = None
......
from gettext import gettext as _
from gi.repository import Gtk, Gdk, Gio, GdkPixbuf
import os
from . import threading_helper as ThreadingHelper
......@@ -74,5 +75,5 @@ class WallpaperBox(Gtk.FlowBoxChild):
thumb.thumbnail((250, 250), Image.ANTIALIAS)
thumb.save(self.cache_path, 'PNG')
except IOError:
print('ERROR: cannot create thumbnail for file', self.wallpaper_path)
print(_('ERROR: cannot create thumbnail for file'), self.wallpaper_path)
return self.cache_path
from gettext import gettext as _
from gi.repository import Gtk
from .confManager import ConfManager
from .wallpaper_flowbox_item import WallpaperBox
......@@ -104,9 +105,9 @@ class HydraPaperWallpapersFlowbox(Gtk.Bin):
self.popover.set_relative_to(self.child_at_pos)
self.flowbox.select_child(self.child_at_pos)
if self.is_favorites or self.child_at_pos.is_fav:
self.favorite_btn.set_label('💔 Remove favorite')
self.favorite_btn.set_label(_('Remove favorite'))
else:
self.favorite_btn.set_label('❤️ Add favorite')
self.favorite_btn.set_label(_('Add favorite'))
wp_path = self.child_at_pos.get_child().wallpaper_path
self.wallpaper_path_entry.set_text(wp_path)
self.wallpaper_name_label.set_text(pathlib.Path(wp_path).name)
......
project('hydrapaper',
version: '1.7.3',
meson_version: '>= 0.40.0',
meson_version: '>= 0.50.0',
license: 'GPL3'
)
description = 'Wallpaper manager with multimonitor support for GNOME'
description = 'Wallpaper manager with multimonitor support'
prettyname = 'HydraPaper'
prettylicense = 'GPL-3.0+'
......@@ -22,7 +22,7 @@ contributors = '\n'.join([
'Alex Hunt (huntie) &lt;hello@alexhunt.io&gt;'
])
# i18n = import('i18n')
i18n = import('i18n')
python = import('python3')
gnome = import('gnome')
prefix = get_option('prefix') # should be /usr
......@@ -30,10 +30,12 @@ bindir = get_option('bindir') # should be bin
datadir = get_option('datadir') # should be /usr/share
pkgdatadir = join_paths(prefix, datadir, meson.project_name())
pythondir = join_paths(prefix, python.sysconfig_path('purelib'))
localedir = join_paths(prefix, get_option('localedir'))
install_subdir(meson.project_name(), install_dir: pythondir)
subdir('data')
subdir('bin')
subdir('po')
meson.add_install_script('meson_post_install.py')
# Please keep this list alphabetically sorted
it
data/org.gabmus.hydrapaper.appdata.xml.in
data/org.gabmus.hydrapaper.desktop.in
data/ui/choose_folder_dialog.glade
data/ui/headerbar.glade
data/ui/menu.xml
data/ui/menu.xml data/ui/settings_window.glade
data/ui/menu.xml data/ui/shortcutsWindow.xml
data/ui/settings_window.glade
data/ui/shortcutsWindow.xml
data/ui/wallpapers_flowbox.glade
data/ui/wallpapers_folders_view.glade
hydrapaper/apply_wallpapers.py
hydrapaper/__main__.py
hydrapaper/main_stack.py
hydrapaper/monitor_parser.py
hydrapaper/wallpaper_flowbox_item.py
hydrapaper/wallpapers_flowbox.py
This diff is collapsed.
message('Update translations')
i18n.gettext(meson.project_name(),
preset: 'glib'
)
#!/bin/bash
rm *.pot
version=$(fgrep "version: " ../meson.build | grep -v "meson" | grep -o "'.*'" | sed "s/'//g")
find ../hydrapaper -iname "*.py" | xargs xgettext --package-name=HydraPaper --package-version=$version --from-code=UTF-8 --output=hydrapaper-python.pot
find ../data/ui -iname "*.glade" -or -iname "*.xml" | xargs xgettext --package-name=HydraPaper --package-version=$version --from-code=UTF-8 --output=hydrapaper-glade.pot -L Glade
find ../data/ -iname "*.desktop.in" | xargs xgettext --package-name=HydraPaper --package-version=$version --from-code=UTF-8 --output=hydrapaper-desktop.pot -L Desktop
find ../data/ -iname "*.appdata.xml.in" | xargs xgettext --no-wrap --package-name=HydraPaper --package-version=$version --from-code=UTF-8 --output=hydrapaper-appdata.pot
msgcat --use-first hydrapaper-python.pot hydrapaper-glade.pot hydrapaper-desktop.pot hydrapaper-appdata.pot > hydrapaper.pot
sed 's/#: //g;s/:[0-9]*//g;s/\.\.\///g' <(fgrep "#: " hydrapaper.pot) | sort | uniq > POTFILES.in
echo "# Please keep this list alphabetically sorted" > LINGUAS
for l in $(ls *.po); do basename $l .po >> LINGUAS; done
for lang in $(sed "s/^#.*$//g" LINGUAS); do
mv "${lang}.po" "${lang}.po.old"
msginit --locale=$lang --input hydrapaper.pot
mv "${lang}.po" "${lang}.po.new"
msgmerge -N "${lang}.po.old" "${lang}.po.new" > ${lang}.po
rm "${lang}.po.old" "${lang}.po.new"
done
rm *.pot
# To create lang file use this command
# msginit --locale=LOCALE --input hydrapaper.pot
# where LOCALE is something like `de`, `it`, `es`...
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment