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

floats support #10

Open
puzrin opened this issue Feb 17, 2019 · 5 comments
Open

floats support #10

puzrin opened this issue Feb 17, 2019 · 5 comments
Labels
spec Related to specification

Comments

@puzrin
Copy link
Collaborator

puzrin commented Feb 17, 2019

This option was missed in C API.

  • Probaly need lv_i18n_get_text_plural_f().
  • Check CLDR, does it have rules for floats? (seems - yes).
  • Probably, floats use additional form, not used for integers.
    • How to relax linter restrictions when floats are not used? We should not force all to fill useless translations
    • Example, in ru-RU: float -> other
@puzrin puzrin added the spec Related to specification label Feb 17, 2019
@kisvegabor
Copy link
Member

kisvegabor commented Feb 19, 2019

Having lv_i18n_get_text_plural_f would mean the float type needs to be introduced to lvgl core. It would increase the memory footprint. If we add this function there should be an option to disable it.

@puzrin
Copy link
Collaborator Author

puzrin commented Feb 19, 2019

Sure, disabled by default in define, enabled via flags.

@puzrin
Copy link
Collaborator Author

puzrin commented Feb 27, 2019

I've checked, CLDR rules are ok with floats http://unicode.org/reports/tr35/tr35-numbers.html#Operands (2/3 of operands are about decimal part).

Problem is with trailing zero-s support. If we pass value as float, we can not specify difference between 1, 1.0 and 1.00. And that makes sense for plural select. Passing value as string is possible, but usability about zero. Second param "min decimal precision" may help, but still strange.

Need to search, how other libraries/languages solves such issue. Fixed decimal length seems to be the major case for floats.

@kisvegabor
Copy link
Member

Gettext says this

Negative and floating-point values usually represent physical entities for which singular and plural don’t clearly apply. In such cases, there is no need to use ngettext; a simple gettext call with a form suitable for all values will do. For example:

printf (gettext ("Time elapsed: %.3f seconds"),
num_milliseconds * 0.001);
Even if num_milliseconds happens to be a multiple of 1000, the output

Time elapsed: 1.000 seconds
is acceptable in English, and similarly for other languages.

I think it's not major issue and we can follow this apporach.
If we dig so deep then we should deal with currencies, dates and other things too as stated in the CLDR doc you linked. But It think these features are not subject of the current development.

@puzrin
Copy link
Collaborator Author

puzrin commented Feb 27, 2019

Note, dates and formatting are not about i18n, those are about l10n - different things.

Since we do "right i18n for embedded c", i'd like to be sure, that floats are supported in all desired ways. Example with num_milliseconds * 0.001 looks really interesting, need to check how that conforms with CLDR rules.

Good news is, floats are not critical for release and can be postponed as long as required, until we are sure in good solution. I created this issue not for immediate resolution, but for memo.

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

No branches or pull requests

2 participants