Skip to content

Commit

Permalink
Add language folders
Browse files Browse the repository at this point in the history
  • Loading branch information
titilambert committed Aug 30, 2016
1 parent c333528 commit 46074d9
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ cover/
tuxeatpi-conf.yml
build/
dist
locale/messages.pot
tuxeatpi/locale/messages.pot
*.mo
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ doc-generate:
### Test targets
#######################################
lang-scan:
pygettext3.5 --output-dir=locale/ -k gtt -va -x tuxeatpi/libs/lang.py tuxeatpi/*.py tuxeatpi/*/*.py
cd locale && msgmerge --update --no-fuzzy-matching --backup=off en/LC_MESSAGES/tuxeatpi.po messages.pot
cd locale && msgmerge --update --no-fuzzy-matching --backup=off fr/LC_MESSAGES/tuxeatpi.po messages.pot
pygettext3.5 --output-dir=tuxeatpi/locale/ -k gtt -va -x tuxeatpi/libs/lang.py tuxeatpi/*.py tuxeatpi/*/*.py
cd tuxeatpi/locale && msgmerge --update --no-fuzzy-matching --backup=off en/LC_MESSAGES/tuxeatpi.po messages.pot
cd tuxeatpi/locale && msgmerge --update --no-fuzzy-matching --backup=off fr/LC_MESSAGES/tuxeatpi.po messages.pot

lang-gen:
cd locale/fr/LC_MESSAGES/ && msgfmt tuxeatpi.po -o tuxeatpi.mo
cd locale/en/LC_MESSAGES/ && msgfmt tuxeatpi.po -o tuxeatpi.mo
cd tuxeatpi/locale/fr/LC_MESSAGES/ && msgfmt tuxeatpi.po -o tuxeatpi.mo
cd tuxeatpi/locale/en/LC_MESSAGES/ && msgfmt tuxeatpi.po -o tuxeatpi.mo

#######################################
### Test targets
Expand Down
6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@
author_email='titilambert@gmail.com',
url="https://github.com/TuxEatPi/tuxeatpi",
download_url="https://github.com/TuxEatPi/tuxeatpi/archive/0.0.1.tar.gz",
package_data={'': ['LICENSE.txt']},
package_data={'': ['LICENSE.txt'], 'tuxeatpi': ['locale/*/LC_MESSAGES/tuxeatpi.po']},
# data_files = [('locale', ['locale/fr/LC_MESSAGES/tuxeatpi.po',
# 'locale/en/LC_MESSAGES/tuxeatpi.po',
# ]
# )],
package_dir={'tuxeatpi': 'tuxeatpi'},
include_package_data=True,
license='Apache 2.0',
Expand Down
6 changes: 3 additions & 3 deletions tuxeatpi/libs/lang.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ def load_languages():
TODO: make it more dynamic
"""
# Prepare
gettext.bindtextdomain('tuxeatpi', 'locale')
gettext.bindtextdomain('tuxeatpi', 'tuxeatpi/locale')
gettext.textdomain('tuxeatpi')
# Load languages
_lang_en = gettext.translation('tuxeatpi', localedir='locale', languages=['en'], fallback=True)
_lang_fr = gettext.translation('tuxeatpi', localedir='locale', languages=['fr'])
_lang_en = gettext.translation('tuxeatpi', localedir='tuxeatpi/locale', languages=['en'], fallback=True)
_lang_fr = gettext.translation('tuxeatpi', localedir='tuxeatpi/locale', languages=['fr'])
# Put languages in dict
LANGUAGES['eng-USA'] = _lang_en
LANGUAGES['fra-FRA'] = _lang_fr
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: 2016-08-29 23:44-0400\n"
"POT-Creation-Date: 2016-08-30 17:25-0400\n"
"PO-Revision-Date: 2016-08-29 23:41-0400\n"
"Last-Translator: \n"
"Language-Team: \n"
Expand All @@ -17,11 +17,11 @@ msgstr ""
"X-Generator: Poedit 1.8.8\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#: tuxeatpi/actions/tux.py:35
#: tuxeatpi/actions/tux.py:34
msgid "My name is {}"
msgstr "My name is {}"

#: tuxeatpi/actions/tux.py:46
#: tuxeatpi/actions/tux.py:45
msgid "I'm born on {}"
msgstr "I'm born on {}"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: 2016-08-29 23:44-0400\n"
"POT-Creation-Date: 2016-08-30 17:25-0400\n"
"PO-Revision-Date: 2016-08-29 22:46-0400\n"
"Last-Translator: \n"
"Language-Team: \n"
Expand All @@ -17,11 +17,11 @@ msgstr ""
"X-Generator: Poedit 1.8.8\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"

#: tuxeatpi/actions/tux.py:35
#: tuxeatpi/actions/tux.py:34
msgid "My name is {}"
msgstr "Mon nom est {}"

#: tuxeatpi/actions/tux.py:46
#: tuxeatpi/actions/tux.py:45
msgid "I'm born on {}"
msgstr "Je suis né {}"

Expand Down

0 comments on commit 46074d9

Please sign in to comment.