kopia lustrzana https://github.com/micropython/micropython-lib
gettext: implement gettext and ngettext
By wrapping the C counterpartspull/229/merge
rodzic
91d176d57a
commit
6b93948472
|
@ -0,0 +1,14 @@
|
|||
import ffilib
|
||||
|
||||
libc = ffilib.libc()
|
||||
|
||||
gettext_ = libc.func("s", "gettext", "s")
|
||||
ngettext_ = libc.func("s", "ngettext", "ssL")
|
||||
|
||||
|
||||
def gettext(message):
|
||||
return gettext_(message)
|
||||
|
||||
|
||||
def ngettext(singular, plural, n):
|
||||
return ngettext_(singular, plural, n)
|
|
@ -1,3 +1,5 @@
|
|||
srctype=dummy
|
||||
type=module
|
||||
version = 0.0.1
|
||||
srctype = micropython-lib
|
||||
type = module
|
||||
version = 0.1
|
||||
author = Riccardo Magliocchetti
|
||||
depends = ffilib
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
import gettext
|
||||
|
||||
msg = gettext.gettext('yes')
|
||||
assert msg == 'yes'
|
||||
|
||||
msg = gettext.ngettext('one', 'two', 1)
|
||||
assert msg == 'one'
|
||||
|
||||
msg = gettext.ngettext('one', 'two', 2)
|
||||
assert msg == 'two'
|
||||
|
||||
msg = gettext.ngettext('one', 'two', 0)
|
||||
assert msg == 'two'
|
||||
|
||||
msg = gettext.ngettext('one', 'two', 'three')
|
||||
assert msg == 'two'
|
Ładowanie…
Reference in New Issue