OCR Configurable  1.0
 Todo Clases Namespaces Archivos Funciones Variables
LanguageCodeHelper.java
Ir a la documentación de este archivo.
00001 /*
00002  * Copyright 2011 Robert Theis
00003  * Copyright 2012 Jaime Navarro Santapau
00004  *
00005  * Licensed under the Apache License, Version 2.0 (the "License");
00006  * you may not use this file except in compliance with the License.
00007  * You may obtain a copy of the License at
00008  *
00009  *      http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00026 package edu.uoc.ocr;
00027 
00028 import android.content.Context;
00029 import android.content.res.Resources;
00030 import android.util.Log;
00031 
00032 import edu.uoc.ocr.R;
00033 
00040 public class LanguageCodeHelper {
00041         public static final String TAG = "LanguageCodeHelper";
00042 
00046         private LanguageCodeHelper() {
00047                 throw new AssertionError();
00048         }
00049 
00061         public static String getOcrLanguageName(Context context, String languageCode) {
00062                 Resources res = context.getResources();
00063                 String[] language6393 = res.getStringArray(R.array.iso6393);
00064                 String[] languageNames = res.getStringArray(R.array.languagenames);
00065                 int len;
00066 
00067                 // Finds the given language code in the iso6393 array, and takes the
00068                 // name with the same index
00069                 // from the languagenames array.
00070                 for (len = 0; len < language6393.length; len++) {
00071                         if (language6393[len].equals(languageCode)) {
00072                                 Log.d(TAG, "getOcrLanguageName: " + languageCode + "->"
00073                                                 + languageNames[len]);
00074                                 return languageNames[len];
00075                         }
00076                 }
00077 
00078                 Log.d(TAG, "languageCode: Could not find language name for ISO 693-3: "
00079                                 + languageCode);
00080                 return languageCode;
00081         }
00082 
00083 }
 Todo Clases Namespaces Archivos Funciones Variables