Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
9e035921
Kaydet (Commit)
9e035921
authored
Agu 25, 2000
tarafından
Barry Warsaw
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Test suite for new gettext.py module.
üst
95be23dc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
76 additions
and
0 deletions
+76
-0
test_gettext.py
Lib/test/test_gettext.py
+76
-0
No files found.
Lib/test/test_gettext.py
0 → 100644
Dosyayı görüntüle @
9e035921
import
os
import
gettext
def
get_qualified_path
(
name
):
"""Return a more qualified path to name"""
import
sys
import
os
path
=
sys
.
path
try
:
path
=
[
os
.
path
.
dirname
(
__file__
)]
+
path
except
NameError
:
pass
for
dir
in
path
:
fullname
=
os
.
path
.
join
(
dir
,
name
)
if
os
.
path
.
exists
(
fullname
):
return
fullname
return
name
# Test basic interface
os
.
environ
[
'LANGUAGE'
]
=
'xx'
mofile
=
get_qualified_path
(
'xx'
)
localedir
=
os
.
path
.
dirname
(
mofile
)
print
'installing gettext'
gettext
.
install
()
print
_
(
'calling bindtextdomain with localedir
%
s'
)
%
localedir
print
gettext
.
bindtextdomain
(
'gettext'
,
localedir
)
print
gettext
.
bindtextdomain
()
print
gettext
.
textdomain
(
'gettext'
)
print
gettext
.
textdomain
()
# test some translations
print
_
(
u'mullusk'
)
print
_
(
r'Raymond Luxury Yach-t'
)
print
_
(
ur'nudge nudge'
)
# double quotes
print
_
(
u"mullusk"
)
print
_
(
r"Raymond Luxury Yach-t"
)
print
_
(
ur"nudge nudge"
)
# triple single quotes
print
_
(
u'''mullusk'''
)
print
_
(
r'''Raymond Luxury Yach-t'''
)
print
_
(
ur'''nudge nudge'''
)
# triple double quotes
print
_
(
u"""mullusk"""
)
print
_
(
r"""Raymond Luxury Yach-t"""
)
print
_
(
ur"""nudge nudge"""
)
# multiline strings
print
_
(
'''This module provides internationalization and localization
support for your Python programs by providing an interface to the GNU
gettext message catalog library.'''
)
print
gettext
.
dgettext
(
'gettext'
,
'nudge nudge'
)
# dcgettext
##import locale
##if gettext.dcgettext('gettext', 'nudge nudge',
## locale.LC_MESSAGES) <> 'wink wink':
## print _('dcgettext failed')
# test the alternative interface
fp
=
open
(
os
.
path
.
join
(
mofile
,
'LC_MESSAGES'
,
'gettext.mo'
),
'rb'
)
t
=
gettext
.
GNUTranslations
(
fp
)
fp
.
close
()
gettext
.
set
(
t
)
print
t
==
gettext
.
get
()
print
_
(
'nudge nudge'
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment