Flashpoint-Website icon indicating copy to clipboard operation
Flashpoint-Website copied to clipboard

i18n format placeholders order

Open deluxghost opened this issue 3 years ago • 2 comments

A language may have different word order from English. Consider an example sentence:

Sentence {foo} {bar}.

that will be formatted to:

Sentence <b>foo</b> <i>bar</i>.

While translating to another language, the translator might need to change the order of placeholders:

{Bar} {foo} seeeenteeeeenceeee.

This will still be formatted in the original order like this:

<b>Bar</b> <i>foo</i> seeeenteeeeenceeee.

Many i18n frameworks have placeholders with number:

Sentence {1} {2}.

these placeholders can be moved to break the order and still work.

While I really like your placeholder concept, I suggest adding a feature like this, add an order number as a prefix:

Sentence {1:foo} {2:bar}.

therefore we can translate it like this:

{2:Bar} {1:foo} seeeenteeeeenceeee.

deluxghost avatar Aug 19 '22 08:08 deluxghost

Heya, thanks for your suggestion. We've been thinking about this issue before emerging the translation branch to master, but since there are no strings with multiple different format tags (at least as far as I remembered), we didn't think of this being an issue for now.

But yeah, it might become an issue in the future, so I'll try to implement it the way you suggested once I have a little more time again.

ShadyMedic avatar Aug 19 '22 08:08 ShadyMedic

There might be some way to also improve how we handle the news page i18n. Currently, at least we can't change these punctuation marks, since we are translating only parts of sentences. (yeah... there might be word order problems too, in the future)

deluxghost avatar Aug 19 '22 09:08 deluxghost