![]() |
Text File Localization and Internationalization |
A text file (Wikipedia) contains lines of characters. A text file contains either plain text or structured text. A plain text file is usually a document, and its text can be in any form. A structured text file is more like a database: it contains records, and each record contains one or more fields. Some fields, such as names and descriptions, need to be localized. Other fields, such as IDs and numbers, must not be localized. Soluling Desktop and Soluling Cloud support text files.
Soluling has three ways to scan a text file:
The end of the document contains links to get the full source code of the samples. After reading this document, we recommend reading a tutorial about how to use Soluling.
Soluling supports all the character encodings that Windows supports. This includes the Unicode encodings, such as UTF-8, UTF-16 (big and little-endian), UTF-32 (big and little-endian), and GB 18030, with and without BOM. Soluling also supports legacy encodings, such as Windows, ISO, Mac, and EBCDIC code pages. Most of the time, Soluling detects the encoding of your file automatically. If it cannot, it shows a dialog where you select the encoding.

The dialog shows the beginning of the file as hex codes, which may help you figure out the encoding. Select the encoding and click OK.
When Soluling scans a plain text file as a single string, it reads the whole file into one string and adds the string to the project. Here is the Plain.txt sample.
Sports 1. Soccer Soccer is a sport played between two teams of eleven players with a spherical ball. Team contains 10 field players and a goalie. Soccer originates from England. 2. Ice hockey Ice hockey is a team sport played on ice, in which skaters use sticks to direct a puck into the opposing team's goal. Team contains 5 field players and a goalie. Ice hockey originates from Canada. 3. Basketball Basketball is a team sport in which two teams of five players try to score points by throwing a ball through the top of a basketball hoop while following a set of rules. Team contains 5 field players. Basketball originates from United States.
When you create a project for the file, keep Scan mode as Scan as single string, the default.

The project contains one row that contains the whole text file.

This file is small, so everything fits into a single cell. When the file gets larger, a single row is hard to translate. In that case, use segmentation.
When Soluling scans a text file using segmentation, it reads the whole file into one string and breaks the string into segments, usually sentences. Each segment is a row in the project. Let's use the same Plain.txt file. When you create a project for the file, set Scan mode to Use segmentation.

The project now contains several rows instead of one.

The segmentation is not completely right yet. There are two errors:
Soluling uses the standard segmentation rules (SRX), and you can modify them. Soluling starts with default rules that catch most breaks and handle most exceptions. Some of the default rules are language-independent, and some are language-specific. Because the original language of Plain.txt is English, the rules are a combination of the language-independent and the English rules. To edit the rules, right-click Plain.txt in the project tree, choose Options, and select the Options sheet.

To add a rule, click Add. There are two kinds of rules:
The Before break and After break fields contain the regular expressions that match the text before and after the break. The Description field can contain any text that describes the rule.
A line break never has an exception, so select Break no exception and enter \r\n into Before break.

The exception must match <beginning of line>N.<white space>, where N is a number. Select Exception, enter ^[0-9]+\. into Before break and \s into After break.

Now the rules are complete.

The two rules you added are custom rules, so they are shown at the top of the list in bold. Click OK to close the source dialog. Because you changed options that affect scanning, Soluling recommends rescanning. Click Yes, and the file is segmented correctly.

Fine-tuning the segmentation rules takes some work, but compared to scanning the file as a single string, segmentation has many advantages. The project is easier to translate, and the translator is less likely to make an error. Translation memory also works better with sentences than with whole documents.
Some text files contain data records instead of plain text. Here is the Sport.txt sample.
soccer Soccer 10 1 England Soccer is a sport played between two teams of eleven players with a spherical ball. hockey Ice hockey 5 1 Canada Ice hockey is a team sport played on ice, in which skaters use sticks to direct a puck into the opposing team's goal. basketball Basketball 5 0 United States Basketball is a team sport in which two teams of five players try to score points by throwing a ball through the top of a basketball hoop while following a set of rules.
Each line contains one record. Each record contains six fields separated by a tab character:
You could scan this file as plain text or segmented text, but then each string would contain several fields, and the translator could easily break the format. Use a definition instead. A definition tells Soluling the format of the file. It contains field rules, one for each field, and together the rules define the record. Like segmentation rules, the field rules use regular expressions.
When you create a project for the file, set Scan mode to Use definition. Soluling reads your file, analyzes its format, and fills the field rules based on the result.

A field rule can have a before and an after expression. The expressions match the characters that delimit the field value. In the sample, the tab character delimits the fields. The first field is the ID, which Soluling uses as the context of the row, and it does not need a before or an after expression. The other fields need the before expression \t, which matches a tab character. The last field ends with a line break, so it also has the after expression \r\n.
You can also use only after expressions. The following definition handles the same record.

The definition that Soluling creates localizes all the fields except the first one. The third and fourth fields are numbers that must not be localized. Select the third column, right-click, and choose Ignore. Do the same for the fourth column.

The definition is now complete, and Soluling scans each localized field of the file into its own row. A field can also be a comment that Soluling shows to the translator. See the Comment sample.
Sport.txt) on Soluling or click the New from File or Files button and select the file.fi\Sport.txt. Set the output file name on the Output sheet.When you change the text file, open the Soluling project and choose Home | Scan. Soluling keeps the existing translations, and you only translate the strings that were added or changed.
With Soluling Cloud, you localize the text file in your browser using Translate. You need a Soluling account. See the available Cloud plans.
When you upload a text file directly, Soluling Cloud scans it as a single string. If you use segmentation or a definition, create the project in Soluling Desktop first and upload the project. See Segmented and defined files.
Plain.txt), or drag and drop the file onto the page. Click Create.Click the project's green Translate button on the dashboard. Translate opens the project, and you can type the translations into the grid. Machine translation suggestions, translation memory, and spell checking are available there. You do not have to finish every language before moving on to the next step.
fi\Plain.txt.When you change the text file, upload the new file, translate what is new or changed, and download the localized files again. On the dashboard, click the project's Update file button (the upload arrow), select the new file or drop it onto the page, and click Update. Existing translations are kept, so you only translate the strings that were added or changed.
The dashboard is one of four ways to use Soluling Cloud. You can also use the SoluCLI command-line tool, Soluling Desktop, or SoluMake, which can run the update and build steps in your build pipeline. See the Cloud tutorial for all of them.
The segmentation rules and the definition are options of the Soluling project, so you create the project in Soluling Desktop, upload it to Soluling Cloud, and build the localized files in Soluling Desktop.
.ntp).When the text file changes, in Soluling Desktop, on the Home tab, click Scan. On the Translate tab, click Upload to Cloud. The cloud project is updated to match your local one, and translations that exist only in the cloud so far are kept. Translate the new and changed strings, then Import from Cloud and build again.
GitHub and <data-dir>\Samples\Text contain the following sample directories:
| Directory | Description | Notes |
|---|---|---|
| Simple | A defined text file that contains one record with an ID, a name, a price, and a count. | Try this first! |
| Plain | The Plain.txt text file of this document with two projects. Plain.ntp scans the file as a single string and builds fi\Plain.txt. Segmented.ntp scans the file using segmentation with the two custom rules and builds fi\Segmented.txt. | |
| Segmented | A UTF-8 text file that contains one paragraph, scanned using segmentation with the default rules. | |
| Sport | The defined Sport.txt file of this document. | |
| Comment | A defined text file where one field is a comment for the translator. | |
| Escape | A defined text file that contains escaped line breaks (\r\n). |
|
| Japanese | A defined text file that contains Shift JIS encoded Japanese text. |
You create a text file localization project by adding a text file (e.g., D:\Sample\Sport.txt) into your Soluling project. You can configure how to localize your text file
by selecting the item in the project tree, right-clicking, and choosing the Options menu. A source dialog appears that lets you edit the options. This source uses the following option sheets.
Read more about other data files such as XML, XSL, JSON, YAML, INI, Excel, SVG, TMX, XLIFF, text and binary files.