[vlc-devel] [PATCH] Translate Kate category tags to display a more user friendly subtitles selection menu
Laurent Aimar
fenrir at via.ecp.fr
Sun Feb 1 19:06:39 CET 2009
Hi,
On Sun, Feb 01, 2009, ogg.k.ogg.k at googlemail.com wrote:
> In the Ogg demuxer only, as the mkv one doesn't seem to use
> the category at the moment, but the table and code are in a
> separate file so it's ready to be reused.
> So you'll get something like 'Sous-titres [Français]' in the
> subtitles menu.
I think that categories.* should be changed to kate.* as they are
kate specific.
> diff --git a/modules/demux/categories.c b/modules/demux/categories.c
> new file mode 100644
> index 0000000..b6eb2fb
> --- /dev/null
> +++ b/modules/demux/categories.c
> @@ -0,0 +1,75 @@
> +/*****************************************************************************
> + * categories.c : maps well known category tags to translated strings.
> + *****************************************************************************
> + * Copyright (C) 2009 ogg.k.ogg.k at googlemail.com
> + * $Id$
> + *
> + * Authors: ogg.k.ogg.k at googlemail.com
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program 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 General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
> + *****************************************************************************/
> +
> +/*****************************************************************************
> + * Preamble
> + *****************************************************************************/
> +#ifdef HAVE_CONFIG_H
> +# include "config.h"
> +#endif
> +
> +#include <stddef.h>
What is it used for ?
> diff --git a/modules/demux/categories.h b/modules/demux/categories.h
> new file mode 100644
> index 0000000..d7cd1d2
> --- /dev/null
> +++ b/modules/demux/categories.h
> @@ -0,0 +1,30 @@
> +/*****************************************************************************
> + * categories.h : maps well known category tags to translated strings.
> + *****************************************************************************
> + * Copyright (C) 2009 ogg.k.ogg.k at googlemail.com
> + * $Id$
> + *
> + * Authors: ogg.k.ogg.k at googlemail.com
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program 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 General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
> + *****************************************************************************/
> +
> +#ifndef CATEGORIES_H_
You can keep it, but is useless here as there is no risk to include it
multiple times.
> +#define CATEGORIES_H_
We are used to define such ones as 1 (if you keep it).
> +extern const char *FindKateCategoryName( const char *psz_tag );
extern is useless for a function.
> diff --git a/modules/demux/ogg.c b/modules/demux/ogg.c
> index 577934c..b2a87b8 100644
> --- a/modules/demux/ogg.c
> +++ b/modules/demux/ogg.c
> @@ -41,6 +41,7 @@
> #include <vlc_bits.h>
> #include <vlc_charset.h>
> #include "vorbis.h"
> +#include "categories.h"
>
> /*****************************************************************************
> * Module descriptor
> @@ -1696,6 +1697,7 @@ static void Ogg_ReadKateHeader( logical_stream_t *p_stream,
> int32_t gnum;
> int32_t gden;
> int n;
> + char *psz_desc;
You probably need const.
>
> p_stream->fmt.i_cat = SPU_ES;
> p_stream->fmt.i_codec = VLC_FOURCC( 'k','a','t','e' );
> @@ -1734,6 +1736,14 @@ static void Ogg_ReadKateHeader( logical_stream_t *p_stream,
> for( n = 0; n < 16; ++n )
Just for consistency in this file, could you use n++ ?
> p_stream->fmt.psz_description[n] = oggpack_read(&opb,8);
> p_stream->fmt.psz_description[15] = 0; /* just in case */
> +
> + /* Now find a localized user readable description for this category */
> + psz_desc = strdup(FindKateCategoryName(p_stream->fmt.psz_description));
> + if( psz_desc )
> + {
> + free( p_stream->fmt.psz_description );
> + p_stream->fmt.psz_description = psz_desc;
> + }
> }
> else
> {
--
fenrir
More information about the vlc-devel
mailing list