fluent icon indicating copy to clipboard operation
fluent copied to clipboard

syntax: handling of empty strings or trailing white spaces

Open langpavel opened this issue 7 years ago • 4 comments

Take this as an example:

form-name =
    {$user_gender ->
        [male] {"Ten "}
        [female] {"She name is "}
       *[other] {""}
    }{ $user_name }

1. Will be good if can be written as:

form-name =
    {$user_gender ->
        [male] His name is \
        [female] Her name is \
       *[other] \
    }{ $user_name }

2. Will be better if can be written as:

form-name =
    {$user_gender ->
        [male] His name is
        [female] Her name is
       *[other] \-
    } { $user_name }

The latest \- in *[other] is trim Like this:

  • \ EOL → emty string or keep spaces before
  • \ - EOL → greedy trim (like eat all whitespaces around)
  • \ + EOL → greedy+one space trim (like eat all whitespaces around, keep one if in middle)

langpavel avatar Nov 30 '18 21:11 langpavel

Hmm... these examples (and this syntax) promotes a common I18N mistake: the idea of sentence concatenation working equivalently across languages. This example assumes that the user name always occurs after the rest of the sentence. Promoting this kind of thinking even if we know better than to use it ourselves is a bad thing. Ideally the syntax should discourage it as a behavior at all. After all His name is {username} in Japanese might be something like 彼の名前は{username}です (I used google translate here).

Note too that @langpavel's choice about spaces has implications for translations of the file. A Japanese translator does not want that (hard to see!) space if it is meaningful. In other words, do this:

form-name = 
    {$user_gender ->
        [male] His name is {$user_name}
        [female] Her name is {$user_name}
       *[other] {$username}
    }

... and disallow concatenations. It answers the question at the same time :-)

aphillips avatar Nov 30 '18 22:11 aphillips

these examples (and this syntax) promotes a common I18N mistake: the idea of sentence concatenation working equivalently across languages

This syntax can be helpful in Latin alphabet based languages, but not exclusively. It's translator tool, not coder or programmer. Note that new syntax/operators MAY BE used in translations, not in the application consuming it

This example assumes that the user name always occurs after the rest of the sentence.

No, this have nothing to do with placement

in Japanese might be something like 彼の名前は{username}です

You can always write it as @aphillips proposed.

In other words, do this:

form-name = 
    {$user_gender ->
        [male] His name is {$user_name}
        [female] Her name is {$user_name}
       *[other] {$username}
    }

Correct, but much of redundancy, I like this variant, but this may be not best solution always I guess... will think about.

langpavel avatar Nov 30 '18 23:11 langpavel

@aphillips good point about the idea of sentence concatenation working equivalently across languages

I do not expect, that \- and \+ operators may cross scope of Message This is not intended and I'm not sure if even can be implemented…

langpavel avatar Nov 30 '18 23:11 langpavel

The \ at end of line can help visually mark white space before end-of-line, this is syntactical character and I believe it will be 99.99% compatible with all written fluent translations :-) As benefit it can help semantically represent an empty string; there was plenty of issues requesting this

langpavel avatar Nov 30 '18 23:11 langpavel