Actions

Difference between revisions of "Specification of language files"

From Joomla! Documentation

(Overview of changes in Joomla 1.6 {{JVer|1.6}})
m (Added a link to an automated tool that perform 1.5 to 1.6 language updates)
Line 16: Line 16:
  
 
== Updating your Joomla 1.5 language files to work on Joomla 1.6 ==   
 
== 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
+
Using the native php ini parser for language files has many benefits including much faster performance.
  
#Double quotes are now not allowed and this can be easily bypassed by searching " and replace with '
+
Basically, you have two options:
#Put a closing double quote at end of line if not empty or a comment.  Find ^((?!#).+)\R  replace with $1"\R
+
# A free online tool is available here: http://demo.yoorock.fr/en/language-updater-j15-g-j16. This tool exactly does what is described in the Eclipse solution.
#Put an opening quote at start of translated string if not empty or comment. Find ^((?!#).+?\=)(.+)\R replace with $1"$2\R
+
# The Eclipse solution (or any other Coding Platform), extremely easy as well:
#Now replace the hash comments with the new semi colon. Find ^# and replace with ;
+
##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
#Remove any illegal strings that can prevent files loading. Find ^(null|yes|no|true|false|on|off|none)=(.+)\R and replace with nothing.
+
##Double quotes are now not allowed and this can be easily bypassed by searching " and replace with '
 +
##Put a closing double quote at end of line if not empty or a comment.  Find ^((?!#).+)\R  replace with $1"\R
 +
##Put an opening quote at start of translated string if not empty or comment. Find ^((?!#).+?\=)(.+)\R replace with $1"$2\R
 +
##Now replace the hash comments with the new semi colon. Find ^# and replace with ;
 +
##Remove any illegal strings that can prevent files loading. Find ^(null|yes|no|true|false|on|off|none)=(.+)\R and replace with nothing.
  
 
==Related discussion threads in the development mailing list==
 
==Related discussion threads in the development mailing list==

Revision as of 19:07, 20 May 2011

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. If you want to include a double-quote in your string, you can use an html entity like & quot; or the default "_QQ_". 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? Reply from infograf768: My guess is that they can't be used if not enclosed in double quotes.
  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 performance.

Basically, you have two options:

  1. A free online tool is available here: http://demo.yoorock.fr/en/language-updater-j15-g-j16. This tool exactly does what is described in the Eclipse solution.
  2. The Eclipse solution (or any other Coding Platform), extremely easy as well:
    1. 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
    2. Double quotes are now not allowed and this can be easily bypassed by searching " and replace with '
    3. Put a closing double quote at end of line if not empty or a comment. Find ^((?!#).+)\R replace with $1"\R
    4. Put an opening quote at start of translated string if not empty or comment. Find ^((?!#).+?\=)(.+)\R replace with $1"$2\R
    5. Now replace the hash comments with the new semi colon. Find ^# and replace with ;
    6. Remove any illegal strings that can prevent files loading. Find ^(null|yes|no|true|false|on|off|none)=(.+)\R and replace with nothing.

Related discussion threads in the development mailing list