Version 4.0.0.1, tag libreoffice-4.0.0.1
[LibreOffice.git] / i18npool / source / localedata / data / list-locales.awk
blobb8a7f73f14de4bc3a2f38d8fb7eb2e513447aff6
1 #!/usr/bin/gawk -f
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 # This file incorporates work covered by the following license notice:
11 # Licensed to the Apache Software Foundation (ASF) under one or more
12 # contributor license agreements. See the NOTICE file distributed
13 # with this work for additional information regarding copyright
14 # ownership. The ASF licenses this file to you under the Apache
15 # License, Version 2.0 (the "License"); you may not use this file
16 # except in compliance with the License. You may obtain a copy of
17 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #// Usage: gawk -f list-locales.awk *.xml
20 #// Simply create a verbose list of known locales as stated in XML files.
21 #// Author: Eike Rathke <erack@sun.com>
23 BEGIN {
24 file = ""
25 count = 0
28 function init_locale() {
29 lcinfo = 0
30 inlang = 0
31 incoun = 0
32 language = ""
33 country = ""
36 FILENAME != file {
37 printEntry()
38 file = FILENAME
39 ++count
40 init_locale()
44 if ( !lcinfo )
46 if ( /<LC_INFO>/ )
47 lcinfo = 1
48 next
50 if ( /<\/LC_INFO>/ )
52 lcinfo = 0
53 next
55 if ( /<Language>/ )
56 inlang = 1
57 if ( inlang && /<DefaultName>/ )
59 split( $0, x, /<|>/ )
60 language = x[3]
62 if ( /<\/Language>/ )
63 inlang = 0
64 if ( /<Country>/ )
65 incoun = 1
66 if ( incoun && /<DefaultName>/ )
68 split( $0, x, /<|>/ )
69 country = x[3]
71 if ( /<\/Country>/ )
72 incoun = 0
75 END {
76 printEntry()
77 print "\n" count " locales"
80 function printEntry() {
81 if ( file )
83 tmp = file
84 gsub( /.*\//, "", tmp )
85 gsub( /\.xml/, "", tmp )
86 split( tmp, iso, /_/ )
87 if ( iso[2] )
88 printf( "%3s_%2s: %s - %s\n", iso[1], iso[2], language, country )
89 else
90 printf( "%3s %2s: %s %s\n", iso[1], iso[2], language, country )