Documentation Updates
| Project: | Language Sections |
| Version: | 6.x-1.4 |
| Component: | Documentation |
| Category: | task |
| Priority: | normal |
| Assigned: | netgenius |
| Status: | active |
Jump to:
Language Sections - main documentation
This will be ongoing documentation, plus links to any generally useful support requests, etc.
Installation
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 work for most installations. However, if you need to use languages such as Chinese, you may need to configure the "Alternative pattern" option.
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, so set its "weight" to a low number. 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. The pseudo language code "qq" is used to represent "no language" - sections marked with "qq" will be displayed for all languages. Text before the first language section will also be displayed for all languages.
Example
This is the text as entered:
---------------------
This text will be displayed for all languages.
=== es ===
Some Spanish text goes here.
=== en ===
Some English text goes here.
=== qq ===
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.
---------------------
Single line sections
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 =======
=es=
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 =qq= 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.
Chinese and other longer language codes
Some languages, for example Chinese, may require a longer language code (five characters in the second part) so the default configuration will not work. Here's the solution:
Goto the configuration screen (filters, configuration) and set the "Use alternative pattern" option and copy/paste the pattern below:
Alternative pattern:
/(=+ *([a-z]{2}|[a-z]{2}-[a-z]{2,5}) *=+\s?)(.*?)/
Note, if you have more than one "Input filter" which uses Language Sections, you will need to configure each one in this way.

#1
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.
#2
Any language section (qq)
A section marked with the pseudo-language-code qq 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.
Default section (qz)
A default section is similar to an any language section, but will only be used when when no specific section was previously found for the current language. Therefore, the position of any default 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 a default section in English. Mark default sections with the pseudo-language-code qz.
You can have multiple default sections, i.e:
--- language-specific sections
--- default section
--- more language-specific sections
--- another default section
#3
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.
#4
How will this effect Search Engine results?
For instance, will a google result show the ===es=== and the language-specific content?
#5
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.