6.4. Adding a new locale
Prev | Chapter 6. Error handling | Next

## 6.4. Adding a new locale

All error messages are stored in an array with a specific index that cannot be changed. This index is used in the library to reference a specific error message.

Since error messages can also have additional parameters the error messages also includes count that specifies how many arguments must be handled to enable some error checking when using the error message in the code (to make sure we have enough arguments).

The arguments are formatted in the error text in the same way as parameters in the `printf()` family of functions.

To create a localized error resource file You should first copy the "`en.inc.php`" to a temporary file, rename it according to the locale you are creating and then translate each error message according to the locale. The make sure that the file is stored under the "`jpgraph/lang/`" catalogue and the new localized error messages can be used.

For example. To create a French version of the error messages the `lang/en.inc.php` should be copied to `lang/fr.inc.php` and the error messages translated. The French locale can then be used by using the string "`fr`" as identified in `SettErrLocale()` as described above.

Prev | Up | Next
6.3. Using PHP Exceptions | Home | Chapter 7. Color handling