Home > Fluid Dynamics Search Engine > Help > 1009

Customizing strings.txt

Most of the text output is stored in the file searchdata/templates/english/strings.txt or similar language-specific files. This includes strings like "Documents $s1-$s2 of $s3 displayed".

Anyone can manually edit this file. Strings are separated by line breaks, so editors just need to make sure line breaks are preserved. For best results, Windows users should use a text editor like Textpad with line numbers visible. When saving, make sure that "word wrap" is turned off -- some editors will insert line breaks at the wrapping points.


Whenever a new version of FDSE is released, the script searchmods/powerusr/lang.pl is used to restructure and optimize the strings.txt file. Any strings that are no longer used are removed, and any heavily-used strings are moved towards the beginning of the file. As a result, the file will change with each FDSE release.

To upgrade FDSE to a new version, it is necessary to replace the strings.txt files completely with the new versions. Then, open the file, search for the strings that were previously customized, and re-customize them.

Advanced: Custom Coding

In FDSE version and older, the strings used anonymous "%s" variables. In version and newer, the strings use named "$s1" and "$s2" variables, which allow for the repeat and re-ordering of variables during translation and customization.

As of FDSE version, all strings are stored in the global array @::str, with $::str[2] corresponding to the text on the 2nd line of the file. These strings can be referenced directly, or can be called from the subroutines pstr, ppstr, and pppstr. When a search is performed, the script has access to the first 80 strings. When a visitor adds a page, or there is an admin action, then all of the strings are available.

The subroutines are used for variable interpolation. For example, $::str[15] = 'Documents $s1-$s2 of $s3 displayed', from the 15th line of strings.txt. To format this string, call:

print &pstr( 15, 1, 10, 100 );
"Documents 1-10 of 100 displayed"

The first argument is the string index, and the remaining arguments are the named variable values.

Subroutine pstr will return the parsed string. ppstr will print the parsed string to output. pppstr will print the parsed string to output inside an HTML paragraph tag.

    "Customizing strings.txt"