Cannot enforce Java variable validations in Zanata's translations due to false positives

Description

The following grep will list a number of translations which are likely to cause problems in Zanata's UI:

For instance:

Any string which contains {0} variables will probably be processed by Java's MessageFormat, which treats single apostrophes as escape characters.

Unmatched apostrophes will cause a formatting error, and if two apostrophes happen to be either side of a {0} variable, the string {0} will be included literally, instead of the variable value being used.

If a literal apostrophe is required (probably the more common case), the apostrophe must be doubled when using MessageFormat.

These 45 translations should be checked and fixed (in most cases we just need to double the apostrophes). We should also investigate ways of preventing the problem in future using validations. We may just need to enforce Java Variable validation.

is similar, but this is specifically about MessageFormat, not HTML and JavaScript.

Discussion:

  • if curly bracket is followed by a digit: treat as possible MessageFormat

  • run MessageFormat to see if there's a parsing exception

  • if no exception, then validate for matching variables etc (as before)

Environment

None

Status

Assignee

Unassigned

Reporter

Sean Flanigan

Tested Version/s

None

Components

Priority

High
Configure