All Projects → angvp → django-klingon

angvp / django-klingon

Licence: LGPL-3.0 License
An app that allows you to translate anything in any language, even klingon ;)

Programming Languages

python
139335 projects - #7 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to django-klingon

v-page
A simple pagination bar, including length Menu, i18n support, based on Vue2.x
Stars: ✭ 85 (+129.73%)
Mutual labels:  i18n
nuxt-i18n-boilerplate
A boilerplate for rapid application development using Nuxt i18n.
Stars: ✭ 20 (-45.95%)
Mutual labels:  i18n
awrora-starter
Landing page template built with one of most popular javascript library Vue.JS, Vuetify (Material Design) and Nuxt.JS with SSR.
Stars: ✭ 38 (+2.7%)
Mutual labels:  i18n
GetCurrency
List all currencies available in NSLocale programmatically using swift 3
Stars: ✭ 18 (-51.35%)
Mutual labels:  i18n
gatsby-simple-blog
an easily configurable gatsby-starter-blog with overreacted looking and tags, breadcrumbs, disqus, i18n, eslint, algolia supported
Stars: ✭ 48 (+29.73%)
Mutual labels:  i18n
jekyll-skeleton
Scaffolding to start with a Jekyll website
Stars: ✭ 27 (-27.03%)
Mutual labels:  i18n
acts as localized
Localization accessor mechanism for AR models
Stars: ✭ 12 (-67.57%)
Mutual labels:  i18n
rosetta
A blazing fast internationalization (i18n) library for Crystal with compile-time key lookup.
Stars: ✭ 23 (-37.84%)
Mutual labels:  i18n
humanize time
Adds the humanize method to reports the approximate distance in time between two Time. humanize supports i18n translations too so it can be used in internationalized apps.
Stars: ✭ 20 (-45.95%)
Mutual labels:  i18n
nodejs-uk
Переклад Node.js українською мовою
Stars: ✭ 30 (-18.92%)
Mutual labels:  i18n
react-put
A flexible formatter and i18n interface for React.
Stars: ✭ 23 (-37.84%)
Mutual labels:  i18n
django-languages-plus
Provides models and fixtures for working with both common languages and 'culture codes' or locale codes, like pt-BR.
Stars: ✭ 21 (-43.24%)
Mutual labels:  i18n
cosmopolite
Typesafe internationalization for Scala
Stars: ✭ 15 (-59.46%)
Mutual labels:  i18n
address-formatter
Universal international address formatter in Javascript
Stars: ✭ 65 (+75.68%)
Mutual labels:  i18n
express-mvc
A light-weight mvc pattern for express framework with minimum dependencies
Stars: ✭ 23 (-37.84%)
Mutual labels:  i18n
icu-demos
sample apps for ICU (formerly icuapps)
Stars: ✭ 13 (-64.86%)
Mutual labels:  i18n
pyseeyou
A Python ICU MessageFormat parsing tool
Stars: ✭ 13 (-64.86%)
Mutual labels:  i18n
gettext i18n rails js
Extends gettext_i18n_rails making your .PO files available to client side javascript as JSON
Stars: ✭ 28 (-24.32%)
Mutual labels:  i18n
react-text-translator
An experimental way to translate text inside React components with context
Stars: ✭ 15 (-59.46%)
Mutual labels:  i18n
f3-multilang
Create multilingual apps with this localization plugin for the PHP Fat-Free Framework
Stars: ✭ 44 (+18.92%)
Mutual labels:  i18n

django-klingon

https://coveralls.io/repos/angvp/django-klingon/badge.png?branch=master https://travis-ci.org/angvp/django-klingon.svg?branch=master Documentation Status Code Climate

Welcome to the documentation for django-klingon!

django-klingon is an attempt to make django model translations suck but with no integrations pain in your app!

Setup & Integration

In your settings files: add django-klingon to INSTALLED_APPS:

INSTALLED_APPS = (
    ...
    'klingon',
    ...
)

specify a default language if you want to use your fields to store the default language:

KLINGON_DEFAULT_LANGUAGE = 'en'

Extend you models to add API support: first add Translatable to your model Class definition. This will add the API functions:

from klingon.models import Translatable
...
class Book(models.Model, Translatable):
...

in the same model add an attribute to indicate which fields will be translatables:

...
translatable_fields = ('title', 'description')
...

your model should look like this:

class Book(models.Model, Translatable):
    title = models.CharField(max_length=100)
    description = models.TextField()
    publication_date = models.DateField()

    translatable_fields = ('title', 'description')

Add admin capabilities:

you can include an inline to your model admin and a custom action to create the translations. To do this in your ModelAdmin class do this:

from klingon.admin import TranslationInline, create_translations
...
class BookAdmin(admin.ModelAdmin):
    ...
    inlines = [TranslationInline]
    actions = [create_translations]
  • see full example in example_project folder of source code of klingon

Using Specific Widgets in the TranslationInline form of the admin:

You can specify the widget to be use on an inline form by passing a dictionary to TranslationInlineForm. So, you might want to extend the TranslationInline with a new form that will a "widgets" dictionary, where you can specify the widget that each filds has to use, for example:

class RichTranslationInlineForm(TranslationInlineForm):
    widgets = {
        'CharField': forms.TextInput(attrs={'class': 'klingon-char-field'}),
        'TextField': forms.Textarea(attrs={'class': 'klingon-text-field'}),
    }

class RichTranslationInline(TranslationInline):
    form = RichTranslationInlineForm

and then you just simply use the RichTranslationInline class on your AdminModels, for example:

class BookAdmin(admin.ModelAdmin):
    inlines = [RichTranslationInline]
  • see full example in example_project folder of source code of klingon

Using the API

To create the translation you can do the follwing:

Suppose that you have and object called book:

> book = Book.objects.create(
    title="The Raven",
    description="The Raven is a narrative poem",
    publication_date=datetime.date(1845, 1, 1)
)

you can create translation for that instances like this:

> book.set_translation('es', 'title', 'El Cuervo')
> book.set_translation('es', 'description', 'El Cuervo es un poema narrativo')

a translation could be access individually:

> self.book.get_translation('es', 'title')
'El Cuervo'
> book.get_translation('es', 'description')
'El Cuervo es un poema narrativo'

or you can get all translations together:

> self.book.translations('es')
{
    'title': self.es_title,
    'description': self.es_description,
}

Installation:

pip install django-klingon

Running the Tests

You can run the tests with via:

python setup.py test

or:

python runtests.py
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].