Language Sections - main documentation

This will be ongoing documentation, plus links to any generally useful support requests, etc.

Installation

Download the package and unpack into your modules directory in the usual way. Consult Drupal documentation for further information.

Configuration

The default configuration will probably work for most installations.

You will need to enable the module in at least one input format in order to use it. It should probably be the first or one of the first filters in the sequence - this will prevent unnecessary text (for other languages) from being processed by later filters, and so will generally help to improve performance.

Basic use

Mark the start of language sections with === lc === where lc is an appropriate language code for the system. No specific end of section marker is needed - any subsequent section is considered to mark the end of the preceding section.

Special codes all and other may also be used. Sections marked with all will be displayed for all languages. Text before the first language section will also be displayed for all languages. Sections marked with other will be displayed when no section matching the requested language was given. These special codes are configurable.

Example

This is the text as entered:

This text will be displayed for all languages.
=== fr ===
Some French text goes here.
=== es ===
Some Spanish text goes here.
=== other ===
Text in some generic language (e.g. English) goes here.
=== all ===
This part will be displayed for all languages.

When language es is selected by the user, the above text will be filtered to become:

This text will be displayed for all languages.
Some Spanish text goes here.
This part will be displayed for all languages.

When a language other than fr or es is selected by the user, the above text will be filtered to become:

This text will be displayed for all languages.
Text in some generic language (e.g. English) goes here.
This part will be displayed for all languages.

Section markers

Note: Although three = characters are shown in these examples, any number can be used, and there may be no space or more than one space around the language code. i.e. the following are valid and equivalent:

=======   en   =======
=en=

Single line handling

In some cases, it may be useful to have sections in a single line of text, for example:

This is some =en= English =es= Spanish =all= text.

Language codes in the format aa-bb, such as en-uk, are also supported in the default configuration. Other language code formats can be handled by setting the "Alternative pattern" configuration option - see below for an example.

Notes

If you use Language Sections in the body of a node, you probably need to set the node itself to "no language".

Technical notes

In the default configuration, the "trigger" for a language section can be described as the following sequence:

1. one or more '=' characters, then
2. zero or more spaces, then
3. a language code in the format nn or nn-mm, then
4. zero or more spaces, then
5. one or more '=' characters.

This trigger sequence was chosen so as to be easy to use and easily readable in its raw form, at the risk of false triggering should text happen to contain a sequence matching the trigger sequence.

The regular expression pattern used for matching can be edited (configuration setting). Be careful not to change the number of parenthesised groups, as that would probably break the logic.

Comments

Andy Inman’s picture

Assigned: Unassigned » Andy Inman

Please don't post comments here other than "documentation", usage hints, or links to such things. If you have questions or bug reports, open an issue. Thanks.

Andy Inman’s picture

Version: 6.x-2.0 » 6.x-1.4

All languages section

A section marked with all will be output for any language, regardless of whether or not a language-specific section or default section has already been used. For example, these sections might be used to include images, PHP code or other content which is not language specific. Or you could use the any language section to show the main content in English, with short summaries in other languages, each within their own language-specific section.

Other languages section

A section marked with other ("other languages") is similar to an any language section, but will only be used when no specific section was previously found for the current language. Therefore, the position of any other section(s) is important - they should be placed after language-specific sections. For example, you might have language-specific sections in French, Spanish and German followed by an other section in English.

You can have multiple other sections, i.e:

--- language-specific sections
--- other section
--- more language-specific sections
--- second other section

Andy Inman’s picture

I'm new to Drupal - is this module what I need?

Multi-language content in Drupal is usually handled via a combination of the built-in Locale and optional i18n modules. Other possibly applicable modules can be found here.

The Language Sections module provides some features not available when using Locale and i18n alone, but you probably need to first understand what those modules can and can't provide before implementing Language Sections.

divrom’s picture

Title: Documentation » Documentation Updates

How will this effect Search Engine results?

For instance, will a google result show the ===es=== and the language-specific content?

Andy Inman’s picture

Search engines see only the filtered output, just like any other web-site visitor. So if Google is looking at www.example.com/en/mypage it will see only the English version, and it won't see the section markers.

Andy Inman’s picture

Version: 6.x-1.4 » 6.x-1.7

As of version 1.7, you can use all and other for all languages and other language. The old markers (qq and qz) are still supported for backward-compatibility with existing content. Version 2.x goes further - makes these triggers fully configurable, and allows multiple triggers. Multiple triggers might include a meaningful words in several languages, such as all, todos, toutes so that content creators could use whichever made most sense to them.

Andy Inman’s picture

With Version 2.x now released, this documentation is a little out of date, but the majority of it is still valid.

With the new options in version 2, a typical Language Sections based page might hold:

=== french ===
Text in French, displayed to users who have chosen French.
=== spanish ===
Text in Spanish, displayed to users who have chosen Spanish.
=== english ===
Text in English, displayed to users who have chosen a language other than French or Spanish - we are are using English as a "generic" language.

That would be a configuration where triggers were set to use language name and english was set as a trigger for other language sections.

almamun’s picture

Version: 7.x-2.x-dev » 6.x-2.0

What about url? How this could be different for different language?

----------------------------
Dinajpur- My District Portal,
Rangpur-Another Local Portal (Drupal Powered)
Banglajogot- Bangla Web Design Blog (Drupal Powered)
JoomlaBangla - Joomla! Bangla Support Site

Andy Inman’s picture

Issue summary: View changes

Updated for more recent versions.

Andy Inman’s picture

Issue summary: View changes

others->other

Andy Inman’s picture

Version: 6.x-1.7 » 6.x-2.0

I'm not sure if I understand the question. You could do it with LS, but you might also want to take a look at MultiLink.

Andy Inman’s picture

Version: 6.x-2.0 » 7.x-2.x-dev

D7 version

The current 7.x-2.x release has identical functionality to 6.x-2.5 except for the following changes:

  • Settings for the module are global for all input formats (equivalent to setting the shared configuration option in D6 versions.)
  • The old qq and qz markers have been removed. If you have a site upgraded from D6 and existing content which uses qq/qz, simply define them in the settings page.
ctmun’s picture

Version: 6.x-1.4 » 7.x-2.x-dev
ctmun’s picture

Issue summary: View changes

Replaced quotes with italics,added more tags