Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[Système] Man et UTF-8 (~ résolu)
View unanswered posts
View posts from last 24 hours

Goto page Previous  1, 2  
Reply to topic    Gentoo Forums Forum Index French
View previous topic :: View next topic  
Author Message
GentooUser@Clubic
l33t
l33t


Joined: 01 Nov 2004
Posts: 829

PostPosted: Thu Mar 15, 2007 5:17 am    Post subject: Reply with quote

Moi mon système est en UTF-8 et j'ai opté pour une approche différente !

D'abord j'ai installé groff-utf8 puis j'ai fait ce script

Code:
#!/bin/bash

IFS=" "

data=$(cat)
enc=$(expr match "$(echo "$data" | file - -i)" '.*charset=\(\S*\)')

if [ $(expr match "$enc" 'us-ascii\|utf-8') -eq 0 ] ; then
        echo "$data" | iconv -c -s -f "$enc" -t "UTF-8"
else
        echo "$data"
fi

unset  IFS


Il converti à la volée en utf-8 toutes les pages de manuel qui ne sont pas en us-ascii ou utf-8.
Après j'ai modifié mon /etc/man.conf comme ça

Code:
NROFF /usr/local/bin/man2utf8 | /usr/bin/groff-utf8 -Tutf8 -c -mandoc

/usr/local/bin/man2utf8 est l'emplacement de mon script.

Avantages:
Ça marche pour toutes les langues francais, russe, japonais... la détection de l'encodage sur le stream par file est excellente !
Rien à recompiler.
Inconvenient:
C'est un peu lent avec les grosses pages man, comptez 3 secondes pour afficher man mplayer sur un p4-2200mhz

J'ai essayé de voir au niveau de doman pour tout convertir en utf-8 de façon définitive, mais j'ai l'impression qu'il n'est pas utilisé par tous les ebuilds !
Et puis ça nécessiterais un emerge -e world :'D


Last edited by GentooUser@Clubic on Thu Mar 15, 2007 4:38 pm; edited 1 time in total
Back to top
View user's profile Send private message
_kal_
l33t
l33t


Joined: 04 Mar 2005
Posts: 602
Location: Paris

PostPosted: Thu Mar 15, 2007 11:05 am    Post subject: Reply with quote

darkagonik wrote:
Merci pour l'ebuild :)
Mais est-ce normal que la page man de bash ne soit pas disponible en français ?

Code:
seb@localhost ~ $ man -aw bash
/usr/share/man/man1/bash.1.bz2


Je suppose que c'est la version 2.39 qui y est pour quelque chose, donc comment adapter ton ebuild pour que ce soit la version 1.64 qui soit installé (celle proposée par portage) ?

J'ai aussi essayé de faire un script (en reprenant le code de ton ebuild) pour convertir les pages man en latin9 (quand c'est l'ebuild 1.64 qui est installé) :
Code:
#!/bin/sh
for i in /usr/share/man/fr/man*/* ; do
        iconv -t iso-8859-15 $i -c -s > $i-latin9
        if [ $? -ne 0 ] ; then echo problem with $i ; fi
        mv $i-latin9 $i
done

Mais j'obtiens des erreurs :
Code:
[...]
problem with /usr/share/man/fr/man3/asinl.3.bz2
problem with /usr/share/man/fr/man3/asprintf.3.bz2
problem with /usr/share/man/fr/man3/assert.3.bz2
iconv: Caractère ou séquence de changement incomplet à la fin du tampon
problem with /usr/share/man/fr/man3/assert_perror.3.bz2
problem with /usr/share/man/fr/man3/atan2.3.bz2
problem with /usr/share/man/fr/man3/atan2f.3.bz2
problem with /usr/share/man/fr/man3/atan2l.3.bz2
problem with /usr/share/man/fr/man3/atan.3.bz2
problem with /usr/share/man/fr/man3/atanf.3.bz2
iconv: Caractère ou séquence de changement incomplet à la fin du tampon
problem with /usr/share/man/fr/man3/atanh.3.bz2
problem with /usr/share/man/fr/man3/atanhf.3.bz2
[...]


Voilà


C'est normal, tu essai d'appliquer iconv sur des fichiers compressé en bzip2. Essai ce script :
Code:
#!/bin/bash

declare -x is_bzip2=0
declare -x is_gzip=0
retour=0

for i in /usr/share/man/fr/man*/* ; do
    if [[ "$i" =~ '.*bz2$' ]] ; then
        is_bzip2=1
        is_gzip=0
        bunzip2 "$i"
        retour=$?
    elif [[ "$i" =~ '.*gz$' ]] ; then
        is_gzip=1
        is_bzip2=O
        gunzip "$i"
        retour=$?
    else
        # ce n'est pas une archive
        continue
    fi

    # si on a tenté de decompresser un lien symbolique
    if [ "$retour" != "0" ] ; then
        continue
    fi
   
    man=$(echo $i | sed -re 's/\.bz2|\.gz//g')
    # si c deja en iso-8859-15 alors on saute
    codage=$(file $man -ir | cut -d ';' -f2 | cut -d'=' -f2)
    if [ "$codage" != "iso*" ] ; then
        if [ $is_bzip2 -eq 1 ] ; then
            bzip2 $man
        else
            gzip $man
        fi
        continue
    fi

    iconv -t iso-8859-15 $man -c > $man-latin9
    if [ $? -ne 0 ] ; then echo problem with $man ; fi
    mv $man-latin9 $man
    if [ $is_bzip2 -eq 1 ] ; then
        bzip2 $man
    else
        gzip $man
    fi

done
Back to top
View user's profile Send private message
swilmet
n00b
n00b


Joined: 14 Mar 2007
Posts: 70
Location: Belgium

PostPosted: Thu Mar 15, 2007 5:54 pm    Post subject: Reply with quote

_kal_ wrote:

C'est normal, tu essai d'appliquer iconv sur des fichiers compressé en bzip2. Essai ce script :


J'ai essayé ton script, mais ça n'a pas marché, les accents ne s'affichaient toujours pas correctement.
Alors j'ai modifié ton ebuild pour que ce soit les pages en version 1.64 qui s'installent (sur ftp://ftp.win.tue.nl/pub/linux-local/manpages/translations/ il y a aussi la 1.69 mais qui ne contient pas bash). Je ne sais pas si c'est vraiment correct ce que je fais, mais au moins ça marche ! :) (j'ai rajouté des commentaires dans le code pour montrer les changements) :

man-pages-fr-1.64.0.ebuild
Code:
# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/app-i18n/man-pages-fr/man-pages-fr-1.64.0.ebuild,v 1.3 2006/06/21 17:25:19 vapier Exp $

# MY_P=${P} ne marche pas, donc j'ai repris la ligne de l'ebuild officiel
MY_P=${P/-pages/}
DESCRIPTION="A somewhat comprehensive collection of french Linux man pages"
HOMEPAGE="http://fr.tldp.org/manfr.php"
#SRC_URI="ftp://ftp.win.tue.nl/pub/linux-local/manpages/translations/${P}.tar.bz2"
# surement pas correct, de toute façon il prend le fichier sur un miroir spécifié dans GENTOO_MIRRORS
# (DISTDIR=/mnt/distfiles chez moi)
SRC_URI="/mnt/distfiles/${P}.tar.bz2"

LICENSE="freedist"
SLOT="0"
KEYWORDS="alpha amd64 arm hppa ia64 m68k mips ppc ppc64 s390 sh sparc x86"
IUSE="latin1"

RDEPEND="virtual/man"

S=${WORKDIR}/${MY_P}

src_unpack() {
    unpack ${A}
    echo "\$S = $S"
    echo "\$P = $P"
    echo "\$MY_P = ${MY_P}"
    cd "${S}"
}

src_compile() { :; }

src_install() {
    if use latin1 ; then
        for i in man*/* ; do
            iconv -t iso-8859-15 $i -c -s > $i-latin9
            if [ $? -ne 0 ] ; then echo problem with $i ; fi
            mv $i-latin9 $i
        done
    fi

    for x in man? ; do
        insinto /usr/share/man/fr/${x}
        doins ${x}/* || die "doins ${x}"
    done
}


C'est du chipotage quoi :roll:


Last edited by swilmet on Thu Mar 15, 2007 10:02 pm; edited 1 time in total
Back to top
View user's profile Send private message
_kal_
l33t
l33t


Joined: 04 Mar 2005
Posts: 602
Location: Paris

PostPosted: Thu Mar 15, 2007 9:18 pm    Post subject: Reply with quote

Héhé, c bizarre que ca n'ai pas marché mais bon passons, l'ebuild devrais résoudre ton problème :)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index French All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum