comparison dwt/dwthelper/ResourceBundle.d @ 200:fef1e3b37378

sync with dwt-linux
author Frank Benoit <benoit@tionex.de>
date Fri, 11 Apr 2008 17:15:55 +0200
parents 184ab53b7785
children ab60f3309436
comparison
equal deleted inserted replaced
199:3d5dbb27dec2 200:fef1e3b37378
6 import tango.text.Util; 6 import tango.text.Util;
7 import tango.io.Stdout; 7 import tango.io.Stdout;
8 8
9 import dwt.DWT; 9 import dwt.DWT;
10 import dwt.dwthelper.utils; 10 import dwt.dwthelper.utils;
11 import tango.io.File;
11 12
12 class ResourceBundle { 13 class ResourceBundle {
13 14
14 char[][ char[] ] map; 15 char[][ char[] ] map;
15 16
58 while( pos < line.length ){ 59 while( pos < line.length ){
59 char c = line[pos]; 60 char c = line[pos];
60 if( esc ){ 61 if( esc ){
61 esc = false; 62 esc = false;
62 switch( c ){ 63 switch( c ){
63 case 't': c = '\t'; break; 64 case 't' : c = '\t'; break;
64 case 'n': c = '\n'; break; 65 case 'n' : c = '\n'; break;
65 case '\\': c = '\\'; break; 66 case '\\': c = '\\'; break;
66 case '\"': c = '\"'; break; 67 case '\"': c = '\"'; break;
68 //case ':' : c = ':' ; break;
67 default: break; 69 default: break;
68 } 70 }
69 } 71 }
70 else{ 72 else{
71 if( c == '\\' ){ 73 if( c == '\\' ){
118 120
119 public char[][] getKeys(){ 121 public char[][] getKeys(){
120 return map.keys; 122 return map.keys;
121 } 123 }
122 124
125 public static ResourceBundle getBundle( ImportData data ){
126 return new ResourceBundle( cast(char[]) data.data );
127 }
123 public static ResourceBundle getBundle( char[] name ){ 128 public static ResourceBundle getBundle( char[] name ){
124 return new ResourceBundle( null ); 129 try{
130 scope f = new File(name);
131 return new ResourceBundle( cast(char[]) f.read() );
132 }
133 catch( IOException e){
134 e.msg ~= " file:" ~ name;
135 throw e;
136 }
125 } 137 }
126 public static ResourceBundle getBundleFromData( char[] data ){ 138 public static ResourceBundle getBundleFromData( char[] data ){
127 return new ResourceBundle( data ); 139 return new ResourceBundle( data );
128 } 140 }
129 } 141 }