Skip to content

Commit

Permalink
Updated docs. Pypi package info and files.
Browse files Browse the repository at this point in the history
  • Loading branch information
sromero84 committed Aug 27, 2012
1 parent 12afebc commit db160a1
Show file tree
Hide file tree
Showing 6 changed files with 179 additions and 7 deletions.
File renamed without changes.
9 changes: 9 additions & 0 deletions MANIFEST
@@ -0,0 +1,9 @@
LICENSE
README.md
README.txt
setup.py
i18n_helper/__init__.py
i18n_helper/models.py
i18n_helper/tests.py
i18n_helper/views.py
i18n_helper/wraptools.py
3 changes: 3 additions & 0 deletions MANIFEST.in
@@ -0,0 +1,3 @@
include README.md
include LICENSE
recursive-include i18n_helper *.py
19 changes: 12 additions & 7 deletions README.md
Expand Up @@ -18,18 +18,23 @@ How does it works
Django i18n helper is a common Django app that overriddes Django core functions
on load to provide the desired behavior.

The application will automatically detect when tests are being run and don't override any methods to preserve tests integrity.
The application will automatically detect when tests are being run and don't
override any methods in such a case to preserve tests integrity.


Installation
------------

All you need to do is add "django-i18n-helper" to your installed apps and
activate the internationalization debug. In your settings.py make sure to have:
Get it

pip install django-i18n-helper

After, all you need to do is add "i18n_helper" to your installed apps and
activate the internationalization debug. In your settings.py, make sure to have:

INSTALLED_APPS = (
...,
'django-i18n-helper'
'i18n_helper'
)

and
Expand Down Expand Up @@ -88,7 +93,7 @@ Graphical examples are sometimes the better way to understand how does something
Fully translated templates


<img src='http://pictat.com/i/2012/8/22/39364traslated1.png'/>
<img src='http://pictat.com/i/2012/8/27/16220screenshot.png'/>

<img src='http://pictat.com/i/2012/8/22/11913traslated2.png'/>

Expand All @@ -102,7 +107,7 @@ Partially translated templates. Note that it's also possible to see from the adm
Disclaimer Notes
----------------

The application should **only** be used when debugging code translations, since it overrides the default Django HTML scaping mechanism and thus outputs unescaped (possibly undesired) code.
The application should **only** be used when "debugging" code translations, since it overrides the default Django HTML scaping mechanism and thus outputs unescaped (possibly undesired) code.
Besides, there are some warnings you should be aware of:

* You will see weird HTML within you buttons or inputs if you have things like &lt;input type="text" value="{% trans "Search" %}" ...&gt; Then the wrapping HTML of your translations will be shown _within_ the inputs or buttons. This will happen for sure in the admin site.
Expand All @@ -118,4 +123,4 @@ Tested with
-----------

* Django 1.4
* Python 2.6.1
* Python 2.6.1
126 changes: 126 additions & 0 deletions README.txt
@@ -0,0 +1,126 @@
Django i18n helper
==================

Provides a simple way to visualize translated strings in Django templates
by wrapping translated content with custom HTML and CSS. Therefore and
most important, helps you to visualize untraslated strings too.

This is particularly useful when internationalization is being added to a
project.

Author: Santiago Gabriel Romero

Contact: sromero@machinalis.com

How does it works
-----------------

Django i18n helper is a common Django app that overriddes Django core functions
on load to provide the desired behavior.

The application will automatically detect when tests are being run and don't
override any methods in such a case to preserve tests integrity.


Installation
------------

Get it

pip install django-i18n-helper

After, all you need to do is add "i18n_helper" to your installed apps and
activate the internationalization debug. In your settings.py, make sure to have:

INSTALLED_APPS = (
...,
'i18n_helper'
)

and

I18N_HELPER_DEBUG = True

django-i18n-helper provides a default behavior that consists in wrapping the
translated content with an HTML div with the following properties:

<div class='i18n-helper' style='display: inline; background-color: #FAF9A7;'>Translated text</div>

This provides a soft highlight for translated strings, but this behavior can be
modified within settings.py.


Customization
-------------

Some configuration variables are provided on order to customize how you want the translated strings to be wrapped.

#### I18N_HELPER_HTML

Defines a whole HTML block for wrapping the translations. This string will be
formatted (http://docs.python.org/library/stdtypes.html#str.format) with the
translated text. Thus every occurrence of "{0}" will be replaced with the
translation.

I18N_HELPER_HTML = "<span class='highlight'>{0}</span>"

If I18N_HELPER_HTMLis not set, the code used will be

<div class='i18n-helper' style='display: inline; background-color: #FAF9A7;'>{0}</div>


#### I18N_HELPER_CLASS

Defines the class to use for the HTML div if I18N_HELPER_HTML is not used. Defaults to "i18n-helper".

I18N_HELPER_CLASS = "my-custom-class"


#### I18N_HELPER_STYLE

Defines the inline CSS for the HTML div if no I18N_HELPER_HTML or
I18N_HELPER_CLASS have been set (case in which it's assumed that the styles
for the class provides the needed css). Defaults to ""display: inline; background-color: #FAF9A7;".

I18N_HELPER_CLASS = "font-weight: bold; background-color: yellow;"


Screenshots
-----------

Graphical examples are sometimes the better way to understand how does something works or looks like. So here go two examples of how completely translated templates would look like, and two of how partially translated templates would.

Fully translated templates


<img src='http://pictat.com/i/2012/8/27/16220screenshot.png'/>

<img src='http://pictat.com/i/2012/8/22/11913traslated2.png'/>

Partially translated templates. Note that it's also possible to see from the admin site which model fields haven't set the _verbose_name_ attribute to translate the field name.

<img src='http://pictat.com/i/2012/8/22/23861untraslate.png'/>

<img src='http://pictat.com/i/2012/8/22/21074untraslate.png'/>


Disclaimer Notes
----------------

The application should **only** be used when "debugging" code translations, since it overrides the default Django HTML scaping mechanism and thus outputs unescaped (possibly undesired) code.
Besides, there are some warnings you should be aware of:

* You will see weird HTML within you buttons or inputs if you have things like &lt;input type="text" value="{% trans "Search" %}" ...&gt; Then the wrapping HTML of your translations will be shown _within_ the inputs or buttons. This will happen for sure in the admin site.

* Your database might not sync and show errors like "value too long for type character varying(50)". Set I18N_HELPER_DEBUG to False if this happens.

* Your migrations might not work and show errors like "value too long for type character varying(50)". Set I18N_HELPER_DEBUG to False if this happens.

* Some capitalization might be lost


Tested with
-----------

* Django 1.4
* Python 2.6.1
29 changes: 29 additions & 0 deletions setup.py
@@ -0,0 +1,29 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

with open('README.md') as readme:
__doc__ = readme.read()

from distutils.core import setup

setup(
name='django-i18n-helper',
version='0.1',
description=u'A internationalization helper that highlights translated strings',
long_description=__doc__,
author = u'Santiago Gabriel Romero',
author_email = 'sromero@machinalis.com',
url='https://github.com/machinalis/django-i18n-helper',
packages=['i18n_helper'],
classifiers = [
'Development Status :: 4 - Beta',
'Environment :: Web Environment',
'Intended Audience :: Developers',
'Framework :: Django',
'License :: OSI Approved :: BSD License',
'Natural Language :: English',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
],
)

0 comments on commit db160a1

Please sign in to comment.