androidlocalizationxliffweblate

How to set string resource length limit in Android?


It is known that Androd string resources support xliff namespace to annotate non-translatable string formatting placeholders, like this

    <string name="max_file_size_exceeded_template">File 
         <xliff:g example="some_image.jpg" id="file_name">%1$s</xliff:g>
         is too big and could not be uploaded.</string>

It helps translators to undestand what parts of string should not be modified. But sometimes I need to annotate some strings max length it they are used in UI control with limited size. What I want is add text length limit to warn translators about this. Something like max-length="24" max-lines="2" length-unit="char" Maybe, xliff supports such thing or it can be achieved in other way. I use Weblate for translations if it matters.


Solution

  • You can set this in Weblate, the Andoid format does not support this directly.

    See also https://docs.weblate.org/en/latest/admin/translating.html#additional-information-on-source-strings