Tuesday, September 6, 2011

GNU Gettext library

gettext is a l10n and i18n library

1. The texts inside source code should be wrapped by gettext function

So the text "My Name is..." becomes _("My Name is...")

2. Then xgettext runs on source code to generate .pot file, which contains the a list of all translatable strings. Translator edits .po files.

msginit --locale=fr --input=name.pot 

3. The .po files are compile into binary .mo file with msgfmt

4. The user, on Unix-type systems, sets the enviroment variable LC_MESSAGES, and the program will display strings in the selected language, if there is an .mo file for it.Then using msginit program translator derives .po file for example for french it will be

Wednesday, March 30, 2011

PDF docs with Mixed Rasted Content

Mixed Rasted Content is the way of keeping images in PDF docs. With couple of words the background image or generally the images in PDF docs are kept in pieces (in segments) for improving the contrast resolution of a raster image composed of pixels. More info on MRC can be found here

Now the problem is that lots of PDF viewers including Okular, Evince, and lots of others are showing the PDF docs with complete noisy background image, i.e. the background image of the docs is just random composition of some colors. Even in Ubuntu distribution the thumbnails are shown in that way.

This is especially problematic when viewing scanned documents in MRC PDFs. Even the converted tools like swftool could not solve the problem, so the only reasonable way is to create PDFs without MRC enabled options. In ABBYY Finereader that can be achieved easily from the saving options.

Another options of doing this is using pdf2pdf converter below which will convert PDFs with MRC to ordinary ones.

The code pdf2pdf converter is:

# Convert a PDF to another PDF. This effectively strips
# out a lot of stuff from most PDF files.

gs=`which gs 2>/dev/null`
if [ ! -x "$gs" ]; then
    echo "Error: install ghostscript first" >&2
    exit 1

while true; do
    case "$1" in
    -?*) OPTS="$OPTS $1";;
    *) break;;

if [ $# -eq 2 ]; then
elif [ $# -eq 1 ]; then
    outfile="`basename \"$1\" .pdf`.new.pdf"
    cat <&2
Usage: pdf2pdf [--pdf-version (1.2|1.3|1.4)] [gs-options ...]  [output.pdf|-]

Converts a PDF from whatever PDF specification version it currently
exists as to the one specified by \`--pdf-version'. Default: 1.2

One side-effect of this conversion is the resulting document will have
the no-printing and no-copying flags removed in the output document if
they are set in the input document.
    exit 1

exec "$gs" $OPTIONS -q -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pdfwrite \
    -dCompatibilityLevel="$pdfver" -sOutputFile="$outfile" -f "$1"

Friday, January 7, 2011

Where the hackintosh comes from ?

Patched Mac OS X kernel : Life-cycle

The kernel of Mac OS X is an open source product which can be found http://opensource.apple.com/ .
The current kernel version is xnu-1504.9.17

The Russian clever guys "teateam" are patching the mach_kernel upon every update of Mac OS X for running on Intel Atom based CPUs.
Here is their blog . The patched kernels are posted in English speaking community here.
The building process of kernel on Mac OS X Snow Leopard is described here

Based on last resource lots of distributions of hackintoshes are created e.g. SnowyWindOSX .

Are the hackintoshes legal ?

In all apple agreement you can find this passage

“2. Permitted License Uses and Restrictions.
A. This License allows you to install and use one copy of the Apple Software on a single Apple-labeled
computer at a time, and you may not make the Apple Software available over a network where it could be used by multiple computers at the same time. If you use Setup Assistant to transfer
software from one Apple-labeled computer to another Apple-labeled computer, please remember that continued use of the original copy of the software may be prohibited once a copy has been
transferred to another computer, unless you already have a licensed copy of such software on both computers. You should check the relevant software license agreements for applicable terms and
conditions. You may make one copy of the Apple Software (excluding the Boot ROM code) in machine-readable form for backup purposes only; provided that the backup copy must include all
copyright or other proprietary notices contained on the original.
B. Certain components of the Apple Software, and third party open source programs included with the Apple Software, have been or may be made available by Apple on its Open Source web site
(http://www.opensource.apple.com/) (collectively the “Open-Sourced Components”). You may modify or replace only these Open-Sourced Components; provided that: (i) the resultant modified
Apple Software is used, in place of the unmodified Apple Software, on a single Apple-labeled computer; and (ii) you otherwise comply with the terms of this License and any applicable licensing
terms governing use of the Open-Sourced Components. Apple is not obligated to provide any maintenance, technical or other support for the resultant modified Apple Software.
C. Except as and only to the extent permitted in this License, by applicable licensing terms governing use of the Open-Sourced Components, or by applicable law, you may not copy, decompile,
reverse engineer, disassemble, modify, or create derivative works of the Apple Software or any part thereof. THE APPLE SOFTWARE IS NOT INTENDED FOR USE IN THE OPERATION OF NUCLEAR
3. Transfer. You may not rent, lease, lend, redistribute or sublicense the Apple Software. You may, however, make a one-time permanent transfer of all of your license rights to the Apple Software
(in its original form as provided by Apple) to another party, provided that: (a) the transfer must include all of the Apple Software, including all its component parts, original media, printed materials
and this License; (b) you do not retain any copies of the Apple Software, full or partial, including copies stored on a computer or other storage device; and© the party receiving the Apple Software
reads and agrees to accept the terms and conditions of this License. You may not rent, lease, lend, redistribute, sublicense or transfer any Apple Software that has been modified or replaced under
Section 2B above. All components of the Apple Software are provided as part of a bundle and may not be separated from the bundle and distributed as standalone applications.
Updates: If an Apple Software update completely replaces (full install) a previously licensed version of the Apple Software, you may not use both versions of the Apple Software at the same time nor
may you transfer them separately.
NFR (Not for Resale) Copies: Notwithstanding other sections of this License, Apple Software labeled or otherwise provided to you on a promotional basis may only be used for demonstration,
testing and evaluation purposes and may not be resold or transferred.”

were says that Apple software can be installed only on apple labeled computers, so this mean that we stick the apple sticker on netbook, notebook or pc then on corresponding device can be easily installed machintosh.