Chapter 10. Text Processing

This chapter covers some topics in the area of text processing. It covers how to prepare and translate the on-screen texts in your application for international markets and how to validate the input that users enter into a text field, using the class QRegExp for regular expression matching, reading, and writing XML documents. Finally, it covers how to render so-called rich text—text with various attributes (not to be confused with Microsoft’s Rich Text Format RTF).

Internationalization and Localization of On-Screen Text

This section covers one important aspect of preparing your application for international markets, namely the translation of on-screen texts. There has been some confusion on the terms used in relation to this subject, so it is probably best to sort them out first:

Locale

A locale describes one particular region of the world that has a common language and culture. Smaller or very homogeneous countries only have one locale, but many have two or more. For example, Canada has at least two—one for the French-speaking part of the country and one for the English-speaking part. A locale is not only about language; it is also about number and date formats, currency symbols, and cultural values that might be reflected in computer software.

Locales are specified with two two-letter codes separated by an underscore. The first two-letter code specifies the language; the second specifies a geographical region, often a country. It is also possible ...

Get Programming with Qt, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.