[vlc-devel] commit: Translate Kate category tags to display a more user friendly menu. (ogg.k.ogg.k )
git version control
git at videolan.org
Mon Feb 2 21:00:02 CET 2009
vlc | branch: master | ogg.k.ogg.k <ogg.k.ogg.k at googlemail.com> | Sun Feb 1 13:28:38 2009 +0000| [8abaa1b2536c844e926981290ab6b3f156af0ad7] | committer: Laurent Aimar
Translate Kate category tags to display a more user friendly menu.
Signed-off-by: Laurent Aimar <fenrir at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8abaa1b2536c844e926981290ab6b3f156af0ad7
---
modules/demux/Modules.am | 2 +-
modules/demux/kate_categories.c | 76 +++++++++++++++++++++++++++++++++++++++
modules/demux/kate_categories.h | 30 +++++++++++++++
modules/demux/ogg.c | 18 +++++++--
4 files changed, 121 insertions(+), 5 deletions(-)
diff --git a/modules/demux/Modules.am b/modules/demux/Modules.am
index 350f320..97c6d04 100644
--- a/modules/demux/Modules.am
+++ b/modules/demux/Modules.am
@@ -1,6 +1,6 @@
SUBDIRS = asf avformat avi mkv mp4 mpeg playlist
SOURCES_flacsys = flac.c
-SOURCES_ogg = ogg.c vorbis.h
+SOURCES_ogg = ogg.c vorbis.h kate_categories.c kate_categories.h
SOURCES_demuxdump = demuxdump.c
SOURCES_rawdv = rawdv.c
SOURCES_rawvid = rawvid.c
diff --git a/modules/demux/kate_categories.c b/modules/demux/kate_categories.c
new file mode 100644
index 0000000..bfe98d4
--- /dev/null
+++ b/modules/demux/kate_categories.c
@@ -0,0 +1,76 @@
+/*****************************************************************************
+ * kate_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>
+#include <string.h>
+#include "kate_categories.h"
+
+static const struct {
+ const char *psz_tag;
+ const char *psz_i18n;
+} Katei18nCategories[] = {
+ /* From Silvia's Mozilla list */
+ { "CC", N_("Closed captions") },
+ { "SUB", N_("Subtitles") },
+ { "TAD", N_("Textual audio descriptions") },
+ { "KTV", N_("Karaoke") },
+ { "TIK", N_("Ticker text") },
+ { "AR", N_("Active regions") },
+ { "NB", N_("Semantic annotations") },
+ { "META", N_("Metadata") },
+ { "TRX", N_("Transcript") },
+ { "LRC", N_("Lyrics") },
+ { "LIN", N_("Linguistic markup") },
+ { "CUE", N_("Cue points") },
+
+ /* Grandfathered */
+ { "subtitles", N_("Subtitles") },
+ { "spu-subtitles", N_("Subtitles (images)") },
+ { "lyrics", N_("Lyrics") },
+
+ /* Kate specific */
+ { "K-SPU", N_("Subtitles (images)") },
+ { "K-SLD-T", N_("Slides (text)") },
+ { "K-SLD-I", N_("Slides (images)") },
+};
+
+const char *FindKateCategoryName( const char *psz_tag )
+{
+ size_t i;
+
+ for( i = 0; i < sizeof(Katei18nCategories)/sizeof(Katei18nCategories[0]); i++ )
+ {
+ if( !strcmp( psz_tag, Katei18nCategories[i].psz_tag ) )
+ return Katei18nCategories[i].psz_i18n;
+ }
+ return N_("Unknown category");
+}
+
+
diff --git a/modules/demux/kate_categories.h b/modules/demux/kate_categories.h
new file mode 100644
index 0000000..f3118df
--- /dev/null
+++ b/modules/demux/kate_categories.h
@@ -0,0 +1,30 @@
+/*****************************************************************************
+ * kate_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 KATE_CATEGORIES_H_
+#define KATE_CATEGORIES_H_ 1
+
+const char *FindKateCategoryName( const char *psz_tag );
+
+#endif
+
diff --git a/modules/demux/ogg.c b/modules/demux/ogg.c
index 577934c..568278f 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 "kate_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;
p_stream->fmt.i_cat = SPU_ES;
p_stream->fmt.i_codec = VLC_FOURCC( 'k','a','t','e' );
@@ -1719,25 +1721,33 @@ static void Ogg_ReadKateHeader( logical_stream_t *p_stream,
p_stream->fmt.psz_language = malloc(16);
if( p_stream->fmt.psz_language )
{
- for( n = 0; n < 16; ++n )
+ for( n = 0; n < 16; n++ )
p_stream->fmt.psz_language[n] = oggpack_read(&opb,8);
p_stream->fmt.psz_language[15] = 0; /* just in case */
}
else
{
- for( n = 0; n < 16; ++n )
+ for( n = 0; n < 16; n++ )
oggpack_read(&opb,8);
}
p_stream->fmt.psz_description = malloc(16);
if( p_stream->fmt.psz_description )
{
- for( n = 0; n < 16; ++n )
+ for( n = 0; n < 16; 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
{
- for( n = 0; n < 16; ++n )
+ for( n = 0; n < 16; n++ )
oggpack_read(&opb,8);
}
}
More information about the vlc-devel
mailing list