Skip to content

Commit

Permalink
Localization internationalization workflow (#131)
Browse files Browse the repository at this point in the history
* add workflow for updating translation files
  • Loading branch information
edaniszewski committed Apr 16, 2018
1 parent 38b6c0a commit d8190b3
Show file tree
Hide file tree
Showing 14 changed files with 684 additions and 579 deletions.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
PKG_NAME := synse
IMG_NAME := vaporio/synse-server
PKG_VER := $(shell python synse/__init__.py)
PKG_VER := $(shell python -c "import synse ; print(synse.__version__)")
export GIT_VER := $(shell /bin/sh -c "git log --pretty=format:'%h' -n 1 || echo 'none'")


Expand Down Expand Up @@ -150,6 +150,10 @@ else
docker-compose -f compose/synse.yml -f compose/test.yml -f compose/test_end_to_end.yml down
endif

.PHONY: translations
translations: ## (Re)generate the translations.
tox -e translations

.PHONY: version
version: ## Print the version of Synse Server
@echo "$(PKG_VER)"
Expand Down
6 changes: 1 addition & 5 deletions dockerfile/release.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ RUN set -e -x \
bash libstdc++ \
&& apk --update --no-cache --virtual .build-dep add \
curl build-base jq \
&& pip install --upgrade pip \
&& pip install --upgrade pip babel \
&& pip install -r requirements.txt \
&& bin_url=$(curl -s https://api.github.com/repos/${EMULATOR_REPO}/releases/latest | jq '.assets[] | select(.name == env.EMULATOR_BIN) | .url' | tr -d '"') \
&& curl -L -H "Accept: application/octet-stream" -o $EMULATOR_BIN $bin_url \
Expand All @@ -38,10 +38,6 @@ RUN mkdir -p /tmp/synse/procs \
&& mkdir -p /synse/config

# install synse_server python package
# TODO - since we are pretty much just using the package, what
# if on build, we just pass in the tarball for synse_server.. then
# we don't have to also include the source code which isn't actually
# used (other than some of the configurations and runserver.py
RUN python setup.py install

ENTRYPOINT ["bin/synse.sh"]
2 changes: 1 addition & 1 deletion dockerfile/slim.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ RUN set -e -x \
bash libstdc++ \
&& apk --update --no-cache --virtual .build-dep add \
build-base \
&& pip install --upgrade pip \
&& pip install --upgrade pip babel \
&& pip install -r requirements.txt \
&& apk del .build-dep

Expand Down
13 changes: 13 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,16 @@ universal = 1
not_skip = __init__.py
default_section = THIRDPARTY
known_first_party = synse,tests

[extract_messages]
keywords = gettext
input_dirs = synse
output_file = synse/i18n/messages.pot

[init_catalog]
input_file = synse/i18n/messages.pot
output_dir = synse/i18n
locale = en_US

[compile_catalog]
directory = synse/i18n
58 changes: 47 additions & 11 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,56 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Setup and packaging for Synse Server."""

from setuptools import setup, find_packages
import os

import synse
from babel.messages import frontend as babel
from setuptools import find_packages, setup


here = os.path.abspath(os.path.dirname(__file__))

# Load the package's __init__.py file as a dictionary.
pkg = {}
with open(os.path.join(here, 'synse', '__init__.py')) as f:
exec(f.read(), pkg)

# Load the README
readme = ""
if os.path.exists('README.md'):
with open('README.md', 'r') as f:
readme = f.read()

# Load the requirements
with open('requirements.txt', 'r') as f:
requirements = f.read().split('\n')


setup(
name=synse.__title__,
version=synse.__version__,
description=synse.__description__,
url=synse.__url__,
author=synse.__author__,
author_email=synse.__author_email__,
license='GNU General Public License v2.0',
python_requires='==3.6',
name=pkg['__title__'],
version=pkg['__version__'],
description=pkg['__description__'],
url=pkg['__url__'],
author=pkg['__author__'],
author_email=pkg['__author_email__'],
license=pkg['__license__'],
packages=find_packages(),
zip_safe=False
include_package_data=True,
package_data={'': ['LICENSE']},
python_requires='==3.6',
install_requires=requirements,
zip_safe=False,
classifiers=[
'Natural Language :: English',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
],
cmdclass={
'compile_catalog': babel.compile_catalog,
'extract_messages': babel.extract_messages,
'init_catalog': babel.init_catalog,
}
)
4 changes: 1 addition & 3 deletions synse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,4 @@
__author__ = 'Vapor IO'
__author_email__ = 'vapor@vapor.io'
__url__ = 'https://github.com/vapor-ware/synse-server'

if __name__ == '__main__':
print(__version__)
__license__ = 'GNU General Public License v2.0'
2 changes: 1 addition & 1 deletion synse/i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def _get_locale_dir():
otherwise raises an IOError.
"""
# TODO This is not the most robust method of finding the locale file.
locale_dir = '{}/locale'.format(os.path.dirname(os.path.realpath(__file__)))
locale_dir = '{}/i18n'.format(os.path.dirname(os.path.realpath(__file__)))
if os.path.isdir(locale_dir):
return locale_dir
else:
Expand Down

0 comments on commit d8190b3

Please sign in to comment.