Soluling home   Document home

Text File Localization and Internationalization

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.

File encoding

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.

Encoding dialog

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.

Plain text files

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.

Scan as single string in Project Wizard

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

Project with one row

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.

Segmented text files

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.

Use segmentation in Project Wizard

The project now contains several rows instead of one.

Segmented project

The segmentation is not completely right yet. There are two errors:

  1. There should be a segment break after each line break.
  2. The header numbers (1., 2., and 3.) cause a segment break, but there should not be a break.

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.

Segmentation rules in the source dialog

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.

Line break rule

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.

Header number exception rule

Now the rules are complete.

Edited segmentation rules

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.

Correctly segmented project

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.

Defined text files

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:

  1. The ID. It must not be localized.
  2. The name of the sport. It is localized.
  3. The number of field players. It must not be localized.
  4. The number of goalies. It must not be localized.
  5. The country of origin. It is localized.
  6. The description. It is localized.

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.

Definition in Project Wizard

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.

Definition that uses after expressions

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 final definition

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.

Desktop process Desktop process

  1. Start Soluling. Drag the text file (e.g., Sport.txt) on Soluling or click the New from File or Files button and select the file.
  2. Project Wizard appears. Select the Scan mode: Scan as single string, Use segmentation, or Use definition. If you use a definition, check the field rules.
  3. Select the original language and the target languages, for example, Finnish, and complete the wizard.
  4. Translate the project.
  5. Choose Home | Build All to build the localized text files. By default, Soluling creates them in language subdirectories, for example, 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.

Cloud process Cloud process

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.

Create a project

  1. Sign in at www.soluling.com and open Cloud > Dashboard for Projects, Users and Terminology.
  2. Click Add a new project, then Select files and pick the text file (e.g., Plain.txt), or drag and drop the file onto the page. Click Create.
  3. On the next page, check the project's Name. It defaults to the file's name.
  4. Set the Original language to the language of the file, for example, English.
  5. Under Target languages, check the languages you want to translate to, for example, Finnish and German.
  6. Under Source type, select Text file (.txt).
  7. Click Create. The project appears on the dashboard, and its status changes to Ready once the file has been processed.

Translate the project

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.

Get the localized files

  1. In Translate's top bar, click the project's name. It opens the project's Manage page, the same page that the project's Manage button on the dashboard opens.
  2. If you have translated something since the localized files were last built, the page says Localized files need to be built. Click Build localized files and wait until it finishes.
  3. The Files section lists the text file with a download button for each target language. Save each localized file, for example, as fi\Plain.txt.

Update the project

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.

Segmented and defined files

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.

  1. Create the project in Soluling Desktop as described in Desktop process, check that the rows are right, and save it. This creates the Soluling project file (.ntp).
  2. On the Translate tab, in the Send and Receive group, click Configure Cloud.
  3. Log in with your Soluling account, and select the cloud account to use if you have several.
  4. Click OK to create the cloud project. When Soluling asks whether to upload the local project to the cloud, click Yes, and Yes again to wait until the cloud has processed it.
  5. Translate the project in Translate as described above.
  6. In Soluling Desktop, on the Translate tab, click Import from Cloud. Soluling downloads the translations made in the cloud and imports them into your local project. Then choose Home | Build All.

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.

Samples

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.  

Configuring text file localization

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.

Settings

Read more about other data files such as XML, XSL, JSON, YAML, INI, Excel, SVG, TMX, XLIFF, text and binary files.