Actions

Difference between revisions of "Specification of language files"

From Joomla! Documentation

Line 36: Line 36:
 
[[Category:Specifications]]
 
[[Category:Specifications]]
 
[[Category:Specifications Version 1.6]]
 
[[Category:Specifications Version 1.6]]
 +
[[Category:References]][[Category:Language Development]]

Revision as of 02:54, 20 September 2010

This page explains the changes of the language file specification from version 1.5 to 1.6. As this is currently under development it is not merged back to the central specification page.

The 1.5 specification is described in Creating a language definition file.

Overview of changes in Joomla 1.6 Joomla 1.6

  1. The KEY is now defined to be
    1. without any whitespace. All whitespace shall be converted into a underscore '_'
    2. All KEY's in the frontend shall include a prefix of the extension

Additional information from a new thread

So, the implications on ini file format:

  1. As previously mentioned, our keys will have to change. Spaces are not allowed. The general practice will be to use underscores for spacing. Also, the plan is to name space strings, so that you would end up with something like COM_EXAMPLE_MYKEY for your key. According to the php manual, The characters {}|&~![()^" cannot be used in keys. There are also reserved words for keys: null, yes, no, true, false, on, off, none.
  2. The syntax for the value will also change. According to the PHP manual, if a value in the ini file contains any non-alphanumeric characters it needs to be enclosed in double-quotes ("). That will basically mean all of our values will have to be enclosed in quotes, as a space is non alpha numeric. From what I gather, if you want to include a double-quote in your string, you use two double-quotes. Finally, according to the PHP manual, the {}|&~![()^" characters have a special meaning in the value. Unfortunately, they don't really unpack what that special meaning is - anybody have experience in this area?
  3. Comment syntax will change, as we are typically using pound signs (#) and the standard parser requires semi colons (;).

Updating your Joomla 1.5 language files to work on Joomla 1.6

Using the native php ini parser for language files has many benefits including much faster performace. Converting your exisiting Joomla 1.5 into the new format is very easy if you use a coding platform like eclipse. Search your file for *.ini in your project of choice. Then use the following search/replace values to automatically, replace exisiting quotes, add quotes to string values and update your comments

  1. Double quotes are now not allowed and this can be easily bypassed by searching " and replace with '
  2. Put a closing double quote at end of line if not empty or a comment. Find ^((?!#).+)\R replace with $1"\R
  3. Put an opening quote at start of translated string if not empty or comment. Find ^((?!#).+?\=)(.+)\R replace with $1"$2\R
  4. Now replace the hash comments with the new semi colon. Find ^# and replace with ;


Related discussion threads in the development mailing list