예제 #1
0
 def _set_catalog(self):
     # Set the catalog object
     self.cat = gettext.Catalog(self.domain,
                                localedir=self.localedir,
                                languages=self.langs,
                                fallback=1,
                                class_=RHN_Translations)
예제 #2
0
def locale():
    cat = gettext.Catalog(config.NAME.lower(), config.LOCALE_DIR, languages=[locale_current])

    def get_text(message):
        result = cat.gettext(message)
        # if result == message:
        #     logging.debug('No translation "{}"'.format(result))
        return result

    return get_text
예제 #3
0
"""Internationalization (i18n) support for Gaphor.

Here the _() function is defined that is used to translate text into
your native language."""

__all__ = ["_"]

import os

import gettext
import importlib_metadata

localedir = os.path.join(
    importlib_metadata.distribution("gaphor").locate_file(
        "gaphor/data/locale"))

try:

    catalog = gettext.Catalog("gaphor", localedir=localedir)
    _ = catalog.gettext

except IOError as e:

    def _(s):
        return s
예제 #4
0
#
# Gaphor is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the GNU Library General Public License
# more details.
#
# You should have received a copy of the GNU Library General Public
# along with Gaphor.  If not, see <http://www.gnu.org/licenses/>.
from __future__ import absolute_import

import gettext
import os

import pkg_resources

__all__ = ['_']

localedir = os.path.join(
    pkg_resources.get_distribution('gaphor').location, 'gaphor', 'data',
    'locale')

try:

    catalog = gettext.Catalog('gaphor', localedir=localedir)
    _ = catalog.gettext

except IOError as e:

    def _(s):
        return s
예제 #5
0
# ReStructuredText config
# http://docs.python.org/release/2.7/documenting/rest.html#sections
RST_KEYS = 'title level1 level2 level3 level4 level5 bar1 bullet'.split()
RST_VALUES = '#*=-^"--'  # do not edit here, please use --chars
RST = dict(zip(RST_KEYS, RST_VALUES))

# CSV config
CSV_KEYS = 'separator quotechar'.split()
CSV_VALUES = ','  # do not edit here, please use --chars
CSV = dict(zip(CSV_KEYS, CSV_VALUES))

################################################################################
# i18n - just use if available

if USE_I18N:
    try:
        import gettext
        # If your locale dir is different, change it here
        cat = gettext.Catalog('txt2tags', localedir='/usr/share/locale/')
        _ = cat.gettext
    except:
        _ = lambda x: x
else:
    _ = lambda x: x

################################################################################
# Targets import

for target in TARGETS_LIST:
    exec('import ' + target)
예제 #6
0
    f = open("/etc/enigma2/settings")
    line = f.readline()
    while (line):
        line = f.readline().replace("\n", "")
        sp = line.split("=")
        if (sp[0] == "config.osd.language"):
            sp2 = sp[1].split("_")
            quickepg_language = sp2[0]
            if os.path.exists("%s/locale/%s" %
                              (quickepg_plugindir, quickepg_language)) == True:
                os.environ["LANGUAGE"] = sp[1]
            else:
                os.environ['LANGUAGE'] = 'en'
    f.close

_ = gettext.Catalog('QuickEPG', '%s/locale' % quickepg_plugindir).gettext


def main(session, **kwargs):
    session.open(QuickEPGPlugin)


def autostart(reason, **kwargs):
    if reason == 0:
        print "[QUICKEPG] no autostart"


def Plugins(path, **kwargs):
    return [
        PluginDescriptor(
            name=_("Quick EPG Import"),
예제 #7
0
import gettext
import os

from TkPy3.locale_dirs import BASE_DIR

_ = gettext.Catalog('tkpy3', os.path.join(BASE_DIR, 'locale'),
                    ['zh-CN']).gettext
예제 #8
0
파일: conf.py 프로젝트: wyrover/groonga
# The short X.Y version.
version = os.environ["DOCUMENT_VERSION"]
# The full version, including alpha/beta/rc tags.
release = os.environ["DOCUMENT_VERSION_FULL"]

# The directories that has *.mo files.
locale_dirs = ["../locale"]

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
language = os.environ['LOCALE']

locale_dir = os.path.dirname(__file__) + "/../locale"
try:
    catalog = gettext.Catalog("conf",
                              localedir=locale_dir,
                              languages=[language])
    _ = catalog.gettext
except:
    _ = lambda msgid: msgid

# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = [
    '**/.#*',
예제 #9
0
 def update_event(self, inp=-1):
     self.set_output_val(
         0,
         gettext.Catalog(self.input(0), self.input(1), self.input(2),
                         self.input(3), self.input(4), self.input(5)))
예제 #10
0
파일: i18n.py 프로젝트: xnox/ubuntu-image
import gettext

catalog = gettext.Catalog("ubuntu-image", fallback=gettext.NullTranslations)

_ = catalog.gettext

__all__ = ('catalog', '_')
예제 #11
0
from datetime import datetime
import traceback
import thread

TRANSMIT_CHUNK_SIZE = 1024
RECEIVE_CHUNK_SIZE = 1024
# the prefix to add before the root directory
# For example, if PREFIX is "/root" and the host is 127.0.0.1, then
# the root directory is http://127.0.0.1/root
PREFIX = "/files"
DOWNLOAD_TAR_PREFIX = "/download_tar"
UPLOAD_PREFIX = "/upload"

###### Initialize Translations ######
try:
    translation_catalog = gettext.Catalog("http-file-share")
    _ = translation_catalog.gettext
except:
    _ = lambda s: s

###### Helper Functions ######


def is_file(path):
    return os.path.isfile(path)


def is_dir(path, AllowLink=False):
    """ Determine whether path is a directory, excluding symbolic links """
    return os.path.isdir(path) and (AllowLink or (not os.path.islink(path)))
    def __init__(self, dodestroy=1):
        write_formats = [
            "8BIM Photoshop resource format", "AVS AVS X image",
            "BMP Microsoft Windows bitmap image",
            "BMP24 Microsoft Windows 24bit bitmap image",
            "DIB Microsoft Windows bitmap image",
            "CACHE Magick Persistent Cache image format",
            "CMYK Raw cyan, magenta, yellow, and black bytes",
            "EPT Adobe Encapsulated PostScript with TIFF preview",
            "FAX Group 3 FAX", "G3 Group 3 FAX",
            "FITS Flexible Image Transport System", "FPX FlashPix Format",
            "GIF CompuServe graphics interchange format",
            "GIF87 CompuServe graphics interchange format (version 87a)",
            "GRAY Raw gray bytes", "HDF Hierarchical Data Format",
            "HISTOGRAM Histogram of the image", "IPTC IPTC Newsphoto",
            "BIE Joint Bilevel Image experts Group interchange format",
            "JBG Joint Bilevel Image experts Group interchange format",
            "JBIG Joint Bilevel Image experts Group interchange format",
            "JPEG24 Joint Photographic Experts Group JFIF format",
            "JPEG Joint Photographic Experts Group JFIF format",
            "JPG Joint Photographic Experts Group JFIF format",
            "GRANITE Granite texture", "LOGO ImageMagick Logo",
            "MAP Colormap intensities and indices", "MATTE MATTE format",
            "MIFF Magick image format",
            "MONO Bilevel bitmap in leastsignificantbyte first order",
            "MTV MTV Raytracing image format", "PCD Photo CD", "PCDS Photo CD",
            "PCL Page Control Language",
            "DCX ZSoft IBM PC multipage Paintbrush",
            "PCX ZSoft IBM PC Paintbrush",
            "EPDF Encapsulated Portable Document Format",
            "PDF Portable Document Format",
            "PCT Apple Macintosh QuickDraw/PICT",
            "PICT Apple Macintosh QuickDraw/PICT",
            "PICT24 24bit Apple Macintosh QuickDraw/PICT",
            "PNG Portable Network Graphics",
            "PBM Portable bitmap format (black and white)",
            "PGM Portable graymap format (gray scale)", "PNM Portable anymap",
            "PPM Portable pixmap format (color)",
            "EPI Adobe Encapsulated PostScript Interchange format",
            "EPS Adobe Encapsulated PostScript",
            "EPSF Adobe Encapsulated PostScript",
            "EPSI Adobe Encapsulated PostScript Interchange format",
            "PS Adobe PostScript",
            "EPS2 Adobe Level II Encapsulated PostScript",
            "PS2 Adobe Level II PostScript", "PS3 Adobe Level III PostScript",
            "PSD Adobe Photoshop bitmap", "RGB Raw red, green, and blue bytes",
            "RGBA Raw red, green, blue, and matte bytes", "SGI Irix RGB image",
            "RAS SUN Rasterfile", "SUN SUN Rasterfile",
            "ICB Truevision Targa image", "TGA Truevision Targa image",
            "VDA Truevision Targa image", "VST Truevision Targa image",
            "PTIF Pyramid encoded TIFF", "TIF Tagged Image File Format",
            "TIFF Tagged Image File Format",
            "TIFF24 24bit Tagged Image File Format", "UIL XMotif UIL table",
            "PAL 16bit/pixel interleaved YUV",
            "UYVY 16bit/pixel interleaved YUV",
            "VICAR VICAR rasterfile format", "VIFF Khoros Visualization image",
            "XV Khoros Visualization image",
            "WBMP Wireless Bitmap (level 0) image",
            "XBM X Windows system bitmap (black and white)",
            "PM X Windows system pixmap (color)",
            "XPM X Windows system pixmap (color)",
            "XWD X Windows system window dump (color)", "YUV CCIR 601 4:1:1",
            "PALM Pixmap Format", "PICON Personal Icon",
            "ROSE 70x64 Truecolor Test Image",
            "CMYKA Raw cyan, magenta, yellow, and matte bytes",
            "APP1 Photoshop resource format", "H Internal Format",
            "ICC Color Profile", "JP2 JPEG-2000 JP2 File Format Syntax",
            "JPC JPEG-2000 JPC Code Stream Syntax",
            "VID Visual Image Directory", "P7 Xv Thumbnail Format",
            "M2V Mpeg 2 Video Stream (Single Frame)",
            "MPEG Mpeg 1 Video Stream (Single Frame)",
            "MPG Mpeg 1 Video Stream (Single Frame)", "OTB On-the-air Bitmap",
            "DPX Digital Moving Picture Exchange", "ILBM Amiga IFF",
            "RAD Radiance Image File", "MNG Multipleimage Network Graphics"
        ]
        self.targets = [('STRING', 0, 0), ('text/plain', 0, 1),
                        ('text/uri-list', 0, 2)]
        # gettext locale support
        self.xtext = gettext.NullTranslations()
        try:
            # open ganim8ctmo in /usr/share/locale
            self.xtext = gettext.Catalog("ganim8ct")
        except:
            self.xtext = gettext.NullTranslations()
        self.tips = GtkTooltips()
        global cversion
        global read_formats
        read_formats.sort()
        write_formats.sort()
        convwindow = GtkWindow(GTK.WINDOW_TOPLEVEL)
        convwindow.set_position(GTK.WIN_POS_CENTER)
        if dodestroy == 1: convwindow.connect("destroy", quit)
        if dodestroy == 1: convwindow.set_wmclass("ganim8ct", "gAnim8CT")
        else: convwindow.connect("destroy", self.hideit)
        self._root = convwindow
        convwindow.realize()
        self.sel_file = None
        self.sel_file2 = None
        convwindow.set_title("gAnim8 Conversion Tool " + cversion)
        convwindow.set_position(GTK.WIN_POS_NONE)
        self.convwindow = convwindow
        hbox1 = GtkHBox(0, 0)
        self.hbox1 = hbox1
        vbox1 = GtkVBox(0, 0)
        self.vbox1 = vbox1
        try:
            header = self.loadImage(getPixDir() + "ganim8_ct.gif")
        except:
            header = GtkLabel("gAnim8 Conversion Tool")
        if not header: header = GtkLabel("gAnim8 Conversion Tool")
        vbox1.pack_start(header, 1, 1, 5)
        vbox1.pack_start(GtkHSeparator(), 1, 1, 1)

        table1 = GtkTable(2, 2, 0)
        table1.set_border_width(1)

        vbox2 = GtkVBox(0, 0)
        label3 = GtkLabel(self.trans_text("Convert FROM:"))
        label3.set_justify(GTK.JUSTIFY_LEFT)
        label3.set_alignment(0, 0.5)
        vbox2.pack_start(label3, 0, 0, 2)
        label6 = GtkLabel(self.trans_text("Type") + ":   ")
        label6.set_alignment(0, 0.5)
        table1.attach(label6, 0, 1, 0, 1, (GTK.EXPAND + GTK.FILL),
                      (GTK.EXPAND + GTK.FILL), 0, 0)
        fromtype = GtkCombo()
        fromtype.set_popdown_strings(read_formats)
        self.fromtype = fromtype
        fromtypeentry = fromtype.entry
        fromtypeentry.set_text(
            "JPEG Joint Photographic Experts Group JFIF format")
        fromtypeentry.set_editable(0)
        self.fromtypeentry = fromtypeentry
        table1.attach(fromtype, 1, 2, 0, 1, (GTK.EXPAND + GTK.FILL),
                      (GTK.EXPAND + GTK.FILL), 0, 0)
        hbox3 = GtkHBox(0, 0)
        hbox3.set_spacing(2)
        label7 = GtkLabel(self.trans_text("File") + ": ")
        label7.set_alignment(0, 0.5)
        table1.attach(label7, 0, 1, 1, 2, (GTK.EXPAND + GTK.FILL),
                      (GTK.EXPAND + GTK.FILL), 0, 0)
        fromfileentry = GtkEntry()
        self.fromfileentry = fromfileentry
        fromfileentry.set_usize(210, -2)
        self.fromfileentry.drag_dest_set(
            gtk.DEST_DEFAULT_ALL, self.targets,
            gtk.GDK.ACTION_COPY | gtk.GDK.ACTION_MOVE)
        self.fromfileentry.connect("drag_drop", self.setDrag)
        self.fromfileentry.connect("drag_begin", self.setDrag)
        self.fromfileentry.connect("drag_data_received", self.setDrag)
        hbox3.pack_start(fromfileentry, 1, 1, 0)
        frombrowse = self.getPixButton(getPixDir() + "gtksnap_open.xpm",
                                       self.trans_text("Browse..."), 0)
        frombrowse.connect("clicked", self.getFromFile)
        self.frombrowse = frombrowse
        hbox3.pack_start(frombrowse, 0, 1, 0)
        table1.attach(hbox3, 1, 2, 1, 2, (GTK.EXPAND + GTK.FILL),
                      (GTK.EXPAND + GTK.FILL), 0, 0)
        vbox2.pack_start(table1, 0, 0, 0)
        vbox2.pack_start(GtkHSeparator(), 0, 0, 7)
        vbox1.pack_start(vbox2, 1, 1, 0)
        vbox3 = GtkVBox(0, 0)

        label5 = GtkLabel(self.trans_text("Convert TO:"))
        label5.set_alignment(0, 0.5)
        table2 = GtkTable(2, 2, 0)
        table2.set_border_width(1)
        vbox3.pack_start(label5, 0, 0, 0)
        label8 = GtkLabel(self.trans_text("Type") + ":   ")
        label8.set_alignment(0, 0.5)
        table2.attach(label8, 0, 1, 0, 1, (GTK.EXPAND + GTK.FILL),
                      (GTK.EXPAND + GTK.FILL), 0, 0)
        totype = GtkCombo()
        totype.set_popdown_strings(write_formats)
        self.totype = totype
        totypeentry = totype.entry
        totypeentry.set_text("GIF CompuServe graphics interchange format")
        totypeentry.set_editable(0)
        self.totypeentry = totypeentry
        table2.attach(totype, 1, 2, 0, 1, (GTK.EXPAND + GTK.FILL),
                      (GTK.EXPAND + GTK.FILL), 0, 0)
        hbox5 = GtkHBox(0, 0)
        hbox5.set_spacing(2)
        label9 = GtkLabel(self.trans_text("File") + ": ")
        label9.set_alignment(0, 0.5)
        table2.attach(label9, 0, 1, 1, 2, (GTK.EXPAND + GTK.FILL),
                      (GTK.EXPAND + GTK.FILL), 0, 0)
        tofileentry = GtkEntry()
        tofileentry.set_usize(210, -2)
        self.tofileentry = tofileentry
        self.tofileentry.drag_dest_set(
            gtk.DEST_DEFAULT_ALL, self.targets,
            gtk.GDK.ACTION_COPY | gtk.GDK.ACTION_MOVE)
        self.tofileentry.connect("drag_drop", self.setDrag)
        self.tofileentry.connect("drag_begin", self.setDrag)
        self.tofileentry.connect("drag_data_received", self.setDrag)
        hbox5.pack_start(tofileentry, 1, 1, 0)
        tobrowse = self.getPixButton(getPixDir() + "gtksnap_open.xpm",
                                     self.trans_text("Browse..."), 0)
        tobrowse.connect("clicked", self.getToFile)

        hbox5.pack_start(tobrowse, 0, 0, 0)
        table2.attach(hbox5, 1, 2, 1, 2, (GTK.EXPAND + GTK.FILL),
                      (GTK.EXPAND + GTK.FILL), 0, 0)
        vbox3.pack_start(table2, 1, 1, 0)
        vbox3.pack_start(GtkHSeparator(), 0, 0, 6)
        vbox1.pack_start(vbox3, 0, 0, 0)
        hbox7 = GtkHBox(1, 0)
        hbox7.set_spacing(3)
        compbutt = self.getPixButton(getPixDir() + "gtksnap_compress.xpm",
                                     "Compress GIF", 1)
        compbutt.connect("clicked", self.doCompress)
        self.compbutt = compbutt
        self.compbutt.set_sensitive(0)
        hbox7.pack_start(compbutt, 1, 1, 3)
        convertbutt = self.getPixButton(getPixDir() + "gtksnap_save.xpm",
                                        "CONVERT", 1)
        convertbutt.connect("clicked", self.startConvert)
        hbox7.pack_start(convertbutt, 1, 1, 3)
        vbox1.pack_start(hbox7, 0, 1, 4)
        hbox6 = GtkHBox(0, 0)
        aboutbutt = GtkButton(self.trans_text("About..."))
        aboutbutt.connect("clicked", self.showAbout)
        hbox6.pack_start(aboutbutt, 1, 1, 3)
        closebutt = GtkButton(self.trans_text("Exit"))
        if dodestroy == 1: closebutt.connect("clicked", quit)
        else: closebutt.connect("clicked", self.hideit)
        hbox6.pack_start(closebutt, 1, 1, 3)
        vbox1.pack_start(hbox6, 0, 0, 4)
        hbox1.pack_start(vbox1, 0, 0, 3)
        imagewindow = GtkScrolledWindow()
        self.imagewindow = imagewindow
        toplay = GtkLayout(None, None)
        self.toplay = toplay
        toplay.set_size(200, 500)
        toplay.set_hadjustment(imagewindow.get_hadjustment())
        imagewindow.add(toplay)
        hbox1.pack_start(imagewindow, 1, 1, 0)
        vbox20 = GtkVBox(0, 0)
        vbox20.pack_start(hbox1, 1, 1, 2)
        statusbar = GtkStatusbar()
        self.statusbar = statusbar
        statid = statusbar.get_context_id("ganim8cv")
        self.statid = statid
        vbox20.pack_start(statusbar, 0, 0, 2)
        convwindow.add(vbox20)
        vbox20.drag_dest_set(gtk.DEST_DEFAULT_ALL, self.targets,
                             gtk.GDK.ACTION_COPY | gtk.GDK.ACTION_MOVE)
        vbox20.connect("drag_drop", self.setWinDrag)
        vbox20.connect("drag_begin", self.setWinDrag)
        vbox20.connect("drag_data_received", self.setWinDrag)
        convwindow.set_usize(585, -2)
        self.showStatus(
            self.trans_text(
                "Copyright 2003 by Erica Andrews. All rights reserved."))
        self.setTip(fromtypeentry, "Select the image format to convert FROM")
        self.setTip(fromtype, "Select the image format to convert FROM")
        self.setTip(frombrowse, "Select the image you wish to convert")
        self.setTip(fromfileentry, "Select the image you wish to convert")
        self.setTip(aboutbutt, "About")
        self.setTip(closebutt, "Exit")
        self.setTip(
            compbutt,
            "Compress the GIF (if applicable)\nRequires the optional Gifsicle program to be on your path."
        )
        self.setTip(convertbutt, "Convert the image")
        self.setTip(tobrowse, "Select the file to save the new image to")
        self.setTip(tofileentry, "Select the file to save the new image to")
        self.setTip(totype, "Select the image format to convert TO")
        self.setTip(totypeentry, "Select the image format to convert TO")

        convwindow.show_all()
    def __init__(self,dodestroy=1,tempd="/tmp/") :
	global temp_dir
	temp_dir=tempd
	self.temp_dir=tempd
        write_formats=["8BIM Photoshop resource format","AVS AVS X image","BMP Microsoft Windows bitmap image","BMP24 Microsoft Windows 24bit bitmap image","DIB Microsoft Windows bitmap image","CACHE Magick Persistent Cache image format","CMYK Raw cyan, magenta, yellow, and black bytes","EPT Adobe Encapsulated PostScript with TIFF preview","FAX Group 3 FAX","G3 Group 3 FAX","FITS Flexible Image Transport System","FPX FlashPix Format","GIF CompuServe graphics interchange format","GIF87 CompuServe graphics interchange format(version 87a)","GRAY Raw gray bytes","HDF Hierarchical Data Format","HISTOGRAM Histogram of the image","IPTC IPTC Newsphoto","BIE Joint Bilevel Image experts Group interchange format","JBG Joint Bilevel Image experts Group interchange format","JBIG Joint Bilevel Image experts Group interchange format","JPEG24 Joint Photographic Experts Group JFIF format","JPEG Joint Photographic Experts Group JFIF format","JPG Joint Photographic Experts Group JFIF format","GRANITE Granite texture","LOGO ImageMagick Logo","MAP Colormap intensities and indices","MATTE MATTE format","MIFF Magick image format","MONO Bilevel bitmap in leastsignificantbyte first order","MTV MTV Raytracing image format","PCD Photo CD","PCDS Photo CD","PCL Page Control Language","DCX ZSoft IBM PC multipage Paintbrush","PCX ZSoft IBM PC Paintbrush","EPDF Encapsulated Portable Document Format","PDF Portable Document Format","PCT Apple Macintosh QuickDraw/PICT","PICT Apple Macintosh QuickDraw/PICT","PICT24 24bit Apple Macintosh QuickDraw/PICT","PNG Portable Network Graphics","PBM Portable bitmap format(black and white)","PGM Portable graymap format(gray scale)","PNM Portable anymap","PPM Portable pixmap format(color)","EPI Adobe Encapsulated PostScript Interchange format","EPS Adobe Encapsulated PostScript","EPSF Adobe Encapsulated PostScript","EPSI Adobe Encapsulated PostScript Interchange format","PS Adobe PostScript","EPS2 Adobe Level II Encapsulated PostScript","PS2 Adobe Level II PostScript","PS3 Adobe Level III PostScript","PSD Adobe Photoshop bitmap","RGB Raw red, green, and blue bytes","RGBA Raw red, green, blue, and matte bytes","SGI Irix RGB image","RAS SUN Rasterfile","SUN SUN Rasterfile","ICB Truevision Targa image","TGA Truevision Targa image","VDA Truevision Targa image","VST Truevision Targa image","PTIF Pyramid encoded TIFF","TIF Tagged Image File Format","TIFF Tagged Image File Format","TIFF24 24bit Tagged Image File Format","UIL XMotif UIL table","PAL 16bit/pixel interleaved YUV","UYVY 16bit/pixel interleaved YUV","VICAR VICAR rasterfile format","VIFF Khoros Visualization image","XV Khoros Visualization image","WBMP Wireless Bitmap(level 0) image","XBM X Windows system bitmap(black and white)","PM X Windows system pixmap(color)","XPM X Windows system pixmap(color)","XWD X Windows system window dump(color)","YUV CCIR 601 4:1:1" , "PALM Pixmap Format","PICON Personal Icon", "ROSE 70x64 Truecolor Test Image","CMYKA Raw cyan, magenta, yellow, and matte bytes","APP1 Photoshop resource format","H Internal Format","ICC Color Profile","JP2 JPEG-2000 JP2 File Format Syntax","JPC JPEG-2000 JPC Code Stream Syntax","VID Visual Image Directory","P7 Xv Thumbnail Format",    "M2V Mpeg 2 Video Stream(Single Frame)","MPEG Mpeg 1 Video Stream(Single Frame)","MPG Mpeg 1 Video Stream(Single Frame)","OTB On-the-air Bitmap","DPX Digital Moving Picture Exchange","ILBM Amiga IFF","RAD Radiance Image File","MNG Multipleimage Network Graphics"]

	# gettext locale support
	self.xtext=gettext.NullTranslations()
	try:
		# open gtksnapshot.mo in /usr/share/locale
		self.xtext=gettext.Catalog("gtksnapshot")
	except:
		self.xtext=gettext.NullTranslations()

        write_formats.sort()
	self.CAPTURE=None
	global cversion
	convwindow=GtkWindow(GTK.WINDOW_TOPLEVEL)
	tips=GtkTooltips()
	if dodestroy==1: convwindow.set_wmclass("gtksnapshot","GtkSnapshot")
        convwindow.set_position(GTK.WIN_POS_CENTER)
        if dodestroy==1: convwindow.connect("destroy",quit)
        else: convwindow.connect("destroy",self.hideit)
	convwindow.realize()
        self.sel_file=None
	convwindow.set_title("GtkSnapshot "+cversion)
	convwindow.set_position(GTK.WIN_POS_CENTER)
	self.convwindow=convwindow
	hbox1=GtkHBox(0, 0)
	vbox1=GtkVBox(0, 0)
        try:
          header=GtkPixmap(convwindow,getPixDir()+"gtksnap_logo.xpm",None)
        except:
	  header=GtkLabel("GtkSnapshot "+cversion)
        if not header: header=GtkLabel("GtkSnapshot "+cversion)
	self.header=header
	vbox1.pack_start(header, 0, 0, 2)

	imagewindow=GtkScrolledWindow()
	self.imagewindow=imagewindow
        toplay=GtkLayout(None,None)
        self.toplay=toplay
        toplay.set_size(500,500)
        toplay.set_hadjustment(imagewindow.get_hadjustment())
	imagewindow.add(toplay)
	imagewindow.set_usize(205,155)
	vbox1.pack_start( imagewindow, 1, 1, 0)
	vbox3=GtkVBox(0, 0)
	table1=GtkTable(2,2,0)
	table1.set_border_width(1)
	label8=GtkLabel(self.trans_text("Save As:")+"  ")
	label8.set_alignment( 0, 0.5)
	table1.attach(label8,0,1,0,1,(GTK.EXPAND+GTK.FILL),(GTK.EXPAND+GTK.FILL),0,0)
	totype=GtkCombo()
	tips.set_tip(totype,self.trans_text("Select the image format you want the screenshot saved as"))
        totype.set_popdown_strings(write_formats)
        totype.set_usize(270,-2)
	self.totype=totype
	totypeentry=totype.entry
	tips.set_tip(totypeentry,self.trans_text("Select the image format you want the screenshot saved as"))
        totypeentry.set_text("GIF CompuServe graphics interchange format")
        totypeentry.set_editable(0)
	self.totypeentry=totypeentry
	table1.attach(totype,1,2,0,1,(GTK.EXPAND+GTK.FILL),(GTK.EXPAND+GTK.FILL),0,0)
	hbox5=GtkHBox(0, 0)
	label9=GtkLabel(self.trans_text("File")+":         ")
	label9.set_alignment( 0, 0.5)
	table1.attach(label9,0,1,1,2,(GTK.EXPAND+GTK.FILL),(GTK.EXPAND+GTK.FILL),0,0)
	tofileentry=GtkEntry()
        tofileentry.set_usize(210,-2)
	self.tofileentry=tofileentry
	tips.set_tip(tofileentry,self.trans_text("Enter a file name to save the screenshot to"))
        self.targets = [('STRING', 0, 0), ('text/plain', 0,1), ('text/uri-list', 0, 2) ]
        self.tofileentry.drag_dest_set(gtk.DEST_DEFAULT_ALL, self.targets, gtk.GDK.ACTION_COPY | gtk.GDK.ACTION_MOVE)
	self.tofileentry.connect("drag_drop",self.setDrag)
	self.tofileentry.connect("drag_begin",self.setDrag)
	self.tofileentry.connect("drag_data_received",self.setDrag)
	try:
		tofileentry.set_text(os.environ["HOME"]+"/screenshot.gif")
	except:
		pass
	hbox5.pack_start( tofileentry, 1, 1, 0)
	tobrowse=self.getPixButton (getPixDir()+"gtksnap_open.xpm",self.trans_text("Browse..."),0)
	tips.set_tip(tobrowse,self.trans_text("Select a file to save the screenshot to"))
        tobrowse.connect("clicked",self.getToFile)
	hbox5.pack_start( tobrowse, 0, 0, 1)
	table1.attach(hbox5,1,2,1,2,(GTK.EXPAND+GTK.FILL),(GTK.EXPAND+GTK.FILL),0,0)
	vbox3.pack_start( table1, 1, 1, 0)

	buttbox=GtkHBox(0,0)
	buttbox.set_homogeneous(1)
	buttbox.set_spacing(5)
	compbutt=self.getPixButton (getPixDir()+"gtksnap_compress.xpm","Compress GIF",1)
	tips.set_tip(compbutt,self.trans_text("Compress the GIF (if applicable)\nRequires the optional Gifsicle program to be on your path."))
        compbutt.connect("clicked",self.doCompress)       
	self.compbutt=compbutt
        self.compbutt.set_sensitive(0)
	buttbox.pack_start(compbutt,1,1,0)
	convertbutt=self.getPixButton (getPixDir()+"gtksnap_save.xpm","SAVE",1)
	tips.set_tip(convertbutt,self.trans_text("Save this screenshot to the selected file"))
        convertbutt.connect("clicked",self.startSave)
	buttbox.pack_start( convertbutt, 1, 1, 0)
	vbox3.pack_start( buttbox, 0, 0, 4)

	vbox3.pack_start( GtkHSeparator(), 0,0, 3)
	vbox1.pack_start( vbox3, 0, 0, 0)

	hbox6=GtkVBox(0, 0)
	grabw=self.getPixButton (getPixDir()+"gtksnap_capture.xpm","CAPTURE Window or Screen Area",1)
	tips.set_tip(grabw,self.trans_text("Take a screenshot of a specific window or a selectable area of the screen"))
        grabw.connect("clicked",self.doGrabWindow)
	hbox6.pack_start( grabw, 1, 1, 1)
	self.includeframe=GtkCheckButton(" "+self.trans_text("Include Window Frame"))
	tips.set_tip(self.includeframe,self.trans_text("If checked, the window's frame will be included in the screenshot (if applicable)."))
	hbox6.pack_start( self.includeframe, 1, 1, 1)
	self.includeframe.set_active(1)
	hbox6.pack_start( GtkHSeparator(), 0,0, 3)
	grabd=self.getPixButton (getPixDir()+"gtksnap_capture.xpm","CAPTURE Entire Desktop",1)
	tips.set_tip(grabd,self.trans_text("Take a screenshot of the WHOLE desktop"))
        grabd.connect("clicked",self.doGrabDesktop)
	hbox6.pack_start(grabd, 1, 1, 1)
	vbox1.pack_start( hbox6, 0, 0, 3)
	hbox1.pack_start( vbox1, 1, 1, 6)

        vbox20=GtkVBox(0,0)

	mymeth=quit
        if not dodestroy==1: mymeth=self.hideit

	mymenubar=GtkMenuBar()
	ag=GtkAccelGroup()
        itemf=GtkItemFactory(GtkMenuBar, "<main>", ag)
        itemf.create_items([
        # path              key           callback    action#  type
  	("/ _"+self.trans_text("File"),  "<alt>F",  None,  0,"<Branch>"),	
   	("/ _"+self.trans_text("File")+"/"+self.trans_text("Capture _Window or Screen Area")+"...", "<alt>W", self.doGrabWindow,865,""),
   	("/ _"+self.trans_text("File")+"/"+self.trans_text("Capture Entire _Desktop")+"...", "<alt>D", self.doGrabDesktop,864,""),
   	("/ _"+self.trans_text("File")+"/_"+self.trans_text("Save"), "<control>S", self.startSave,863,""),
   	("/ _"+self.trans_text("File")+"/_"+self.trans_text("Print..."), "<control>P", self.startPrint,877,""),
   	("/ _"+self.trans_text("File")+"/sep1", None, None,869,"<Separator>"),   
   	("/ _"+self.trans_text("File")+"/_"+self.trans_text("Exit"), "<control>Q", mymeth,867,""),   	   		  
  	("/ _"+self.trans_text("Help"),  "<alt>H",  None, 900,"<LastBranch>"),   
  	("/ _"+self.trans_text("Help")+"/_"+self.trans_text("About..."), "F2", self.showAbout,901,""),  	
	])
	convwindow.add_accel_group(ag)
        mymenubar=itemf.get_widget("<main>")
        mymenubar.show()
	vbox20.pack_start(mymenubar,0,0,0)

        vbox20.pack_start(hbox1,1,1,2)
	statusbar=GtkStatusbar()
	self.statusbar=statusbar
        statid=statusbar.get_context_id("ganim8snap")
        self.statid=statid
        vbox20.pack_start(statusbar,0,0,2)
	convwindow.add(vbox20)
        self.showStatus(self.trans_text("Copyright 2003 by Erica Andrews. All rights reserved."))
	os.popen("rm -f "+temp_dir+"gtksnapshot* &") # Delete any temporary files
  	os.popen("rm -f /tmp/gtksnapshot* &") # Delete any temporary files
	convwindow.show_all()
예제 #14
0
"""
Copyright 2017 Arm Ltd.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

SPDX-License-Identifier: Apache-2.0
"""

import gettext
import os
from . import __name__ as PACKAGE

localedir = os.path.join(os.path.dirname(__file__), 'locale')
cat = gettext.Catalog(PACKAGE, localedir=localedir, fallback=True)
_ = cat.gettext
예제 #15
0
# Python Multilingual API
# gettext — Multilingual internationalization services.
# The gettext module provides internationalization (I18N) and localization (L10N) services for your Python modules and applications.
# It supports both the GNU gettext message catalog API and a higher level, class-based API that may be more appropriate for Python files.
# The interface described below allows you to write your module and application messages in one natural language, and provide a catalog of translated
# messages for running under different natural languages.
#
# GNU gettext API:
#
# The gettext module defines the following API, which is very similar to the GNU gettext API.
# If you use this API you will affect the translation of your entire application globally.
# Often this is what you want if your application is monolingual, with the choice of language dependent on the locale of your user.
# If you are localizing a Python module, or if your application needs to switch languages on the fly, you probably want to use the class-based API instead.
#
# Solaris message catalog support.
# The Solaris operating system defines its own binary .mo file format, but since no documentation can be found on this format, it is not supported at this
# time.
#
# The Catalog constructor
# GNOME uses a version of the gettext module by James Henstridge, but this version has a slightly different API. Its documented usage was:
#

import gettext

cat = gettext.Catalog(domain, localedir)

_ = cat.gettext

print(_('hello world'))