|
|
String length in Catalyst and XLIFF |
ReasonThe length of localisable strings can be defined/restricted in characters or pixels. This information, or maxwidth size attribute, can be parsed in a TTK project from XLIFF files. This is in fact the only way to automatically import and apply max size limitations at the time of writing this article for Alchemy Catalyst 11.
Maximum size in Catalyst and XLIFFAlchemy Catalyst users can use either Character or Pixel based string sizes: If using Maximum Characters, then the width is specified in characters and the height is specified in rows (20 chars by 1 row or 2 rows, etc...) If using Maximum Pixel, then the width and height are specified in pixels. In the case of pixel, the user must also choose the font to be used in any text size calculations. This is chosen from a predefined list of fonts setup in FILE > Options > Application > Defined Fonts.
Applying manuallyLimitations can be specified on a string by string basis or multiple strings via the Properties tab. In the string list you can select one or multiple strings and apply the Maximum size limits. This means the limits can be applied to any file format on a per segment basis.
Parsing maxsize in Xliff filesThe Max size attribute is automatically parsed when inserting XLIFF files in Alchemy Catalyst. These are the requirements: In order for Alchemy Catalyst to parse max size information in an XLIFF translation unit (TU), a maxwidth attribute must be present in the unit. The existence of a maxwidth attribute acts as a trigger for further processing of any max size information in a given TU. Thus a maxheight without a maxwidth attribute would be ignored. Once Alchemy Catalyst reads a maxwidth, if a size unit is specified it will use either the default fixed-width font (defined in FILE > Options > Application > Defined Fonts) if the unit is character or will try to match the font information in the TU against any variable-width fonts stored in the Alchemy Catalyst registry, otherwise adding them on the fly from the info in the TU.
Maxwidth defined with font info but no size unit If there is no size unit specified but there is font information, Alchemy Catalyst defaults to pixels as limitation units and tries to match font information as outlined above. This behaviour is as per XLIFF specs. Maxwidth defined with no size unit or font information If there is no size unit and no font specified and Alchemy Catalyst has variable-width fonts defined, it defaults to pixel-based limitation and uses the first available variable-width font. If there are no variable-width fonts available, Alchemy Catalyst defaults to character based limitation and uses the default fixed-width font which is Courier New. Our software has to make assumptions in the cases outlined above, as the XLIFF spec is ambiguous with regard to max size parameters in TUs. It doesn’t mandate a minimum set of attributes for max size information in TUs so it’s possible to have attribute combinations which actually don’t make any sense. With that in mind, Alchemy Catalyst has quite a complicated set of rules for sanity checking XLIFF TUs with max size information.
For pixel limitation, a typical entry looks like this <trans-unit font="arial;12;normal" maxwidth="100" maxheight="20" size-unit="pixel"> <source>Would you like to be on our mailing list?</source> The font stores, font name, font size and font weight in a semi-colon delimited string. If a font is entered here that matches a pre-defined font, Alchemy Catalyst will use it. If it is a new font, not previously defined, Alchemy Catalyst defines them on the fly with a unique name such as Font1, Font2, etc... For character limitation a typical entry looks like this <trans-unit maxwidth="20" maxheight="1" size-unit="char"> <source>Cancel</source>
Optional Attributes If there is no height specified, Alchemy Catalyst assumes one row (i.e. one row for character-based limit, or the pixel height of the font for a font-based limitation) If there is no size-unit specified, the spec says the default is pixels. But in this case, we need a font. If a font is specified, we use it. If not, we use the first pre-defined font from Tools-Options.
Not supported Catalyst doesn’t currently read the minheight or minwidth attributes that are also part of the XLIFF spec.
Import / ExportThe font definitions are part of the user profile and so get stored in the registry and can be imported/exported via the profile.ini file.
Example of XLIFF with max size <?xml version="1.0"?> <xliff version="1.1"> <file original="String" > <body> <trans-unit id="testStringID" resname="testStringID1" font="arial;12;normal" restype="x-LABEL_KEY" maxwidth="100" > <source>This is a localisable string.</source> <target xml:lang="fr">Ceci est une chaîne traduisible.</target> </trans-unit> </body> </file> </xliff>
Related topics
Products or Versions Affected
Article last updated with Catalyst 11.0
|