Translation assessment tool (part 2)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Changelog:
Script and program to interpret what wrc dumps and issue an html file
with the translation status of each language.

Vincent
Index: tools/.cvsignore
===================================================================
RCS file: /home/wine/wine/tools/.cvsignore,v
retrieving revision 1.9
diff -u -r1.9 .cvsignore
--- tools/.cvsignore	11 Sep 2003 21:27:58 -0000	1.9
+++ tools/.cvsignore	17 Jan 2004 04:26:06 -0000
@@ -2,3 +2,5 @@
 bin2res
 fnt2bdf
 makedep
+trans
+trans_html
Index: tools/Makefile.in
===================================================================
RCS file: /home/wine/wine/tools/Makefile.in,v
retrieving revision 1.37
diff -u -r1.37 Makefile.in
--- tools/Makefile.in	20 Nov 2003 22:02:15 -0000	1.37
+++ tools/Makefile.in	17 Jan 2004 04:26:06 -0000
@@ -8,12 +8,14 @@
 PROGRAMS = \
 	bin2res \
 	fnt2bdf \
-	makedep
+	makedep \
+	trans
 
 C_SRCS = \
 	bin2res.c \
 	fnt2bdf.c \
-	makedep.c
+	makedep.c \
+	trans.c
 
 SUBDIRS = \
 	widl \
@@ -40,6 +42,9 @@
 bin2res: bin2res.o
 	$(CC) $(CFLAGS) -o bin2res bin2res.o $(LIBPORT)
 
+trans: trans.o
+	$(CC) $(CFLAGS) -o trans trans.o
+
 install::
 	$(MKINSTALLDIRS) $(bindir) $(mandir)/man$(prog_manext)
 	$(INSTALL_SCRIPT) $(SRCDIR)/winemaker $(bindir)/winemaker
@@ -47,5 +52,8 @@
 
 uninstall::
 	$(RM) $(bindir)/winemaker $(mandir)/man$(prog_manext)/winemaker.$(prog_manext)
+
+clean::
+	$(RM) -r trans_html
 
 ### Dependencies:
diff -u /dev/null tools/trans.c
--- /dev/null	2002-08-30 19:31:37.000000000 -0400
+++ tools/trans.c	2004-01-16 23:28:24.000000000 -0500
@@ -0,0 +1,311 @@
+/*
+ * Copyright 2003-2004 Vincent Béron
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "windef.h"
+
+#define NB_RES_TYPE 21
+#define NB_LANG 0x94
+
+static const char *res_types[] = {
+"cursor",
+"bitmap",
+"icon",
+"menu",
+"dialog",
+"stringtable",
+"fontdir",
+"font",
+"accelerator",
+"rcdata",
+"messagetable",
+"cursor_group",
+"icon_group",
+"versioninfo",
+"ani_cursor",
+"ani_icon",
+"dlginit",
+"toolbar",
+"menuex",
+"dialogex",
+"user"
+};
+
+#define PRETTYPRINTLANG(langid) \
+	if(LANG_##langid == lid) { \
+		return #langid; \
+	}
+
+static const char *get_language_name(int lid) {
+	PRETTYPRINTLANG(NEUTRAL)
+	PRETTYPRINTLANG(AFRIKAANS)
+	PRETTYPRINTLANG(ALBANIAN)
+	PRETTYPRINTLANG(ARABIC)
+	PRETTYPRINTLANG(ARMENIAN)
+	PRETTYPRINTLANG(ASSAMESE)
+	PRETTYPRINTLANG(AZERI)
+	PRETTYPRINTLANG(BASQUE)
+	PRETTYPRINTLANG(BELARUSIAN)
+	PRETTYPRINTLANG(BENGALI)
+	PRETTYPRINTLANG(BULGARIAN)
+	PRETTYPRINTLANG(CATALAN)
+	PRETTYPRINTLANG(CHINESE)
+	PRETTYPRINTLANG(CROATIAN)
+	PRETTYPRINTLANG(CZECH)
+	PRETTYPRINTLANG(DANISH)
+	PRETTYPRINTLANG(DIVEHI)
+	PRETTYPRINTLANG(DUTCH)
+	PRETTYPRINTLANG(ENGLISH)
+	PRETTYPRINTLANG(ESTONIAN)
+	PRETTYPRINTLANG(FAEROESE)
+	PRETTYPRINTLANG(FARSI)
+	PRETTYPRINTLANG(FINNISH)
+	PRETTYPRINTLANG(FRENCH)
+	PRETTYPRINTLANG(GALICIAN)
+	PRETTYPRINTLANG(GEORGIAN)
+	PRETTYPRINTLANG(GERMAN)
+	PRETTYPRINTLANG(GREEK)
+	PRETTYPRINTLANG(GUJARATI)
+	PRETTYPRINTLANG(HEBREW)
+	PRETTYPRINTLANG(HINDI)
+	PRETTYPRINTLANG(HUNGARIAN)
+	PRETTYPRINTLANG(ICELANDIC)
+	PRETTYPRINTLANG(INDONESIAN)
+	PRETTYPRINTLANG(ITALIAN)
+	PRETTYPRINTLANG(JAPANESE)
+	PRETTYPRINTLANG(KANNADA)
+	PRETTYPRINTLANG(KASHMIRI)
+	PRETTYPRINTLANG(KAZAK)
+	PRETTYPRINTLANG(KONKANI)
+	PRETTYPRINTLANG(KOREAN)
+	PRETTYPRINTLANG(KYRGYZ)
+	PRETTYPRINTLANG(LATVIAN)
+	PRETTYPRINTLANG(LITHUANIAN)
+	PRETTYPRINTLANG(MACEDONIAN)
+	PRETTYPRINTLANG(MALAY)
+	PRETTYPRINTLANG(MALAYALAM)
+	PRETTYPRINTLANG(MANIPURI)
+	PRETTYPRINTLANG(MARATHI)
+	PRETTYPRINTLANG(MONGOLIAN)
+	PRETTYPRINTLANG(NEPALI)
+	PRETTYPRINTLANG(NORWEGIAN)
+	PRETTYPRINTLANG(ORIYA)
+	PRETTYPRINTLANG(POLISH)
+	PRETTYPRINTLANG(PORTUGUESE)
+	PRETTYPRINTLANG(PUNJABI)
+	PRETTYPRINTLANG(ROMANIAN)
+	PRETTYPRINTLANG(RUSSIAN)
+	PRETTYPRINTLANG(SANSKRIT)
+	PRETTYPRINTLANG(SERBIAN)
+	PRETTYPRINTLANG(SINDHI)
+	PRETTYPRINTLANG(SLOVAK)
+	PRETTYPRINTLANG(SLOVENIAN)
+	PRETTYPRINTLANG(SPANISH)
+	PRETTYPRINTLANG(SWAHILI)
+	PRETTYPRINTLANG(SWEDISH)
+	PRETTYPRINTLANG(SYRIAC)
+	PRETTYPRINTLANG(TAMIL)
+	PRETTYPRINTLANG(TATAR)
+	PRETTYPRINTLANG(TELUGU)
+	PRETTYPRINTLANG(THAI)
+	PRETTYPRINTLANG(TURKISH)
+	PRETTYPRINTLANG(UKRAINIAN)
+	PRETTYPRINTLANG(URDU)
+	PRETTYPRINTLANG(UZBEK)
+	PRETTYPRINTLANG(VIETNAMESE)
+	PRETTYPRINTLANG(GAELIC)
+	PRETTYPRINTLANG(MALTESE)
+	PRETTYPRINTLANG(MAORI)
+	PRETTYPRINTLANG(RHAETO_ROMANCE)
+	PRETTYPRINTLANG(SAAMI)
+	PRETTYPRINTLANG(SORBIAN)
+	PRETTYPRINTLANG(SUTU)
+	PRETTYPRINTLANG(TSONGA)
+	PRETTYPRINTLANG(TSWANA)
+	PRETTYPRINTLANG(VENDA)
+	PRETTYPRINTLANG(XHOSA)
+	PRETTYPRINTLANG(ZULU)
+	PRETTYPRINTLANG(ESPERANTO)
+	PRETTYPRINTLANG(WALON)
+	PRETTYPRINTLANG(CORNISH)
+	PRETTYPRINTLANG(WELSH)
+	PRETTYPRINTLANG(BRETON)
+	return "Unknown language";
+}
+
+int main(int argc, char *argv[]) {
+	char *p;
+	char filename_general[256], filename_res[256];
+	FILE *output_general, *output_res;
+	int i, j, k;
+	int nb_lang_relevant = 0;
+	int lang_relevant[NB_LANG];
+	int nb_files = 0;
+	struct afile {
+		char filename_orig[256];
+		char line[NB_RES_TYPE][NB_LANG+2];
+		char **problems[NB_RES_TYPE][NB_LANG];
+		int nb_problems[NB_LANG];
+		int file_relevant;
+		int lang_relevant[NB_LANG];
+		int res_relevant[NB_RES_TYPE];
+	} *files;
+	int langid;
+	char temp[256];
+	char filename[256];
+
+	p = strrchr(argv[0], '/');
+	*p = '\0';
+
+	sprintf(filename_general, "%s/trans_html/index.html", argv[0]);
+	output_general = fopen(filename_general, "wt");
+	fprintf(output_general, "<html>\n<head>\n</head>\n<body>\n");
+	fprintf(output_general, "  <table border>\n");
+
+	for(j = 0; j < NB_LANG; j++) {
+		lang_relevant[j] = 0;
+	}
+
+	files = malloc((nb_files+1)*sizeof(struct afile));
+	while(fgets(files[nb_files].filename_orig, 256, stdin)) {
+		for(i = 0; i < NB_RES_TYPE; i++) {
+			fgets(files[nb_files].line[i], NB_LANG+2, stdin);
+			for(j = 0; j < NB_LANG; j++) {
+				files[nb_files].problems[i][j] = malloc(sizeof(char *));
+				files[nb_files].problems[i][j][0] = NULL;
+				files[nb_files].nb_problems[j] = 0;
+			}
+			for(j = 0; j < NB_LANG; j++) {
+				if('x' == files[nb_files].line[i][j] || '-' == files[nb_files].line[i][j] || '+' == files[nb_files].line[i][j] || ' ' == files[nb_files].line[i][j]) {
+					do {
+						fgets(temp, 256, stdin);
+						p = strchr(temp, '\\');
+						if(p) {
+							p--;
+							*p = '\0';
+							p -= 2;
+							langid = strtol(p, NULL, 16);
+							*p = '\0';
+						} else {
+							p = strchr(temp, '\0') - 3;
+							langid = strtol(p, NULL, 16);
+							*p = '\0';
+							p = NULL;
+						}
+						files[nb_files].problems[i][langid][files[nb_files].nb_problems[langid]++] = strdup(temp);
+						files[nb_files].problems[i][langid] = realloc(files[nb_files].problems[i][langid], (files[nb_files].nb_problems[langid]+1)*sizeof(char *));
+						files[nb_files].problems[i][langid][files[nb_files].nb_problems[langid]] = NULL;
+					} while (p);
+				}
+			}
+		}
+
+		files[nb_files].file_relevant = 0;
+		for(j = 0; j < NB_LANG; j++) {
+			files[nb_files].lang_relevant[j] = 0;
+			for(i = 0; i < NB_RES_TYPE; i++) {
+				if(' ' != files[nb_files].line[i][j] && 'n' != files[nb_files].line[i][j]) {
+					files[nb_files].lang_relevant[j] = 1;
+					if(!lang_relevant[j]) {
+						lang_relevant[j] = 1;
+						nb_lang_relevant++;
+					}
+				}
+			}
+			if(files[nb_files].lang_relevant[j]) {
+				if(!files[nb_files].file_relevant) {
+					files[nb_files].file_relevant = 1;
+				}
+			}
+		}
+
+		nb_files++;
+		files = realloc(files, (nb_files+1)*sizeof(struct afile));
+	}
+
+	for(k = 0; k < nb_files; k++) {
+		if(files[k].file_relevant) {
+			fprintf(output_general, "    <tr>\n      <td colspan=%d><b>%s</b></td>\n    </tr>\n    <tr>\n      <td></td>\n", nb_lang_relevant+1, files[k].filename_orig);
+			for(j = 0; j < NB_LANG; j++) {
+				if(lang_relevant[j]) {
+					fprintf(output_general, "      <td>%s</td>\n", get_language_name(j));
+				}
+			}
+			fprintf(output_general, "    </tr>\n");
+		}
+
+		strcpy(filename, files[k].filename_orig);
+		p = filename;
+		while((p = strchr(p, '/')))
+			*p = '.';
+		p = strchr(filename, '\0') - 1;
+		*p = '\0';
+		for(i = 0; i < NB_RES_TYPE; i++) {
+			files[k].res_relevant[i] = 0;
+			for(j = 0; j < NB_LANG; j++) {
+				if('.' == files[k].line[i][j] || 'x' == files[k].line[i][j] || '-' == files[k].line[i][j] || '+' == files[k].line[i][j]) {
+					files[k].res_relevant[i] = 1;
+				}
+			}
+			if(files[k].res_relevant[i]) {
+				fprintf(output_general, "    <tr>\n      <td>%s</td>\n", res_types[i]);
+				for(j = 0; j < NB_LANG; j++) {
+					if(lang_relevant[j]) {
+						if('.' == files[k].line[i][j]) {
+							fprintf(output_general, "      <td bgcolor=\"green\">complete</td>\n");
+						} else if('x' == files[k].line[i][j]) {
+							fprintf(output_general, "      <td bgcolor=\"red\"><a href=\"details/%s.%s.%s.html\">mismatch</a></td>\n", filename, res_types[i], get_language_name(j));
+						} else if('-' == files[k].line[i][j]) {
+							fprintf(output_general, "      <td bgcolor=\"orange\"><a href=\"details/%s.%s.%s.html\">incomplete</a></td>\n", filename, res_types[i], get_language_name(j));
+						} else if('+' == files[k].line[i][j]) {
+							fprintf(output_general, "      <td bgcolor=\"red\"><a href=\"details/%s.%s.%s.html\">mismatch+incomplete</a></td>\n", filename, res_types[i], get_language_name(j));
+						} else if(' ' == files[k].line[i][j]) {
+							fprintf(output_general, "      <td bgcolor=\"yellow\">nothing</td>\n");
+						}
+						if('.' != files[k].line[i][j] && ' ' != files[k].line[i][j]) {
+							sprintf(filename_res, "%s/trans_html/details/%s.%s.%s.html", argv[0], filename, res_types[i], get_language_name(j));
+							output_res = fopen(filename_res, "wt");
+							fprintf(output_res, "<html>\n<head>\n</head>\n<body>\n");
+							if('x' == files[k].line[i][j]) {
+								fprintf(output_res, "Some resources are different from what they should be.");
+							} else if('+' == files[k].line[i][j]) {
+								fprintf(output_res, "Some resources are missing, and some others are different from what they should be.");
+							} else if('-' == files[k].line[i][j]) {
+								fprintf(output_res, "Some resources are missing.");
+							}							files[k].nb_problems[j] = 0;
+							while(files[k].problems[i][j][files[k].nb_problems[j]]) {
+								fprintf(output_res, "<br>\n%s", files[k].problems[i][j][files[k].nb_problems[j]++]);
+							}
+							fprintf(output_res, "\n</body>\n</html>\n");
+							fclose(output_res);
+						}
+					}
+				}
+				fprintf(output_general, "    </tr>\n");
+			}
+		}
+	}
+
+	fprintf(output_general, "  </table>\n</body>\n</html>\n");
+	fclose(output_general);
+
+	exit(0);
+	return 0;
+}
diff -u /dev/null tools/trans.sh
--- /dev/null	2002-08-30 19:31:37.000000000 -0400
+++ tools/trans.sh	2004-01-16 23:39:27.000000000 -0500
@@ -0,0 +1,133 @@
+#!/bin/sh
+#
+# Script to build a map of which translations are up-to-date
+# and/or complete
+#
+# Copyright 2003-2004 Vincent Béron
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+BASEDIR=`dirname $0`
+if [ ! -d ${BASEDIR}/trans_html ]; then
+	mkdir ${BASEDIR}/trans_html
+fi
+if [ ! -d ${BASEDIR}/trans_html/details ]; then
+	mkdir ${BASEDIR}/trans_html/details
+fi
+rm ${BASEDIR}/trans_html/details/*.html >/dev/null 2>&1
+rm ${BASEDIR}/trans_html/index.html >/dev/null 2>&1
+
+for MAKEFILE in `find . -name 'Makefile'`; do
+	DIRECTORY="`dirname "${MAKEFILE}"`"
+	pushd "${DIRECTORY}" >/dev/null
+	MAKEFILECONTENTS="`sed -e '/^[[:space:]]/s/^[[:space:]]*\([^[:space:]]\)/ \1/' Makefile`"
+	RC_BINSRC="`echo "${MAKEFILECONTENTS}" |\
+		grep '^RC_BINSRC[[:space:]]*=.*$' |\
+		sed -e 's/^RC_BINSRC[[:space:]]*=[[:space:]]*//'`"
+	RC_BINARIES="`echo "${MAKEFILECONTENTS}" |\
+		sed -e '/^RC_BINARIES[[:space:]]*=[[:space:]]*/s/^RC_BINARIES[[:space:]]*=[[:space:]]*\([^[:space:]]*\)/RC_BINARIES=\1/' |\
+		sed -e '/^RC_BINARIES=.*$/ {
+			:join
+			N
+			s/[[:space:]]*\\\\\n//
+			t join
+			b next
+			}
+			:next' |\
+		grep '^RC_BINARIES=.*$' |\
+		sed -e 's/^RC_BINARIES=[[:space:]]*//'`"
+	RC_SRCS="`echo "${MAKEFILECONTENTS}" |\
+		sed -e '/^RC_SRCS[[:space:]]*=[[:space:]]*/s/^RC_SRCS[[:space:]]*=[[:space:]]*\([^[:space:]]*\)/RC_SRCS=\1/' |\
+		sed -e '/^RC_SRCS=.*$/ {
+			:join
+			N
+			s/[[:space:]]*\\\\\n//
+			t join
+			b next
+			}
+			:next' |\
+		grep '^RC_SRCS=.*$' |\
+		sed -e 's/^RC_SRCS=[[:space:]]*//'`"
+	RC_SRCS16="`echo "${MAKEFILECONTENTS}" |\
+		sed -e '/^RC_SRCS16[[:space:]]*=[[:space:]]*/s/^RC_SRCS16[[:space:]]*=[[:space:]]*\([^[:space:]]*\)/RC_SRCS16=\1/' |\
+		sed -e '/^RC_SRCS16=.*$/ {
+			:join
+			N
+			s/[[:space:]]*\\\\\n//
+			t join
+			b next
+			}
+			:next' |\
+		grep '^RC_SRCS16=.*$' |\
+		sed -e 's/^RC_SRCS16=[[:space:]]*//'`"
+	MC_SRCS="`echo "${MAKEFILECONTENTS}" |\
+		sed -e '/^MC_SRCS[[:space:]]*=[[:space:]]*/s/^MC_SRCS[[:space:]]*=[[:space:]]*\([^[:space:]]*\)/MC_SRCS=\1/' |\
+		sed -e '/^MC_SRCS=.*$/ {
+			:join
+			N
+			s/[[:space:]]*\\\\\n//
+			t join
+			b next
+			}
+			:next' |\
+		grep '^MC_SRCS=.*$' |\
+		sed -e 's/^MC_SRCS=[[:space:]]*//'`"
+	TOPSRCDIR="`echo "${MAKEFILECONTENTS}" |\
+		grep '^TOPSRCDIR[[:space:]]*=.*$' |\
+		sed -e 's/^TOPSRCDIR[[:space:]]*=[[:space:]]*//'`"
+	TOPOBJDIR="`echo "${MAKEFILECONTENTS}" |\
+		grep '^TOPOBJDIR[[:space:]]*=.*$' |\
+		sed -e 's/^TOPOBJDIR[[:space:]]*=[[:space:]]*//'`"
+	SRCDIR="`echo "${MAKEFILECONTENTS}" |\
+		grep '^SRCDIR[[:space:]]*=.*$' |\
+		sed -e 's/^SRCDIR[[:space:]]*=[[:space:]]*//'`"
+	EXTRARCFLAGS="`echo "${MAKEFILECONTENTS}" |\
+		grep '^EXTRARCFLAGS[[:space:]]*=.*$' |\
+		sed -e 's/^EXTRARCFLAGS[[:space:]]*=[[:space:]]*//'`"
+	INCLUDES="-I${SRCDIR} -I. -I${TOPSRCDIR}/include -I${TOPOBJDIR}/include"
+	LDPATH="${TOPOBJDIR}/libs/unicode:${LD_LIBRARY_PATH}"
+	WRC="${TOPOBJDIR}/tools/wrc/wrc"
+	BIN2RES="${TOPOBJDIR}/tools/bin2res"
+	WMC="${TOPOBJDIR}/tools/wmc/wmc"
+	TRANS="${TOPOBJDIR}/tools/trans"
+	RC="${WRC}"
+	RC16="${WRC}"
+	RCFLAGS="--nostdinc ${INCLUDES} --debug=0x40 ${EXTRARCFLAGS}"
+	RC16FLAGS="-O res16 ${RCFLAGS}"
+	if [ -n "${MC_SRCS}" ]; then
+		for MCFILE in ${MC_SRCS}; do
+			LD_LIBRARY_PATH="${LDPATH}" ${WMC} -i -U -H /dev/null -o ${MCFILE}.rc ${MCFILE}
+		done
+	fi
+	if [ -n "${RC_BINARIES}" ]; then
+		for RCFILE in ${RC_BINARIES}; do
+			${BIN2RES} -f -o ${RCFILE} ${SRCDIR}/${RC_BINSRC}
+		done
+	fi
+	if [ -n "${RC_SRCS}" ]; then
+		for RCFILE in ${RC_SRCS}; do
+			FILE="${DIRECTORY}/${RCFILE}"
+			(echo "${FILE#./}" && LD_LIBRARY_PATH="${LDPATH}" ${RC} ${RCFLAGS} -fo${RCFILE%.rc}.res ${RCFILE})
+		done
+	fi
+	if [ -n "${RC16_SRCS}" ]; then
+		for RCFILE in ${RC16_SRCS}; do
+			FILE="${DIRECTORY}/${RCFILE}"
+			(echo "${FILE#./}" && LD_LIBRARY_PATH="${LDPATH}" ${RC16} ${RC16FLAGS} -fo${RCFILE%.rc}.res ${RCFILE})
+		done
+	fi
+	popd >/dev/null
+#done >"${BASEDIR}/trans_html/tout"
+done |"${BASEDIR}/trans"

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux