This page is
outdated.
It was written for an older version of MediaWiki and may not apply to the most recent version. If you have checked or updated this page and found the content to be suitable, please remove this notice. See the
talk pagefor a possible discussion on this.
FFS stands for file format support. This is the general name for a group of classes for reading and writing translated messages in different file formats in the Translate extension.
Software developers reinvented the wheel with localization technologies many times, so there are many different formats for storing translatable software messages. There are two main groups of such formats.
With some exceptions, most FFS class derive from the FFS interface, which defines the basic methods every class must implement:
setWritePath( $target )
getWritePath()
read( $code )
readFromVariable( $data )
write( MessageCollection $collection )
writeIntoVariable( MessageCollection $collection )
Classes for storing MediaWiki translations are not currently handled by FFS interface derivatives, but by autonomous classes: there are configuration instructions. New FFS-like classes are being developed.
The class SimpleFFS is the ancestor of all the other FFS classes, and it is also a simple example of how an FFS class should be written. It implements a simplistic key-based format:
Since SimpleFFS is intentionally simplistic, it demonstrates possible bugs and complications. For example, the "=" character is not escaped, so the key and the value may not contain them. Obviously, this is not something that is suitable for real-world programs. SimpleFFS also implements useful utility methods:
exists( $code )
writeReal( $collection )
filterAuthors
fixNewLines( $data )
All the above SimpleFFS methods can be overridden. Most implementations, however, only need to implement writeIntoVariable
and readFromVariable
.
General tips when writing new classes:
The existing FFS classes are:
Examples of Translate exports in those formats are available at translatewiki.net.
FFS classes hierarchyThe Translate extension is MediaWiki-based and every message is stored as a MediaWiki page, so the key must be a valid MediaWiki page title. Mangling takes care of this by escaping the key names a manner similar to the quoted-printable encoding, but with some modifications before storing the message as a wiki page. Before the message is written back to the file, the message is unmangled.
When an FFS class overrides the functions that call the mangling routines, it must make sure the roundtrip is done correctly – that is, that the key is mangled before writing to MediaWiki and unmangled before writing the translation back to the file.
Mangling is done in the StringMatcher
class.
If you create a new FFS class, create a corresponding testing file in the tests directory. The important things to test are:
readFromVariable
function returns the right keys and values for AUTHORS and MESSAGES.You can use existing test routines, such as JavaFFSTest, as examples.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4