Permalink
Browse files

Commit (improved) patch from #525 and fix for #520.

 - Use DistUtilsExtra for better i18n, make the .desktop file
   translatable and regenerate po files with 'setup.py build_i18n'.
   Support for taking strings from .xml and .sqlite is still missing.

 - Install executable into /usr/games, on Debian and Ubuntu systems.

 - Some little other change. Did I mention could take some testing?



git-svn-id: http://svn.unknown-horizons.org/trunk@3254 d3468d7a-13f2-4ea4-bf00-366cb6352a40
  • Loading branch information...
1 parent ad53eaf commit 283907548f0222c609f1bbf2ebd7ddeb5468e9bd rainct committed Mar 2, 2010
View
2 MANIFEST.in
@@ -1,5 +1,5 @@
include unknown-horizons
include run_uh.py
recursive-include content *
-recursive-include po *.po *.mo *.pot
+recursive-include po *.po *.pot
include doc/manpage.xml
View
4 content/unknown-horizons.desktop → content/unknown-horizons.desktop.in
@@ -1,7 +1,7 @@
[Desktop Entry]
Type=Application
-Name=Unknown Horizons
-Comment=A 2D real time strategy simulation with an emphasis on economy and city building
+_Name=Unknown Horizons
+_Comment=A 2D real time strategy simulation with an emphasis on economy and city building
Icon=unknown-horizons
Exec=unknown-horizons
Terminal=false
View
2 debug.py
@@ -36,7 +36,7 @@
import os
import gettext
- gettext.install("unknownhorizons", "po", unicode=1)
+ gettext.install("unknownhorizons", "build/mo", unicode=1)
#find fife and setup search paths
try:
View
2 horizons/gui/modules/settingsgui.py
@@ -139,7 +139,7 @@ def show_settings(self):
trans = gettext.translation('unknownhorizons', settings.language.position, languages=[settings.language.name])
trans.install(unicode=1)
else:
- gettext.install('unknownhorizons', 'po', unicode=1)
+ gettext.install('unknownhorizons', 'build/mo', unicode=1)
settings.language.name = ''
update_all_translations()
View
2 horizons/i18n/utils.py
@@ -20,7 +20,7 @@
# ###################################################
def find_available_languages():
- alternatives = ('po',
+ alternatives = ('build/mo',
'/usr/share/locale',
'/usr/share/games/locale',
'/usr/local/share/locale',
View
4 horizons/main.py
@@ -203,10 +203,10 @@ def _init_gettext():
trans.install(unicode=1)
except IOError:
print _("Configured language %(lang)s at %(place)s could not be loaded") % {'lang': settings.language.name, 'place': settings.language.position}
- install('unknownhorizons', 'po', unicode=1)
+ install('unknownhorizons', 'build/mo', unicode=1)
settings.language.name = ''
else:
- install('unknownhorizons', 'po', unicode=1)
+ install('unknownhorizons', 'build/mo', unicode=1)
update_all_translations()
View
2 horizons/settings.py
@@ -154,6 +154,6 @@ def set_defaults(self):
url_master = 'master.unknown-horizons.org', \
favorites = [])
self.addCategories('language')
- self.language.setDefaults(position='po', name='')
+ self.language.setDefaults(position='build/mo', name='')
self.addCategories('savegame')
self.savegame.setDefaults(savedquicksaves = 10, autosaveinterval = 10, savedautosaves = 10)
View
6 po/POTFILES.in.in
@@ -0,0 +1,6 @@
+*.py
+horizons/*.py
+horizons/*/*.py
+horizons/*/*/*.py
+horizons/*/*/*/*.py
+editor/*.py
View
0 po/de/LC_MESSAGES/unknownhorizons.po → po/de.po
File renamed without changes.
View
BIN po/de/LC_MESSAGES/unknownhorizons.mo
Binary file not shown.
View
0 po/en/LC_MESSAGES/unknownhorizons.po → po/en.po
File renamed without changes.
View
BIN po/en/LC_MESSAGES/unknownhorizons.mo
Binary file not shown.
View
0 po/fr/LC_MESSAGES/unknownhorizons.po → po/fr.po
File renamed without changes.
View
BIN po/fr/LC_MESSAGES/unknownhorizons.mo
Binary file not shown.
View
0 po/nb/LC_MESSAGES/unknownhorizons.po → po/nb.po
File renamed without changes.
View
BIN po/nb/LC_MESSAGES/unknownhorizons.mo
Binary file not shown.
View
0 po/pl/LC_MESSAGES/unknownhorizons.po → po/pl.po
File renamed without changes.
View
BIN po/pl/LC_MESSAGES/unknownhorizons.mo
Binary file not shown.
View
0 po/pt_PT/LC_MESSAGES/unknownhorizons.po → po/pt_PT.po
File renamed without changes.
View
BIN po/pt_PT/LC_MESSAGES/unknownhorizons.mo
Binary file not shown.
View
2 run_uh.py
@@ -159,7 +159,7 @@ def main():
os.chdir( find_uh_position() )
logging.config.fileConfig( os.path.join('content', 'logging.conf'))
- gettext.install("unknownhorizons", "po", unicode=1)
+ gettext.install("unknownhorizons", "build/mo", unicode=1)
create_user_dirs()
View
4 setup.cfg
@@ -0,0 +1,4 @@
+[build_i18n]
+domain=unknownhorizons
+bug_contact=team@unknown-horizons.org
+desktop_files=[('share/applications', ('content/unknown-horizons.desktop.in',))]
View
73 setup.py
@@ -1,25 +1,31 @@
#!/usr/bin/env python
+from __future__ import with_statement
from distutils.core import setup
from distutils.command.build import build
from distutils.spawn import spawn, find_executable
-from glob import glob
+from DistUtilsExtra.command import *
import os
-import os.path
+import platform
+from glob import glob
-data = [('share/applications', ('content/unknown-horizons.desktop', )),
- ('share/pixmaps', ('content/unknown-horizons.xpm', ))]
+# Ensure we are in the correct directory
+os.chdir(os.path.realpath(os.path.dirname(__file__)))
-for i in filter(lambda x: len(x[2]), os.walk('content')):
- if not '.svn' in os.path.split(i[0]):
- data.append( ('share/unknown-horizons/%s' % i[0], [ '%s/%s' % (i[0], j) for j in i[2]] ) )
+if platform.dist()[0].lower() in ('debian', 'ubuntu'):
+ executable_path = 'games'
+else:
+ executable_path = 'bin'
-for i in os.listdir('po'):
- if os.path.isdir('po/%s' % i):
- if os.path.exists('po/%s/LC_MESSAGES/unknownhorizons.mo' % i):
- data.append( ('share/locale/%s/LC_MESSAGES' % i, ('po/%s/LC_MESSAGES/unknownhorizons.mo' % i,)))
+data = [
+ (executable_path, ('unknown-horizons', )),
+ ('share/pixmaps', ('content/unknown-horizons.xpm', ))]
-#trans = glob('po/*/LC_MESSAGES/unknownhorizons.mo')
+for root, dirs, files in filter(lambda x: len(x[2]), os.walk('content')):
+ if '.svn' in dirs:
+ dirs.remove('.svn')
+ data.append(('share/unknown-horizons/%s' % root,
+ ['%s/%s' % (root, f) for f in files]))
data = filter(lambda x: '.svn' not in x[0], data)
@@ -29,8 +35,22 @@
dirs.remove('.svn')
packages.append(root)
-class build_man(build):
- description = "Build the Manpage"
+class _build_i18n(build_i18n.build_i18n):
+
+ def run(self):
+ # Generate POTFILES.in from POTFILES.in.in
+ if os.path.isfile("po/POTFILES.in.in"):
+ lines = []
+ with open("po/POTFILES.in.in") as f:
+ for line in f:
+ lines.extend(glob(line.strip()))
+ with open("po/POTFILES.in", "w") as f:
+ f.write("\n".join(lines) + "\n")
+
+ build_i18n.build_i18n.run(self)
+
+class _build_man(build):
+ description = "build the Manpage"
def run(self):
if not find_executable('xsltproc'):
@@ -52,16 +72,19 @@ def run(self):
build.sub_commands.append(('build_man', None))
-cmdclass = {'build_man': build_man}
+cmdclass = {
+ 'build': build_extra.build_extra,
+ 'build_man': _build_man,
+ 'build_i18n': _build_i18n,
+}
-setup(name='UnknownHorizons',
- version='2009.2',
- description='Realtime Economy Simulation and Strategy Game',
- author='The Unknown Horizons Team',
- author_email='team@unknown-horizons.org',
- url='http://www.unknown-horizons.org',
- packages=packages,
+setup(
+ name='UnknownHorizons',
+ version='2009.2',
+ description='Realtime Economy Simulation and Strategy Game',
+ author='The Unknown Horizons Team',
+ author_email='team@unknown-horizons.org',
+ url='http://www.unknown-horizons.org',
+ packages=packages,
data_files=data,
- cmdclass=cmdclass,
- scripts=['unknown-horizons']
- )
+ cmdclass=cmdclass)

0 comments on commit 2839075

Please sign in to comment.