File virtaal.spec of Package virtaal

#
# spec file for package virtaal
#
# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
#
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


Name:           virtaal
Version:        0.7.1
Release:        0
# Note that files under share/virtaal/autocorr are LGPL-3.0 licensed
License:        GPL-2.0+ and LGPL-3.0
Summary:        Localization and translation editor
Url:            http://translate.sourceforge.net/wiki/virtaal/index
Group:          Development/Tools/Other
Source:         %{name}-%{version}.tar.bz2
BuildRequires:  desktop-file-utils
BuildRequires:  fdupes
BuildRequires:  gettext-runtime
BuildRequires:  hicolor-icon-theme
BuildRequires:  libglade2
BuildRequires:  python-curl
BuildRequires:  python-devel
BuildRequires:  python-gtk
BuildRequires:  translate-toolkit
BuildRequires:  update-desktop-files

Requires:       %{name}-lang = %{version}
Requires:       python-gnome-extras
Requires:       python-gobject2
Requires:  	 python-gtk
Requires:       python-lxml
Requires:       translate-toolkit
#the optional ones (for full experience)
Requires:       gtkspell
Requires:       python-curl
Requires:       python-Levenshtein
Requires:       python-psycopg2
Requires:       python-simplejson
Requires:       xdg-utils

%{py_requires}

BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch
%lang_package

%description
A program for Computer Aided Translation (CAT) and localization.

Virtaal includes features that allow a localizer to work effectively including:
syntax highlighting, autocomplete and autocorrect.  By showing only
the data that is needed through its simple and effective user interface it
ensures that translators can focus on their current translation task.

A rich set of Translation Memory (TM) plugins provide valuable suggestions to
the translator from sources such as Open-Tran.eu, the current file, and the
translators own TM server.  Similarly Machine Translation (MT) suggestions can
come from Apertium, libtranslate, Google and Moses.

The terminology plugin system will provide terminology hints from Open-Tran.eu,
local terminology files and remote terminology repositories.

Placeholders such as variables, abbreviations, URLs, emails and special
punctutions are highlighted for easy insertion into the translations.

Virtaal is able to edit any of the following formats: XLIFF, Gettext PO and
.mo, Qt .ts, .qph and .qm, Wordfast TM, TMX, OmegaT glossaries and TBX. The
Translate Toolkit converters allow translators to edit: OpenDocument
Format (ODF), OpenOffice.org SDF, Java (and Mozilla) .properties, Mozilla
DTD files, subtitles, and other formats.

%prep
%setup -q

%build
python setup.py build

# Build the translations
./maketranslations %{name}
pushd po
for po in $(ls *.po | grep -E -v de_DE)
do
    mkdir -p locale/$(basename $po .po)/LC_MESSAGES/
    msgfmt $po --output-file=locale/$(basename $po .po)/LC_MESSAGES/%{name}.mo
done
popd

%install

python setup.py install \
      --prefix=%{_prefix} \
      --root=%{buildroot} \


# Install .desktop file and app icon
mkdir -p %{buildroot}%{_datadir}/pixmaps/
mv %{buildroot}%{_datadir}/icons/%{name}.png %{buildroot}%{_datadir}/pixmaps
%suse_update_desktop_file -r %{name} Development Translation
pushd %{buildroot}%{_datadir}/icons/hicolor
  for size in $(ls -d *)
  do
      pushd $size/mimetypes
      ext=png
      if [ "$size" == "scalable" ]; then
          ext=svg
      fi
      for mimetype in \
             text-x-gettext-translation \
             text-x-gettext-translation-template \
             application-x-xliff+xml application-x-xliff \
             text-x-wordfast
      do
          ln -s x-translation.$ext $mimetype.$ext
      done
      popd
  done
popd
cp -rp po/locale %{buildroot}%{_datadir}/

# Temporary fix - should be gone on new version
sed -i 's/\r//' %{buildroot}%{python_sitelib}/virtaal/support/libi18n/locale.py

# Delete unnecessary files (translations not shipped)
rm -r %{buildroot}%{_datadir}/locale/{ak,en_ZA,son,ast,sw}

#Fix for sheband errors:
for lib in %{buildroot}%{python_sitelib}/virtaal/{*.py,*/*.py,*/*/*.py,*/*/*/*.py,*/*/*/*/*.py}; do
 sed '/\/usr\/bin\/env/d' $lib > $lib.new &&
 touch -r $lib $lib.new &&
 mv $lib.new $lib
done

%find_lang %{name}

# create symlinks for man pages
%fdupes -s %{buildroot}/%{_mandir}
# create hardlinks for the rest
%fdupes %{buildroot}

%clean
rm -rf %{buildroot}

%files lang -f %{name}.lang

%files
%defattr(-,root,root)
%doc ChangeLog README LICENSE
%{_bindir}/virtaal
%{_datadir}/icons/hicolor/*/*/*
%{_datadir}/applications/virtaal.desktop
%{_datadir}/icons/virtaal.ico
%{_datadir}/icons/x-translation.ico
%{_datadir}/mime/packages/virtaal-mimetype.xml
%{_datadir}/pixmaps/virtaal.png
%{_datadir}/virtaal/
%{python_sitelib}/virtaal/
%{python_sitelib}/virtaal-%{version}-py%{py_ver}.egg-info

%changelog
openSUSE Build Service is sponsored by