Spacc BBS Spacc BBS
    • Categorie
    • Recenti
    • Tag
    • Popolare
    • Mondo
    • Utenti
    • Gruppi
    • Registrati
    • Accedi
    La nuova BBS è in fase Alpha. I post precedenti al 22 luglio 2024 potrebbero non essere trasferibili, ma rimarranno disponibili per la lettura su /old/.

    Improving support for plurals in localisations

    Pianificato Fissato Bloccato Spostato Uncategorized
    nodebbl10ni18ntransifex
    4 Post 2 Autori 9 Visualizzazioni
    Caricamento altri post
    • Da Vecchi a Nuovi
    • Da Nuovi a Vecchi
    • Più Voti
    Rispondi
    • Topic risposta
    Effettua l'accesso per rispondere
    Questa discussione è stata eliminata. Solo gli utenti con diritti di gestione possono vederla.
    • julian@community.nodebb.orgJ Questo utente è esterno a questo forum
      julian@community.nodebb.org
      ultima modifica di

      Quick update re: localisation... according to Transifex, we began our translations over 12 years ago 😎 time flies!

      image.jpeg

      In that time, we've migrated maintained our translations through Transifex, which has been kind enough to offer us free hosting as NodeBB is an open-source project.

      There has always been a bit of a problem with sentences with numbers in them — namely that they can either be singular ("A quick brown fox jumped...") or plural ("Three quick brown foxes jumped...")

      tl;dr — NodeBB now supports localisations with proper plural forms directly in our Transifex project interface. No more (s) hacks at the end of words!

      This gets even more complicated because different languages have different sentence structures for countable items. While English is relatively simple (one, or "more"), Russian has different terms/handling for "one", "few", "many", and "other".

      N.B. "other" is Transifex' term for a fallback/generic catch-all... maybe it means "more than many"?


      Up 'til now we hacked around this by appending the string (s) to the end of singular forms:

      > You have %1 post(s) left to read.

      > There are 5 fox(es) in your henhouse.

      > Please stack these ten box(en) in the warehouse.

      This was admittedly a stopgap measure, but we've made the changes to our translator library to properly handle the plural forms that Transifex supports. From the Transifex interface, these strings will look like this:

      image.jpeg

      The "1" and "other" buttons at the top right will allow you to switch between forms, finally allowing you to construct plural forms for NodeBB strings.

      Happy Translating!

      https://community.nodebb.org/assets/uploads/files/1793212282733-f697c609-b7bd-4109-85db-afca8f8de0d4-image.jpeg

      https://community.nodebb.org/assets/uploads/files/1793213140124-fb5b59cf-ac1b-4431-89af-6c89d5984304-image.jpeg

      1 Risposta Ultima Risposta Rispondi Cita 0
      • julian@community.nodebb.orgJ Questo utente è esterno a questo forum
        julian@community.nodebb.org
        ultima modifica di

        For translators

        This means that any converted strings have lost their existing translations. You will need to manually go in and translate them again (plus their plural variants), or rescue the existing translation from the history.

        However, note that for plural strings, there is a new placeholder {count} to be used in addition to the %1, %2, etc. that we already use. We use {count} for simplicity, but it could be named anything.

        gunchleoc@mastodon.scotG julian@community.nodebb.orgJ 2 Risposte Ultima Risposta Rispondi Cita 0
        • gunchleoc@mastodon.scotG Questo utente è esterno a questo forum
          gunchleoc@mastodon.scot @julian@community.nodebb.org
          ultima modifica di

          @julian Thanks for fixing this!

          1 Risposta Ultima Risposta Rispondi Cita 0
          • julian@community.nodebb.orgJ Questo utente è esterno a questo forum
            julian@community.nodebb.org @julian@community.nodebb.org
            ultima modifica di

            For Developers

            There's no requirement to support pluralized strings in your templates — they are opt-in, but they are fairly easy to support.

            Where you would normally write a translation string like so:

            {
              ...
              "foo": "%1 bar(s)"
              ...
            }
            

            You will instead put in an "ICU Plural" string that looks like this:

            {
              ...
              "foo": "{count, plural, one {{count} bar} other {{count} bars}}"
              ...
            }
            

            Comma separated:

            • count is the variable substitution you'll use in the latter half of the string
            • plural is hardcoded, it's always plural
            • Then the forms:
              • one denotes the singular form in the proceeding braces
              • other denotes the plural form (in English) in the next set of braces
            1 Risposta Ultima Risposta Rispondi Cita 0
            • Primo post
              Ultimo post