• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.android.tools.layoutlib.java.util;
17 
18 import java.util.Locale;
19 
20 /**
21  * This class provides an alternate implementation for {@code java.util.Locale#adjustLanguageCode}
22  * which is not available in openJDK.
23  *
24  * The create tool re-writes references to the above mentioned method to this one. Hence it's
25  * imperative that this class is not deleted unless the create tool is modified.
26  */
27 public class LocaleAdjustLanguageCodeReplacement {
28 
adjustLanguageCode(String languageCode)29     public static String adjustLanguageCode(String languageCode) {
30         String adjusted = languageCode.toLowerCase(Locale.US);
31         // Map new language codes to the obsolete language
32         // codes so the correct resource bundles will be used.
33         if (languageCode.equals("he")) {
34             adjusted = "iw";
35         } else if (languageCode.equals("id")) {
36             adjusted = "in";
37         } else if (languageCode.equals("yi")) {
38             adjusted = "ji";
39         }
40 
41         return adjusted;
42     }
43 }
44