blob: c1b6b7f1c0aeadca93de97e86f4edb545bc273c4 [file] [log] [blame]
ohair92de5662012-04-10 08:22:03 -07001#!/bin/sh
2
3#
4# Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
5# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6#
7# This code is free software; you can redistribute it and/or modify it
8# under the terms of the GNU General Public License version 2 only, as
9# published by the Free Software Foundation. Oracle designates this
10# particular file as subject to the "Classpath" exception as provided
11# by Oracle in the LICENSE file that accompanied this code.
12#
13# This code is distributed in the hope that it will be useful, but WITHOUT
14# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16# version 2 for more details (a copy is included in the LICENSE file that
17# accompanied this code).
18#
19# You should have received a copy of the GNU General Public License version
20# 2 along with this work; if not, write to the Free Software Foundation,
21# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22#
23# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
24# or visit www.oracle.com if you need additional information or have any
25# questions.
26#
27
28#
29# This script is to generate the supported locale list string and replace the
30# #LOCALE_LIST# in <ws>/src/share/classes/sun/util/CoreResourceBundleControl.java.
31#
32# NAWK & SED is passed in as environment variables.
33#
34LOCALE_LIST=$1
35INUT_FILE=$2
36OUTPUT_FILE=$3
37
38LOCALES=`(for I in $LOCALE_LIST; do echo $I;done) | sort | uniq`
39JAVA_LOCALES=
40
41toJavaLocale()
42{
43 NewLocale=`echo $1 | $NAWK '
44 BEGIN {
45 # The following values have to be consistent with java.util.Locale.
46 javalocales["en"] = "ENGLISH";
47 javalocales["fr"] = "FRENCH";
48 javalocales["de"] = "GERMAN";
49 javalocales["it"] = "ITALIAN";
50 javalocales["ja"] = "JAPANESE";
51 javalocales["ko"] = "KOREAN";
52 javalocales["zh"] = "CHINESE";
53 javalocales["zh_CN"] = "SIMPLIFIED_CHINESE";
54 javalocales["zh_TW"] = "TRADITIONAL_CHINESE";
55 javalocales["fr_FR"] = "FRANCE";
56 javalocales["de_DE"] = "GERMANY";
57 javalocales["it_IT"] = "ITALY";
58 javalocales["ja_JP"] = "JAPAN";
59 javalocales["ko_KR"] = "KOREA";
60 javalocales["en_GB"] = "UK";
61 javalocales["en_US"] = "US";
62 javalocales["en_CA"] = "CANADA";
63 javalocales["fr_CA"] = "CANADA_FRENCH";
64 }
65 {
66 if ($0 in javalocales) {
67 print " Locale." javalocales[$0];
68 } else {
69 split($0, a, "_");
70 if (a[3] != "") {
71 print " new Locale(\"" a[1] "\", \"" a[2] "\", \"" a[3] "\")";
72 } else if (a[2] != "") {
73 print " new Locale(\"" a[1] "\", \"" a[2] "\")";
74 } else {
75 print " new Locale(\"" a[1] "\")";
76 }
77 }
78 }'`
79
80 JAVA_LOCALES=$JAVA_LOCALES$NewLocale
81}
82
83# count the number of locales
84counter=0
85for i in $LOCALES
86do
87 counter=`expr $counter + 1`
88done
89
90index=0
91for locale in $LOCALES
92do
93 index=`expr $index + 1`;
94 if [ $index != $counter ]
95 then
96 toJavaLocale $locale
97 JAVA_LOCALES=$JAVA_LOCALES","
98 else
99 toJavaLocale $locale
100 fi
101done
102
103# replace the #LOCALE_LIST# in the precompiled CoreResourceBundleControl.java file.
104
105$SED -e "s@^#warn .*@// -- This file was mechanically generated: Do not edit! -- //@" \
106 -e "s/#LOCALE_LIST#/$JAVA_LOCALES/g" $2 > $3
107
108
109