Skip to content

Commit

Permalink
Issue #15: Implemented locales into the setup.py script
Browse files Browse the repository at this point in the history
  • Loading branch information
zedtux committed Aug 31, 2012
1 parent f31e9ae commit 036d7e9
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 8 deletions.
2 changes: 1 addition & 1 deletion naturalscrolling/__init__.py
Expand Up @@ -19,14 +19,14 @@
import sys
import argparse
import gettext
gettext.install("naturalscrolling", "./locales")

from naturalscrolling_lib.naturalscrollingconfig import *
from naturalscrolling.indicator import Indicator
from naturalscrolling_lib.gconfsettings import GConfSettings
from naturalscrolling.xinputwarper import XinputWarper
from naturalscrolling_lib.debugger import Debugger

gettext.install("naturalscrolling", get_locale_path())

def main():
"""Support for command line options"""
Expand Down
23 changes: 20 additions & 3 deletions naturalscrolling_lib/naturalscrollingconfig.py
Expand Up @@ -28,16 +28,19 @@
"appliation_website",
"get_data_file",
"get_data_path",
"get_locale_path",
"get_auto_start_path",
"get_auto_start_file_name",
"get_auto_start_file_path",
"get_auto_start_from_data_file_path"]

# Where your project will look for your data (for instance, images and ui
# files). By default, this is ../, relative your trunk layout
__naturalscrolling_data_directory__ = "../"
__version__ = "VERSION"
__website__ = "http://webiste"
__naturalscrolling_data_directory__ = """../"""
# Where your project will look for translation catalogs
__naturalscrolling_locale_directory__ = """../locales"""
__version__ = """VERSION"""
__website__ = """http://webiste"""


class project_path_not_found(Exception):
Expand Down Expand Up @@ -80,6 +83,20 @@ def get_data_path():

return abs_data_path

def get_locale_path():
"""Retrieve naturalscrolling locale path
This path is by default <naturalscrolling_lib_path>/../locales in trunk
and /usr/share/locale in an installed version but this path
is specified at installation time.
"""

# Get pathname absolute or relative.
path = os.path.join(
os.path.dirname(__file__), __naturalscrolling_locale_directory__)

return os.path.abspath(path)


def get_auto_start_path():
""" Retrieve the autostart folder from user's HOME folder """
Expand Down
16 changes: 12 additions & 4 deletions setup.py
Expand Up @@ -77,13 +77,15 @@ def update_desktop_file(datadir):
class InstallAndUpdateDataDirectory(DistUtilsExtra.auto.install_auto):

def run(self):
path = self.prefix + "/share/naturalscrolling/"
values = {"__naturalscrolling_data_directory__": path,
data_path = self.prefix + "/share/naturalscrolling/"
locale_path = self.prefix + "/share/locale/"
values = {"__naturalscrolling_data_directory__": data_path,
"__naturalscrolling_locale_directory__": locale_path,
"__version__": self.distribution.get_version(),
"__license__": self.distribution.get_license(),
"__website__": self.distribution.get_url()}
previous_values = update_config(values)
update_desktop_file(path)
update_desktop_file(data_path)
DistUtilsExtra.auto.install_auto.run(self)
update_config(previous_values)

Expand All @@ -107,4 +109,10 @@ def run(self):
("share/naturalscrolling/media", ["media/Screenshot.png",
"media/natural-scrolling-status-activated.png",
"media/natural-scrolling-status-not-activated.png",
"media/naturalscrolling.svg"])])
"media/naturalscrolling.svg"]),
("share/locale/es_ES/LC_MESSAGES", ["locales/es_ES/LC_MESSAGES/naturalscrolling.mo"]),
("share/locale/fr_FR/LC_MESSAGES", ["locales/fr_FR/LC_MESSAGES/naturalscrolling.mo"]),
("share/locale/it_IT/LC_MESSAGES", ["locales/it_IT/LC_MESSAGES/naturalscrolling.mo"]),
("share/locale/pt_BR/LC_MESSAGES", ["locales/pt_BR/LC_MESSAGES/naturalscrolling.mo"])
]
)

0 comments on commit 036d7e9

Please sign in to comment.