Skip to content

Commit

Permalink
implementacion de gettext [WIP]
Browse files Browse the repository at this point in the history
  • Loading branch information
sodomon2 committed Jan 4, 2021
1 parent 7112190 commit 723a591
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 19 deletions.
12 changes: 8 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
EXECUTABLE = ./sodplayer
MSGFMT = /usr/bin/msgfmt
LOCALE_PO = locale
LOCALES = /usr/share/locale/es_ES.UTF-8/LC_MESSAGES
LOCALE_ES = /usr/share/locale/es_ES.UTF-8/LC_MESSAGES
LOCALE_EN = /usr/share/locale/en_US/LC_MESSAGES

all: locale

locale:
$(MSGFMT) --check-accelerators=_ $(LOCALE_PO)/es.po -o $(LOCALE_PO)/es.mo
$(MSGFMT) --check-accelerators=_ $(LOCALE_PO)/en.po -o $(LOCALE_PO)/en.mo

install: locale
install -m775 $(EXECUTABLE) /usr/bin/
Expand All @@ -23,8 +25,9 @@ install: locale
cp -r vistas/ /usr/share/sodplayer
cp -r lib/ /usr/share/sodplayer
cp -r sodplayer.json /usr/share/sodplayer
mkdir -p $(LOCALES)
cp -r locale/es.mo $(LOCALES)/sodplayer.mo
mkdir -p $(LOCALE_ES) $(LOCALE_EN)
cp -r locale/es.mo $(LOCALE_ES)/sodplayer.mo
cp -r locale/en.mo $(LOCALE_EN)/sodplayer.mo
install -m644 vistas/images/player.svg /usr/share/pixmaps/sodplayer.svg
install -m644 sodplayer.desktop /usr/share/applications

Expand All @@ -33,6 +36,7 @@ uninstall :
rm -f /usr/share/applications/sodplayer.desktop
rm -f /usr/share/pixmaps/sodplayer.svg
rm -f /usr/bin/$(EXECUTABLE)
rm -f $(LOCALES)/sodplayer.mo
rm -f $(LOCALE_ES)/sodplayer.mo
rm -f $(LOCALE_EN)/sodplayer.mo

.PHONY: locale
6 changes: 3 additions & 3 deletions components/SODPlayer-menus.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
]]

menu_archive_recent = Gtk.ImageMenuItem {
label = gettext("Recents"),
label = gettext:gettext("Recents"),
image = Gtk.Image {stock = "gtk-directory"}
}

menu_archive_item_url = Gtk.ImageMenuItem {
label = gettext("URL..."),
label = gettext:gettext("URL..."),
image = Gtk.Image {stock = "gtk-connect"}
}

separator = Gtk.SeparatorMenuItem()

menu_archive_item_quit = Gtk.ImageMenuItem {
label = gettext("Quit"),
label = gettext:gettext("Quit"),
image = Gtk.Image {stock = "gtk-quit"}
}
8 changes: 4 additions & 4 deletions components/SODPlayer-statusicon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ end
function create_menu(event_button, event_time)
menu = Gtk.Menu {
Gtk.ImageMenuItem {
label = gettext("File"),
label = gettext:gettext("File"),
image = Gtk.Image {
stock = "gtk-open"
},
Expand All @@ -35,7 +35,7 @@ function create_menu(event_button, event_time)
end
},
Gtk.ImageMenuItem {
label = gettext("URL..."),
label = gettext:gettext("URL..."),
image = Gtk.Image {
stock = "gtk-connect"
},
Expand All @@ -45,7 +45,7 @@ function create_menu(event_button, event_time)
},
Gtk.SeparatorMenuItem {},
Gtk.ImageMenuItem {
label = gettext("Preferences"),
label = gettext:gettext("Preferences"),
image = Gtk.Image {
stock = "gtk-preferences"
},
Expand All @@ -55,7 +55,7 @@ function create_menu(event_button, event_time)
},
Gtk.SeparatorMenuItem {},
Gtk.ImageMenuItem {
label = gettext("Quit"),
label = gettext:gettext("Quit"),
image = Gtk.Image {
stock = "gtk-quit"
},
Expand Down
21 changes: 13 additions & 8 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ json = require 'lib.json'
config = require 'lib.configuration'
utils = require 'lib.utils'
ml = require 'lib.ml'
gettext = require 'lib.gettext'
lgettext = require 'lib.lgettext'

lgi = require 'lgi' -- La libreria que me permitira usar GTK
GObject = lgi.GObject -- Parte de lgi
Expand All @@ -29,18 +29,23 @@ end

print(Gst._version)
assert = lgi.assert
builder = Gtk.Builder({
translation_domain = 'sodplayer'
})

assert(builder:add_from_file('vistas/player.ui'))
ui = builder.objects
app = Gtk.Application.new ('org.SODPlayer',Gio.ApplicationFlags.HANDLES_OPEN)

config:create_config('sodplayer','sodplayer.json')
dir = ('%s/sodplayer'):format(GLib.get_user_config_dir())
conf = config:load(('%s/sodplayer.json'):format(dir))

if conf.general.language == 'es' then
gettext = lgettext.translation('sodplayer', '/usr/share/locale', {'es_ES.UTF-8'}, 'UTF-8')
builder = Gtk.Builder({translation_domain = 'sodplayer'})
else
gettext = lgettext.translation('sodplayer', '/usr/share/locale', {'en_US'}, 'UTF-8')
builder = Gtk.Builder()
end

assert(builder:add_from_file('vistas/player.ui'))
ui = builder.objects
app = Gtk.Application.new ('org.SODPlayer',Gio.ApplicationFlags.HANDLES_OPEN)

-- SODPlayer
require('components.SODPlayer-app')
require('components.SODPlayer-volume')
Expand Down

0 comments on commit 723a591

Please sign in to comment.