Soluling home   Document home

File dialog format filters

File dialog format filters

Many platforms contain file dialogs that you can use to select a file to be opened and specify the file to be saved. The dialog contains the Filter property that specifies file types shown in the file type combo box.

For example, if the original filter string is

All supported files (*.xml;*.ini)|*.xml;*.ini|XML files (*.xml)|*.xml|Ini files (*.ini)|*.ini

Then the following translation will pass.

Kaikki tuetut tiedostot (*.xml;*.ini)|*.xml;*.ini|XML tiedostot (*.xml)|*.xml|Ini tiedostot (*.ini)|*.ini

Even the description strings are different, the structure is the same. The translation has all supported files part, XML part and Ini part. Also, each part has the same file masks (e.g., *.xml). However, the following translations will fail.

Translation Reason to fail
Kaikki tuetut tiedostot (*.xml;*.ini)|*.xml;*.ini|XML tiedostot (*.xml)|*.xml|Ini tiedostot (*.ini) *.ini There is no | character between Ini description and the Ini mask.
Kaikki tuetut tiedostot (*.xml;*.ini)|*.xml;*.ini|XML tiedostot (*.xml)|*.xml There is no Ini part.
Kaikki tuetut tiedostot (*.xml;*.ini)|*.xml;*.ini|XML tiedostot (*.xml)|*.xml|Ini tiedostot (*.ini) *.ini| There is an extra | character.

You have two choices to make sure that localized values are valid. The recommended choice is to use the filter string formatter class. Soluling contains filter string formatter classes for the following platforms:

Platforms APIs Samples
.NET <data-dir>\Library\​NET\DialogFilter.cs <data-dir>\Samples\​WindowsForms\FileDialog
<data-dir>\Samples\​WPF\FileDialog
Delphi <data-dir>\Library\​Delphi\NtDialog.pas <data-dir>\Samples\​Delphi\VCL\FileDialog
<data-dir>\Samples\​Delphi\FMX\FileDialog

If your platform is not supported, then the second choice is to use file dialog filter validation.