title: l10n/i18n: how to handle phrases with dynamic list of items?
body: <p>What's the sanest way to handle translation and localization of dynamic lists?</p>
  
  <p>Let's say I've queried the database, and got a list <code>["Foos", "Bars", "Bazes"]</code>. Let's also assume the list always contain at least two items - I'll be sure to use a different translation for the single-item case.</p>
  
  <p>What should I do if I need a phrase like "<em>We have a wide choice of Foos, Bars and Bazes in our code</em>"? (assuming that list items are dynamic so I <strong>can't</strong> just pre-translate all the possible permutations, and need to do things at runtime.)</p>
  
  <p>I see at least the following issues:</p>
  
  <ul>
  <li><p>I need to inflect all the items to the correct form (are there languages where different forms are required depending on the position in the list?)</p></li>
  <li><p>Different locales may have drastically different rules how to join items.</p>
  
  <ul>
  <li>E.g. CJK locales need "、" instead of ",".</li>
  <li>And AFAIK in Chinese there will be "及" or "和" - depending on the full phrase - before the last item, so I guess there's some ambiguity with translating "and".</li>
  <li>And, as I've read, some languages may avoid punctuation like it's used in English, but have other concepts instead, e.g. Arabic translator may prefer use "و" <em>before</em> every item (although they also have commas, "،"). Not sure if true or not - I don't know Arabic, just saw it mentioned.</li>
  </ul></li>
  </ul>
  
  <p>My problem is, I don't even know what tooling may help me here. I don't have any particular programming language requirements, although Python or JavaScript would be the best. But I guess I can run just about anything, as I can probably build a l10n microservice and query it from my project.</p>
  
  <p>I've used GNU gettext before I've encountered this, but I haven't found anything that would help me in its APIs and data formats. The best I can imagine is <code>_("We have a wide choice of %s in our code", list_text)</code> and generate <code>list_text</code> using some DIY hacks. I'm not sure XLIFF format has anything like this as well. I've found <code>i18n-list-generator</code> on npm but it's <a href="https://github.com/jmeas/i18n-list-generator.js/blob/master/src/i18n-list-generator.js" rel="noreferrer"><em>way</em> too simplicistic</a>.</p>
  
  <p>Have anyone dealt with something like this? What did you do? Is there <em>any</em> library out there that handles this - so I can take a look at its API and learn how it does things?</p>