Skip to content

Adding a Locale to Phaidra (i18n)

mariamoritz edited this page Nov 11, 2014 · 8 revisions

Steps for adding a locale to Phaidra

  1. Interface localization (HTML and Javascript Templates, Javascript)
  2. Content localization (Admin)
  3. Save your work!
  4. Adding a translated (and aligned) work

Steps for adding a locale to Phaidra

1. Interface localization

Prologue: Include the language

Open up phaidra/settings.py. In the section LANGUAGES, add the language:

LANGUAGES = (
   ('en', 'English'),
   ('fa', 'Farsi'),
   ('de', 'German'),
   ('it', 'Italian'),
   ('hr', 'Croatian')
)

From the root directory of the project, run:

$ fab prepare_locale:de

Replace 'de' with the two-letter locale code. This command is rather slow, so just be patient 😄

Interface Localization

Open /opt/phaidra/locale/*/LC_MESSAGES/django.po, where * is the locale code you are interested in. You will find sets of strings which look something like this:

# templates/something.html:123
msgid "Words in English"
msgstr "Wörter auf Deutsch"

The msgid is always the original in the file, and the msgstr is your translation. Simply go through this document and translate the English into your target language.

Compilemessages

Once you've translated the strings in django.po and djangojs.po, you need to compile them.

$ fab compile_locale:de

Replace 'de' with the two-letter locale code.

2. Textbook Localization

Log in to the Phaidra Admin. You will need to create items within the following App categories:

  • Languages
  • Content

Simply assign the language you're working on to the Content you create, and it will show up on the interface when the language is selected.

When you go to YOUR_IP_ADDRESS:8000/*/lessons/, you will see which lessons still need content.

3. Save your work!

In order to propagate the changes you've made within the admin panel to github, so others can load in your content as well, run the following command.

fab propagate_db
git add app/fixtures/db.json && git add locale

Run git status to confirm that your changes are properly staged, then git commit and push as usual.


4. Add a source text to Phaidra

This workflow will be improved very soon

  1. Copy your XML file into common/utils/neo4j_import/data.

  2. Open up common/utils/neo4j_import/import_alignment.py and add an entry to the LANGUAGES dictionary. At the time of writing, it looks like this:

languages = {
    'en': Document('Thucydides', 'The Pentecontaetia', 'eng', 'en', 
        'urn:cts:greekLit:tlg0003.tlg001.perseus-grc'),
    'fa': Document('ﺕﻮﺳیﺩیﺩ', 'ﺕﺍﺭیﺥ پﻦﺟﺎﻫ ﺱﺎﻟ گﺬﺸﺘﻫ', 'fas', 'fa', 
        'urn:cts:greekLit:tlg0003.tlg001.perseus-grc'),
    'hr': Document('Tukidid', 'Povijest Peloponeskograta', 'hrv', 'hr',
        'urn:cts:greekLit:tlg0003.tlg001.perseus-grc')
}

Simply add another entry with the data in order: Author language, Translated Work, 3-letter language code, 2-letter language code, source URN.

  1. From the root directory, run fab with your choosen language as parameter, e.g. fab import_alignment:lang='en'.

  2. optional: you can also run fab import_alignment:lang='all' if you want to run all alignment data at once.


Additional steps for adding a source language to Phaidra

Developer Guide

Backend

Frontend

Content Guide

What did you break?

  • Postgres Database
  • Neo4j
  • Django
  • "The server"
  • Git
  • UI
Clone this wiki locally