Abstracting language settings out of locale (updated)

Events happening in the community are now at Drupal community events on www.drupal.org.
gábor hojtsy's picture

The first implementation detail we are looking at for Drupal 6-dev i18n is abstracting language settings out of the locale interface. In Drupal 5, the locale module handles the list of available languages (which is reused in i18n related contrib modules). The data stored about languages is not enough for most purposes (native names are not stored, RTL-LTR direction information is not available), and extending modules really have no way to plug into the language management screen.

The goal here is to have a language management interface, where you can get a handle on the languages you would like to make available on your site (either as interface languages and/or content languages, it does not matter). The languages will be stored more generically (ie not in a "locale_*" table), so they are to be reused by design by the locale and any other translation modules.

Note: screenshot updated to reflect latest development.
Language management screen
Visit the flickr page for notes and full screen view.

This new approach dictates that languages should have their own management screen. I got into doing a first mockup this morning, so we see where we are going and can talk about interface, code and database schemas if need be. In this mockup, the import and export functionality (which is actually tied to interface translations and not to languages) is moved to an interface string management screen. Also we get the locale related pieces removed from languages table, and new details added.

Thanks to tips from Jose Reyero, here we have the native name of languages stored, so we can show a better list of selectable languages on a German page for example showing native names too. We also store the directionality of the langauge used, so themes can conform to LTR and RTL languages too. The Drupal built in language list (in locale.inc) already has the native languages listed, we need to extend it with the directionality information, so if you add a language by picking one from the list, you get the right directionality with it.

This is a generic language list management screen. How this can be reused (or even extended) by locale and i18n related functionality is still an open question.

  • Either we allow altering of the displayed form, so modules can add columns (like "enable for interface localization", "interface localization percentage" and such).
  • Or locale and i18n related functionality can provide their own tables, where the language list is a given, and specific setup options are presented there.
  • A third option would be to have a language editing interface per language (simlifying the overview table to not display a form, but really only some information), where settings can be placed. Block editing is a possible model for this kind of interface.

A bigger architectural question is where the language management code should reside. Either we should add a language.module to handle general language setup, or we keep this functionality as part of the locale module. The question is wheter it is deemed a valid use case when someone does not need interface translation functionality but needs content translation functionality (eg. an English blog with ocassional French posts, but no French interface). On such a site, the locale module would be something to get rid of, if possible.

Questions to you:

  • Do you have anything generic to store per language (which is not already stored in Drupal 5 and is not in the above mockup)?
  • Is the above interface useable, or we need a separate editing screen even for these basic settings?
  • Should we tie language management into locale module or a new language.module (on which locale and i18n functionality depend)?
  • You surely have something else to add, which I am not thiking of!

Get the code from the Development Seed SVN, where anonymous checkout is allowed.

Comments

screenshot updated

gábor hojtsy's picture

I have updated the screenshot to reflect the latest development stage. Now languages have an edit page, and only "overview" type settings are displayed in this form. This table based interface is inspired by (takes concepts from) the module admin page and the blocks admin page.

Two-byte code

aries's picture

Do you think that two byte (ISO) code is enough for dialects? Big countries like China or English Spoken World has many forks from their roots.

Aries

Aries

gábor hojtsy's picture

Drupal core itself has support for more complicated codes like zh-hans or zh-hant (or pt-br for that matter). This is already in Drupal 5, our work does not limit this, nor do we expand on this support as it seems to be adequate.

Internationalization

Group organizers

Group categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: