Skip to content
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

Missing support for plurals #1

Open
felixLam opened this issue Mar 29, 2017 · 1 comment
Open

Missing support for plurals #1

felixLam opened this issue Mar 29, 2017 · 1 comment

Comments

@felixLam
Copy link
Member

PO supports plurals officially:
https://www.gnu.org/software/gettext/manual/html_node/Translating-plural-forms.html

We would need to come up with a custom "encoding" for CSV formats.

@norpan
Copy link

norpan commented Jul 5, 2017

We have the need for plural forms in a not so distant future. Only po file support is relevant for us so I'm leaving the CVS format out of my comment for now.

Let's take the example from the po documentation and translate into Elm.

module Translation.Main exposing (..)

{-
   "Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
   "%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"
-}

nplurals =
    3


plural : Int -> Int
plural n =
    if n % 10 == 1 && n % 100 /= 11 then
        0
    else if n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) then
        1
    else
        2



{-
   #, c-format
   msgid "One file removed"
   msgid_plural "%d files removed"
   msgstr[0] "%d slika je uklonjena"
   msgstr[1] "%d datoteke uklonjenih"
   msgstr[2] "%d slika uklonjenih"
-}


nFilesRemoved : Int -> String
nFilesRemoved n =
    if plural n == 0 then
        toString n ++ " slika je uklonjena"
    else if plural n == 1 then
        toString n ++ " datoteke uklonjenih"
    else
        toString n ++ " slika uklonjenih"

So, what we need is

  • Parser from C expression to Elm expression for plural function
  • Parser from Elm expression to C expression for plural function
  • Handling of if then else and extra number parameter for translations

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

No branches or pull requests

2 participants