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

Re: Bug#120432: marked as done (www.d.o/Bugs: Additional settings missing in German translation)



On Wed, Nov 21, 2001 at 03:43:47PM +0100, Josip Rodin wrote:
> On Wed, Nov 21, 2001 at 02:23:25PM +0100, Denis Barbier wrote:
> > Not really, all slices should be there untranslated. Does someone write
> > a script to update missing slices in such files?
> 
> Perhaps it would be more useful if wml had a mode where it barfed about
> missing tags.

Here is some material. It will only work when there is no newline embedded
in translated text.

The idea is very similar to the one used for countries: generate a template
from language_names.wml, which is read by this file.  Because of this loop,
special care must be taken to ensure that file is generated before used.
A target has been inserted into Makefile.common, but IIRC previous similar
change with countries.wml did break nm.debian.org, so the 3language_names.def
script could be put on klecker under /org/www.debian.org/cron/daily_updates
to avoid such problems.

After applying patch and creating language_names.def, the game can start.
When you want to test this feature, simply add
   #use wml::debian::language_names
at top of file, and s/define-tag/define-tag-sliced/g
It seems to work quite well with english/Bugs/pkgreport-opts.inc, but please
test before making intensive use of this toy.  In particular, Chinese variants
may cause trouble.

Denis
#!/bin/sh -e

# This script generates english/template/debian/language_names.def
# from english/template/debian/language_names.wml

. `dirname $0`/../common.sh

cd $webtopdir/english/template/debian && make -f - <<EOT
language_names.def: language_names.wml
	sed -e '/^#/d' -e '/<\/*protect/d' language_names.wml | eperl -B '<perl>' -E '</perl>' - >/dev/null
EOT
Index: Makefile.common
===================================================================
RCS file: /cvs/webwml/webwml/Makefile.common,v
retrieving revision 1.47
diff -u -r1.47 Makefile.common
--- Makefile.common	2001/09/29 13:16:15	1.47
+++ Makefile.common	2001/11/23 01:07:50
@@ -115,7 +115,7 @@
 
 $(TEMPLDIR)/basic.wml: $(TEMPLDIR)/navbar.wml
 $(TEMPLDIR)/footer.wml: $(TEMPLDIR)/ctime.wml
-$(TEMPLDIR)/languages.wml: $(TEMPLDIR)/language_names.wml
+$(TEMPLDIR)/languages.wml: $(TEMPLDIR)/language_names.wml $(TEMPLDIR)/language_names.def
 $(TEMPLDIR)/mainpage.wml: $(TEMPLDIR)/basic.wml $(TEMPLDIR)/mirrors.wml \
   $(TEMPLDIR)/languages.wml $(TEMPLDIR)/footer.wml $(TEMPLDIR)/links.tags.wml \
   $(ENGLISHSRCDIR)/Pics/blue-upperleft.png $(ENGLISHSRCDIR)/Pics/blue-upperright.png \
@@ -171,6 +171,9 @@
 
 $(TEMPLDIR)/countries.def: $(TEMPLDIR)/countries.wml
 	cd $(TEMPLDIR) && sed -e /^#/d countries.wml | eperl -B '<:' -E ':>' - >/dev/null
+
+$(TEMPLDIR)/language_names.def: $(TEMPLDIR)/language_names.wml
+	cd $(TEMPLDIR) && sed -e '/^#/d' -e '/<\/*protect/d' language_names.wml | eperl -B '<perl>' -E '</perl>' - >/dev/null
 
 
 .SUFFIXES: 
Index: english/template/debian/language_names.wml
===================================================================
RCS file: /cvs/webwml/webwml/english/template/debian/language_names.wml,v
retrieving revision 1.169
diff -u -r1.169 language_names.wml
--- english/template/debian/language_names.wml	2001/11/15 21:29:38	1.169
+++ english/template/debian/language_names.wml	2001/11/23 01:07:50
@@ -1,5 +1,10 @@
 #use wml::std::tags
 
+#   The following module is generated from this script, see explanations
+#   at end of file
+#use def::debian::language_names
+
+
 # Add a new entry for your language. Also add the english name for your
 # country to the existing entries. Use the same word for the translation
 # and make a request on debian-www for people to add the translations
@@ -1275,4 +1280,34 @@
 		vietnamese	=> "Vietnamese",
 	},
 );
+
+#     These lines generate the language_names.def file, only when this file
+#     is processed through
+#         sed -e '/^#/d' -e '/<\/*protect/d' language_names.wml | eperl -B '<perl>' -E '</perl>' - >/dev/null
+#     WML will skip this block
+if ('$(DUMMY_VAR_DO_NOT_REMOVE)' ne '') {
+    open(GEN, "> language_names.def");
+    print GEN "#   File generated automatically.  Do not edit!\n";
+    print GEN "<"."set-var _webwml_langs_=\"\\";
+    foreach my $c (sort keys %trans) {
+        print GEN "\n".uc($c);
+    }
+    print GEN "\">\n\n";
+<protect pass=2>
+    print GEN << 'EOT';
+<define-tag define-tag-sliced endtag=required whitespace=delete>
+<preserve default>
+<set-var default=<subst-in-string %body
+        ".*\\[EN:([^\\n]*):\\].*" "\\1" singleline=true>>
+<subst-in-string "=LT=define-tag %0>
+<foreach _webwml_lang_ _webwml_langs_>
+<or <match %body "\[<get-var _webwml_lang_>:[^\\n]*:\\]" action=extract>
+    "[<get-var _webwml_lang_>:<get-var default>:]">
+</foreach>
+=LT=/define-tag>" "=LT=" "<">
+<restore default>
+</define-tag>
+EOT
+</protect>
+}
 </perl>

Reply to: