Version 3.6.0.2, tag libreoffice-3.6.0.2
[LibreOffice.git] / i18npool / source / localedata / data / list-locales.awk
blob9921e7f92c88e94f2249521c444d1a5358956f39
1 #!/usr/bin/gawk -f
2 #// Usage: gawk -f list-locales.awk *.xml
3 #// Simply create a verbose list of known locales as stated in XML files.
4 #// Author: Eike Rathke <erack@sun.com>
6 BEGIN {
7 file = ""
8 count = 0
11 function init_locale() {
12 lcinfo = 0
13 inlang = 0
14 incoun = 0
15 language = ""
16 country = ""
19 FILENAME != file {
20 printEntry()
21 file = FILENAME
22 ++count
23 init_locale()
27 if ( !lcinfo )
29 if ( /<LC_INFO>/ )
30 lcinfo = 1
31 next
33 if ( /<\/LC_INFO>/ )
35 lcinfo = 0
36 next
38 if ( /<Language>/ )
39 inlang = 1
40 if ( inlang && /<DefaultName>/ )
42 split( $0, x, /<|>/ )
43 language = x[3]
45 if ( /<\/Language>/ )
46 inlang = 0
47 if ( /<Country>/ )
48 incoun = 1
49 if ( incoun && /<DefaultName>/ )
51 split( $0, x, /<|>/ )
52 country = x[3]
54 if ( /<\/Country>/ )
55 incoun = 0
58 END {
59 printEntry()
60 print "\n" count " locales"
63 function printEntry() {
64 if ( file )
66 tmp = file
67 gsub( /.*\//, "", tmp )
68 gsub( /\.xml/, "", tmp )
69 split( tmp, iso, /_/ )
70 if ( iso[2] )
71 printf( "%3s_%2s: %s - %s\n", iso[1], iso[2], language, country )
72 else
73 printf( "%3s %2s: %s %s\n", iso[1], iso[2], language, country )