PageRenderTime 56ms CodeModel.GetById 9ms RepoModel.GetById 1ms app.codeStats 0ms

/i18npool/source/localedata/data/list-locales.awk

https://bitbucket.org/markjenkins/libreoffice_ubuntu-debian-fixes
AWK | 92 lines | 65 code | 6 blank | 21 comment | 0 complexity | 5f505d13fdf9887fc7bf49bf80a8711d MD5 | raw file
Possible License(s): GPL-3.0, LGPL-3.0, MPL-2.0-no-copyleft-exception, LGPL-2.1, BSD-3-Clause-No-Nuclear-License-2014
  1. #!/usr/bin/gawk -f
  2. #
  3. # This file is part of the LibreOffice project.
  4. #
  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/.
  8. #
  9. # This file incorporates work covered by the following license notice:
  10. #
  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 .
  18. #
  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>
  22. BEGIN {
  23. file = ""
  24. count = 0
  25. }
  26. function init_locale() {
  27. lcinfo = 0
  28. inlang = 0
  29. incoun = 0
  30. language = ""
  31. country = ""
  32. }
  33. FILENAME != file {
  34. printEntry()
  35. file = FILENAME
  36. ++count
  37. init_locale()
  38. }
  39. {
  40. if ( !lcinfo )
  41. {
  42. if ( /<LC_INFO>/ )
  43. lcinfo = 1
  44. next
  45. }
  46. if ( /<\/LC_INFO>/ )
  47. {
  48. lcinfo = 0
  49. next
  50. }
  51. if ( /<Language>/ )
  52. inlang = 1
  53. if ( inlang && /<DefaultName>/ )
  54. {
  55. split( $0, x, /<|>/ )
  56. language = x[3]
  57. }
  58. if ( /<\/Language>/ )
  59. inlang = 0
  60. if ( /<Country>/ )
  61. incoun = 1
  62. if ( incoun && /<DefaultName>/ )
  63. {
  64. split( $0, x, /<|>/ )
  65. country = x[3]
  66. }
  67. if ( /<\/Country>/ )
  68. incoun = 0
  69. }
  70. END {
  71. printEntry()
  72. print "\n" count " locales"
  73. }
  74. function printEntry() {
  75. if ( file )
  76. {
  77. tmp = file
  78. gsub( /.*\//, "", tmp )
  79. gsub( /\.xml/, "", tmp )
  80. split( tmp, iso, /_/ )
  81. if ( iso[2] )
  82. printf( "%3s_%2s: %s - %s\n", iso[1], iso[2], language, country )
  83. else
  84. printf( "%3s %2s: %s %s\n", iso[1], iso[2], language, country )
  85. }
  86. }