Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Issue #15: Implemented locales into the setup.py script

  • Loading branch information...
commit 036d7e9f99972f48ef0f6e5e49bbcb1a1be7ec37 1 parent f31e9ae
@zedtux zedtux authored
View
2  naturalscrolling/__init__.py
@@ -19,7 +19,6 @@
import sys
import argparse
import gettext
-gettext.install("naturalscrolling", "./locales")
from naturalscrolling_lib.naturalscrollingconfig import *
from naturalscrolling.indicator import Indicator
@@ -27,6 +26,7 @@
from naturalscrolling.xinputwarper import XinputWarper
from naturalscrolling_lib.debugger import Debugger
+gettext.install("naturalscrolling", get_locale_path())
def main():
"""Support for command line options"""
View
23 naturalscrolling_lib/naturalscrollingconfig.py
@@ -28,6 +28,7 @@
"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",
@@ -35,9 +36,11 @@
# 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):
@@ -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 """
View
16 setup.py
@@ -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)
@@ -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"])
+ ]
+)
Please sign in to comment.
Something went wrong with that request. Please try again.