Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions app/src/processing/app/i18n/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Internationalization Tools

by @sgk at SwitchScience.

## Reflect the source code change

Sometimes, the developers add/delete/modify the strings which should be translated. You have to reflect the source code change to your translation. This can be done as below given your language code `xx`.

% ./update.sh xx

This will extract the up-to-date set of strings from the source code, set the translated strings from the current "`Resources_xx.po`" file, and then write back to "`Resources_xx.po`" file. If the developers delete/modify the strings, corresponding translated strings disappear from the file. You may want to do like this.

% git commit
% ./update.sh xx
% git diff Resrouces_xx.po
% git add Resources_xx.po Resources_xx.properties
% git commit

## Get the translated catalog from Transifex

You may want to retrieve the translation contribution from Transifex. This can be done as below given your language code `xx`.

% ./pull.sh xx

Translation strings for only strings already in "`Resources_xx.po`" file will be updated. If Transifex has translated strings which are not in "`Resources_xx.po`" file, the strings will not appear in the file.

If you want to retrieve the newly translated language which is not in the Git repository, you will want to do like this.

% cp Resources_en.po Resources_xx.po
% ./pull.sh xx
% more Resources_xx.po
% git add Resources_xx.po Resources_xx.properties
% git commit

## Send the translated catalog to Transifex

You can send the translated catalog file "`Resources_xx.po`" to Transifex using the following command line where `xx` is the language code.

% ./push.sh xx

Be aware that this will overwrite the current result on Transifex. You may want to do "./update.sh" and "./pull.sh" before doing "./push.sh".

## Select "all" languages

**For the comitter only.** For all above scripts, you can select all languages by specifying "-a" instead of language codes like this.

% ./update.sh -a

The "all" means all the languages currently in your working directory. This does not mean the languages on Transifex.
73 changes: 0 additions & 73 deletions app/src/processing/app/i18n/i18n_update.py

This file was deleted.

42 changes: 0 additions & 42 deletions app/src/processing/app/i18n/i18n_update.sh

This file was deleted.

31 changes: 31 additions & 0 deletions app/src/processing/app/i18n/pull.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

if [ $0 != "./pull.sh" ]; then
echo "pull.sh: Invoke this script as ./pull.sh"
exit 1
fi

while [ $# -gt 0 ]; do
if [ $1 = '-a' ]; then
for f in Resources_*.po; do
f=$(expr "$f" : "Resources_\(.*\).po")
langs="$langs $f"
done
else
langs="$langs $1"
fi
shift
done

if [ "$langs" = "" ]; then
echo "pull.sh: Give at least one language code."
exit 1
fi

python python/pull.py $langs

for lang in $langs; do
if [ -f "Resources_$lang.po" ]; then
msgcat -p Resources_$lang.po > Resources_$lang.properties
fi
done
25 changes: 25 additions & 0 deletions app/src/processing/app/i18n/push.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

if [ $0 != "./push.sh" ]; then
echo "push.sh: Invoke this script as ./push.sh"
exit 1
fi

while [ $# -gt 0 ]; do
if [ $1 = '-a' ]; then
for f in Resources_*.po; do
f=$(expr "$f" : "Resources_\(.*\).po")
langs="$langs $f"
done
else
langs="$langs $1"
fi
shift
done

if [ "$langs" = "" ]; then
echo "push.sh: Give at least one language code."
exit 1
fi

exec python python/push.py $langs
1 change: 1 addition & 0 deletions app/src/processing/app/i18n/python/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.pyc
31 changes: 31 additions & 0 deletions app/src/processing/app/i18n/python/pull.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env python
#vim:set fileencoding=utf-8 sw=2 expandtab

from transifex import Transifex

def main():
import getpass
import sys

print 'Use your account to talk with Transifex.'
user = raw_input('Username: ')
passwd = getpass.getpass('Password: ')
trans = Transifex(user, passwd)

for lang in sys.argv[1:]:
fname = 'Resources_%s.po' % lang
print "Updating %s from Transifex..." % fname,
sys.stdout.flush()
try:
lang = trans.canonical_lang(lang)
trans.pull(lang, fname)
except RuntimeError, e:
print e.message
continue
except IOError, e:
print e.strerror
continue
print

if __name__ == '__main__':
main()
31 changes: 31 additions & 0 deletions app/src/processing/app/i18n/python/push.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env python
#vim:set fileencoding=utf-8 sw=2 expandtab

from transifex import Transifex

def main():
import getpass
import sys

print 'Use your account to talk with Transifex.'
user = raw_input('Username: ')
passwd = getpass.getpass('Password: ')
trans = Transifex(user, passwd)

for lang in sys.argv[1:]:
fname = 'Resources_%s.po' % lang
print "Updating %s on Transifex using %s..." % (lang, fname),
sys.stdout.flush()
try:
lang = trans.canonical_lang(lang)
trans.push(lang, ''.join(open(fname)))
except RuntimeError, e:
print e.message
continue
except IOError, e:
print e.strerror
continue
print

if __name__ == '__main__':
main()
71 changes: 71 additions & 0 deletions app/src/processing/app/i18n/python/requests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# -*- coding: utf-8 -*-

# __
# /__) _ _ _ _ _/ _
# / ( (- (/ (/ (- _) / _)
# /

"""
requests HTTP library
~~~~~~~~~~~~~~~~~~~~~

Requests is an HTTP library, written in Python, for human beings. Basic GET
usage:

>>> import requests
>>> r = requests.get('http://python.org')
>>> r.status_code
200
>>> 'Python is a programming language' in r.content
True

... or POST:

>>> payload = dict(key1='value1', key2='value2')
>>> r = requests.post("http://httpbin.org/post", data=payload)
>>> print r.text
{
...
"form": {
"key2": "value2",
"key1": "value1"
},
...
}

The other HTTP methods are supported - see `requests.api`. Full documentation
is at <http://python-requests.org>.

:copyright: (c) 2013 by Kenneth Reitz.
:license: Apache 2.0, see LICENSE for more details.

"""

__title__ = 'requests'
__version__ = '1.1.0'
__build__ = 0x010100
__author__ = 'Kenneth Reitz'
__license__ = 'Apache 2.0'
__copyright__ = 'Copyright 2013 Kenneth Reitz'


from . import utils
from .models import Request, Response, PreparedRequest
from .api import request, get, head, post, patch, put, delete, options
from .sessions import session, Session
from .status_codes import codes
from .exceptions import (
RequestException, Timeout, URLRequired,
TooManyRedirects, HTTPError, ConnectionError
)

# Set default logging handler to avoid "No handler found" warnings.
import logging
try: # Python 2.7+
from logging import NullHandler
except ImportError:
class NullHandler(logging.Handler):
def emit(self, record):
pass

logging.getLogger(__name__).addHandler(NullHandler())
Loading