sugarlabs / flappy-birds-activity

An arcade game for Sugar XOs.
1 stars 13 forks source link

Using gettext on numbers #7

Closed quozl closed 6 years ago

quozl commented 8 years ago

In bb7634990ab6db7a6a9c086eb6f3d043fcf7fc92 and 44a263fe1aaa40c2b8254bc5f4fb633c66420eb2 you add gettext for integers.

@leonardcj, is this valid use?

iamutkarshtiwari commented 8 years ago

@quozl The game updates the scores. So in some other language(for example: Chinese) the integer must be different looking character so it needs to go through gettext

quozl commented 8 years ago

Isn't that a job for a character set?

iamutkarshtiwari commented 8 years ago

@quozl I am bit doubtful about that. We should consult this with @leonardcj

leonardcj commented 8 years ago

I need to look a little more closely at the correct way to ensure proper L10n into non-Arabic numerals. I will get back to you on this.

quozl commented 8 years ago

@leonardcj, thanks.

quozl commented 6 years ago

@leonardcj, any news?

leonardcj commented 6 years ago

Um, I thought there was a %(num)Id type for internationalizing the numerals as opposed to %(num)d. Maybe I was thinking of http://wiki.laptop.org/go/Python_i18n#Some_tips where it mentions "Python 2.6 and 3.0 support new formatting options, including a "%n" localized number format."

quozl commented 6 years ago

Okay. @iamutkarshtiwari, what do you think?

Problem is that a POT file and po/en.po file cannot practically contain every possible number that might be used as a player score, so _(str(int)) may never work; always returning str(int) unchanged.

leonardcj commented 6 years ago

https://www.gnu.org/software/gettext/manual/gettext.html

As a special feature for Farsi (Persian) and maybe Arabic, translators can insert an ‘I’ flag into numeric format directives. For example, the translation of "%d" can be "%Id". The effect of this flag, on systems with GNU libc, is that in the output, the ASCII digits are replaced with the ‘outdigits’ defined in the LC_CTYPE locale category. On other systems, the gettext function removes this flag, so that it has no effect.

Note that the programmer should not put this flag into the untranslated string. (Putting the ‘I’ format directive flag into an msgid string would lead to undefined behaviour on platforms without glibc when NLS is disabled.)

leonardcj commented 6 years ago

Does that make more sense?

iamutkarshtiwari commented 6 years ago

Changes made https://github.com/sugarlabs/flappy-birds-activity/commit/9d97e55aef2c08821cfbdbed341029fb4f42eb94

quozl commented 6 years ago

Thanks!