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
1be64198
Kaydet (Commit)
1be64198
authored
Ock 11, 2002
tarafından
Martin v. Löwis
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add fallback argument to translation(). Request fallbacks on install.
Fixes #500595.
üst
57f61fb8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
4 deletions
+12
-4
libgettext.tex
Doc/lib/libgettext.tex
+5
-2
gettext.py
Lib/gettext.py
+5
-2
NEWS
Misc/NEWS
+2
-0
No files found.
Doc/lib/libgettext.tex
Dosyayı görüntüle @
1be64198
...
...
@@ -123,7 +123,8 @@ If no such file is found, then \code{None} is returned.
\end{funcdesc}
\begin{funcdesc}
{
translation
}{
domain
\optional
{
, localedir
\optional
{
,
languages
\optional
{
, class
_}}}}
languages
\optional
{
,
class
_
,
\optional
{
fallback
}}}}}
Return a
\class
{
Translations
}
instance based on the
\var
{
domain
}
,
\var
{
localedir
}
, and
\var
{
languages
}
, which are first passed to
\function
{
find()
}
to get the
...
...
@@ -132,7 +133,9 @@ identical \file{.mo} file names are cached. The actual class instantiated
is either
\var
{
class
_}
if provided, otherwise
\class
{
GNUTranslations
}
. The class's constructor must take a single
file object argument. If no
\file
{
.mo
}
file is found, this
function raises
\exception
{
IOError
}
.
function raises
\exception
{
IOError
}
if
\var
{
fallback
}
is false
(which is the default), and returns a
\class
{
NullTranslations
}
instance
if
\var
{
fallback
}
is true.
\end{funcdesc}
\begin{funcdesc}
{
install
}{
domain
\optional
{
, localedir
\optional
{
, unicode
}}}
...
...
Lib/gettext.py
Dosyayı görüntüle @
1be64198
...
...
@@ -230,11 +230,14 @@ def find(domain, localedir=None, languages=None):
# a mapping between absolute .mo file path and Translation object
_translations
=
{}
def
translation
(
domain
,
localedir
=
None
,
languages
=
None
,
class_
=
None
):
def
translation
(
domain
,
localedir
=
None
,
languages
=
None
,
class_
=
None
,
fallback
=
0
):
if
class_
is
None
:
class_
=
GNUTranslations
mofile
=
find
(
domain
,
localedir
,
languages
)
if
mofile
is
None
:
if
fallback
:
return
NullTranslations
()
raise
IOError
(
ENOENT
,
'No translation file found for domain'
,
domain
)
key
=
os
.
path
.
abspath
(
mofile
)
# TBD: do we need to worry about the file pointer getting collected?
...
...
@@ -248,7 +251,7 @@ def translation(domain, localedir=None, languages=None, class_=None):
def
install
(
domain
,
localedir
=
None
,
unicode
=
0
):
translation
(
domain
,
localedir
)
.
install
(
unicode
)
translation
(
domain
,
localedir
,
fallback
=
1
)
.
install
(
unicode
)
...
...
Misc/NEWS
Dosyayı görüntüle @
1be64198
...
...
@@ -26,6 +26,8 @@ Library
arbitrary shell code can't be executed because a bogus URL was
passed in.
- gettext.translation has an optional fallback argument.
Tools/Demos
Build
...
...
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