Skip to content

syntax: handling of empty strings or trailing white spaces #223

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
langpavel opened this issue Nov 30, 2018 · 4 comments
Open

syntax: handling of empty strings or trailing white spaces #223

langpavel opened this issue Nov 30, 2018 · 4 comments

Comments

@langpavel
Copy link

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)
@aphillips
Copy link

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 :-)

@langpavel
Copy link
Author

langpavel commented Nov 30, 2018

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
Copy link
Author

@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
Copy link
Author

langpavel commented Nov 30, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants