1 /* 2 ********************************************************************** 3 * Copyright (c) 2002-2010, International Business Machines 4 * Corporation and others. All Rights Reserved. 5 ********************************************************************** 6 * Author: John Emmons 7 ********************************************************************** 8 */ 9 10 package org.unicode.cldr.posix; 11 12 import java.io.PrintWriter; 13 import java.util.Locale; 14 15 import org.unicode.cldr.util.CLDRFile; 16 17 public class POSIX_LCMessages { 18 19 String yesstr; 20 String nostr; 21 String yesexpr; 22 String noexpr; 23 String SearchLocation; 24 Locale loc; 25 POSIX_LCMessages(CLDRFile doc, String locale_name, POSIXVariant variant)26 public POSIX_LCMessages(CLDRFile doc, String locale_name, POSIXVariant variant) { 27 int i = locale_name.indexOf('_'); 28 if (i > 0) 29 loc = new Locale(locale_name.substring(0, i)); 30 else 31 loc = Locale.getDefault(); 32 33 SearchLocation = "//ldml/posix/messages/yesstr"; 34 String s; 35 s = doc.getWinningValue(SearchLocation); 36 if (s != null) { 37 StringBuffer buf; 38 if (variant.yesno.equals("short")) { 39 i = s.indexOf(":"); 40 if (i > 0) 41 buf = new StringBuffer(s.substring(0, i)); 42 else 43 buf = new StringBuffer(s); 44 } else { 45 buf = new StringBuffer(s); 46 if (!s.equals(s.toUpperCase(loc))) 47 buf.append(":" + s.toUpperCase(loc)); 48 if (!s.startsWith("yes:")) 49 buf.append(":yes:y:YES:Y"); 50 } 51 yesstr = POSIXUtilities.POSIXCharNameNP(buf.toString()); 52 yesexpr = POSIXUtilities.POSIXYesNoExpr(buf.toString()); 53 } else if (variant.yesno.equals("short")) { 54 yesstr = "yes"; 55 yesexpr = POSIXUtilities.POSIXYesNoExpr(yesstr); 56 } else { 57 yesstr = "yes:y:YES:Y"; 58 yesexpr = POSIXUtilities.POSIXYesNoExpr(yesstr); 59 } 60 61 SearchLocation = "//ldml/posix/messages/nostr"; 62 s = doc.getWinningValue(SearchLocation); 63 if (s != null) { 64 StringBuffer buf; 65 if (variant.yesno.equals("short")) { 66 i = s.indexOf(":"); 67 if (i > 0) 68 buf = new StringBuffer(s.substring(0, i)); 69 else 70 buf = new StringBuffer(s); 71 } else { 72 buf = new StringBuffer(s); 73 if (!s.equals(s.toUpperCase(loc))) 74 buf.append(":" + s.toUpperCase(loc)); 75 if (!s.startsWith("no:")) 76 buf.append(":no:n:NO:N"); 77 } 78 nostr = POSIXUtilities.POSIXCharNameNP(buf.toString()); 79 noexpr = POSIXUtilities.POSIXYesNoExpr(buf.toString()); 80 } else if (variant.yesno.equals("short")) { 81 nostr = "no"; 82 noexpr = POSIXUtilities.POSIXYesNoExpr(nostr); 83 } else { 84 nostr = "no:n:NO:N"; 85 noexpr = POSIXUtilities.POSIXYesNoExpr(nostr); 86 } 87 88 } 89 write(PrintWriter out)90 public void write(PrintWriter out) { 91 92 out.println("*************"); 93 out.println("LC_MESSAGES"); 94 out.println("*************"); 95 out.println(); 96 97 // yesstr 98 out.println("yesstr \"" + yesstr + "\""); 99 out.println(); 100 101 // nostr 102 out.println("nostr \"" + nostr + "\""); 103 out.println(); 104 105 // yesexpr 106 out.println("yesexpr \"" + yesexpr + "\""); 107 out.println(); 108 109 // noexpr 110 out.println("noexpr \"" + noexpr + "\""); 111 out.println(); 112 113 out.println(); 114 out.println("END LC_MESSAGES"); 115 } 116 } 117