Skip to content
This repository has been archived by the owner on Nov 24, 2020. It is now read-only.

Feature Request: notation human readable enums #10

Open
tironiigor opened this issue Mar 29, 2018 · 2 comments
Open

Feature Request: notation human readable enums #10

tironiigor opened this issue Mar 29, 2018 · 2 comments
Labels
enhancement New feature or request

Comments

@tironiigor
Copy link
Contributor

It would be a feature so we could have an enum like

type Gender enum {
    female
    male
}

and then we could have

translator pt-br, default {
    Gender: {
        female: Feminino
        male: Masculino
    }
}

and it would generate a function to get the value for that translation given the phone Locale, and using the default value if the Locale trasnlation is not avaiable

@dygufa
Copy link
Contributor

dygufa commented Mar 29, 2018

I would pretty much enjoy if we could define displayable values for enums, this would give consistence between plataforms on how we show these values.

However I would prefer a notation like:

type Gender enum {
    female: "Feminino"
    male: "Masculino"
}

In this scenario the i18n would be handled by an external file.

@lbguilherme
Copy link
Member

lbguilherme commented Mar 30, 2018

Perhaps all languages could go into external files (i.e. have no default language)? And that external file be just a import with some sdkgen syntax for describing it (maybe similar to @tironiigor's?)

A proposal:

Create a construct to define translatable strings:

i18n en, en-US, default {
  female = "Female"
  placeNotFound = "The place was not found"
}

i18n pt-BR {
  female = "Femino"
  placeNotFound = "Local não encontrado"
}

Then this translation can be used in places where a string could be used, optionally. This is a mix of @tironiigor and @dygufa:

type Gender enum {
    female: i18n.female   // I can refer to i18n constants
    male: "Masculino"     // Or simply use a plain string
}

similarly those constants would be usable when implementing the api:

if (!place) {
    throw api.err.NotFound(ctx.i18n.placeNotFound);
}

@dygufa dygufa added the enhancement New feature or request label Apr 2, 2018
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants