Giter VIP home page Giter VIP logo

django-transadmin's Introduction

Django Transadmin - Translate your text from the admin

Categories: (translation, internationalization, i18n)

Build Status

Works on Python 3.x and Python 2.6 or more.

Compatible with the default Django template, Jinja2 and Jingo

Benefits

Administrate your translations directly from the admin. Import your translations string from po files. Compatible with Jingo

Quick tour

In a template:

{{ _("String to translate") }}

In a python file:

from transadmin.helpers import _

translated_text = _("String to translate")
Import translation

You can directly create a string to translate from the admin. When it comes to generate many pages, you may prefer the automation script.

Manually

get to your admin (transadmin > Translation) and add:

  • source: "String to translate"
  • language: "fr"
  • trans: "Chaine à traduire"
Automation script

Django allows you to generate po files from templates, views and so on:

django-admin.py makemessages -l fr

Transadmin then allows you to import a po file into the database:

python manage.py transadmin_import my/fr/file.po -l fr

This command reads translations from my/file.po and import every string into the database for fr language.

Your untranslated strings are now ready to get translated from the admin!

Even though the transadmin_import command is safe and preserves your existing data. You are highly encouraged to make a backup before running such commands.

You can now view your website in French.

Installation

Download

Via pip latest version

pip install django-transadmin

or the bleeding edge version

pip install -e git+https://github.com/vinyll/django-transadmin.git#egg=django-transadmin

update INSTALLED_APPS

In settings.py, add transadmin in your INSTALLED_APPS

INSTALLED_APPS = (
	# …,
	'transadmin',
)

Congratulations, you're all set!

Configuration

A few settings are available:

  • TRANSADMIN_LANGUAGES: a tuple of tuples for available languages for the admin. Reads the settings.LANGUAGES by default.
  • TRANSADMIN_CONTEXTS: a tuple of tuples for available context. Free text by default.
  • TRANSADMIN_FALLBACK_LANGUAGE: a string representing the code of the language to fallback to if a string is not translated into the current language. No fallback by default, displays the untranslated text.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.