Adding Language Awareness - ΩJr. Publizjr Creates Web Pages

This information lives on a webpage hosted at the following web address: 'https://omegajunior.globat.com/code/publizjr/'.

How to implement multi-language awareness to Publizjr 1 Generator Templates. This article is aimed at webmasters and capable PHP programmers.

The webmaster can choose to use a language-aware Publizjr Generator template. This is useful for multi-lingual web sites. The Failure Notes on the OmegaJunior Consultancy serve as an example.

Any web site section using Publizjr can have multiple generator templates per section folder. By default, Publizjr Generator Templates come in 2 varieties: a simple one and a complex, language-aware template.

The webmaster should place the multi-language Publizjr Generator template (to be found in the required parts download) in the desired web page section's root folder, name it 'index.php' or whatever has been set as the site's default document. Then either rename or remove the simple template.

Localised Sub Folders

Each folder for a page that needs translating, needs localised sub folders. Each of these should be named after the 2-letter code each locale is assigned, thus making them into locale folders. (More exotic locale codes are not supported yet. Contact us if such a need arises.)

Common locale codes include 'en', 'de', 'nl', 'fr', 'es'. This is part of the same language code that the web browser sends to the server automatically, meaning the visitor receives content set in their preferred language, if available. No other language selector needed.

Depending on the content authors' hierarchy, the locale sub folders could be created by the web master or by the content authors themselves. Which is allowed can be set by the webmaster, granting folder access priviliges.

Each locale sub folder should contain a translated copy of the page content texts. If the template cannot find a folder named after the preferred language, it will show the text pieces available in the main page folder. This means, unfortunately, that some content may exist twice. The benefit is a high granularity of access privileges.


Non-Editorial Texts

The multi-language Publizjr Generator template contains some labels and titles a page author cannot change. To make those language-aware too, the 'translations' folder (to be found in the required parts download) which should exist in the site root, requires addition of a locale folder per supported linguistic culture.

Each locale sub folder should receive translated texts, with file names equaling the main translation texts. The template combines the locale code with the unique translation file name to retrieve the correct text in the desired language, falling back to the default text if the desired language or text should prove amiss.

The translations folder may contain texts, PHP snippets, HTML snippets, etc. It should not be accessible to content authors.

Note: the integration with Disqus Page Comments can be made language aware, too.

Interested?

Let's meet for coffee or over lunch. Talk to me using this form.