Mercurial > projects > dwt2
comparison base/src/java/util/ResourceBundle.d @ 114:46539f5c5993
Added implementation of ResourceBundle.
author | kntroh |
---|---|
date | Fri, 08 Apr 2011 20:12:20 +0900 |
parents | 9f4c18c268b2 |
children | 3daece18b48e |
comparison
equal
deleted
inserted
replaced
113:fb3aa8075988 | 114:46539f5c5993 |
---|---|
6 import java.lang.util; | 6 import java.lang.util; |
7 import java.lang.Integer; | 7 import java.lang.Integer; |
8 import java.lang.exceptions; | 8 import java.lang.exceptions; |
9 import java.util.MissingResourceException; | 9 import java.util.MissingResourceException; |
10 import java.util.Enumeration; | 10 import java.util.Enumeration; |
11 import java.nonstandard.locale; | |
11 version(Tango){ | 12 version(Tango){ |
12 //import tango.text.Util; | 13 //import tango.text.Util; |
13 import tango.io.device.File; | 14 import tango.io.device.File; |
14 import tango.text.locale.Core; | |
15 } else { // Phobos | 15 } else { // Phobos |
16 import std.file; | 16 import std.file; |
17 } | 17 } |
18 | 18 |
19 | 19 |
23 | 23 |
24 /++ | 24 /++ |
25 + First entry is the default entry if no maching locale is found | 25 + First entry is the default entry if no maching locale is found |
26 +/ | 26 +/ |
27 public this( ImportData[] data ){ | 27 public this( ImportData[] data ){ |
28 version(Tango){ | 28 char[] name = caltureName.dup; |
29 char[] name = Culture.current().name.dup; | 29 if( name.length is 5 && name[2] is '-' ){ |
30 if( name.length is 5 && name[2] is '-' ){ | 30 name[2] = '_'; |
31 name[2] = '_'; | 31 char[] end = "_" ~ name ~ ".properties"; |
32 char[] end = "_" ~ name ~ ".properties"; | |
33 foreach( entry; data ){ | |
34 if( entry.name.length > end.length && entry.name[ $-end.length .. $ ] == end ){ | |
35 //Trace.formatln( "ResourceBundle {}", entry.name ); | |
36 initialize( cast(char[])entry.data ); | |
37 return; | |
38 } | |
39 } | |
40 } | |
41 char[] end = "_" ~ name[0..2] ~ ".properties"; | |
42 foreach( entry; data ){ | 32 foreach( entry; data ){ |
43 if( entry.name.length > end.length && entry.name[ $-end.length .. $ ] == end ){ | 33 if( entry.name.length > end.length && entry.name[ $-end.length .. $ ] == end ){ |
44 //Trace.formatln( "ResourceBundle {}", entry.name ); | 34 //Trace.formatln( "ResourceBundle {}", entry.name ); |
45 initialize( cast(char[])entry.data ); | 35 initialize( cast(String)entry.data ); |
46 return; | 36 return; |
47 } | 37 } |
48 } | 38 } |
49 //Trace.formatln( "ResourceBundle default" ); | |
50 initialize( cast(char[])data[0].data ); | |
51 } else { // Phobos | |
52 implMissing(__FILE__,__LINE__); | |
53 } | 39 } |
40 char[] end = "_" ~ name[0..2] ~ ".properties"; | |
41 foreach( entry; data ){ | |
42 if( entry.name.length > end.length && entry.name[ $-end.length .. $ ] == end ){ | |
43 //Trace.formatln( "ResourceBundle {}", entry.name ); | |
44 initialize( cast(String)entry.data ); | |
45 return; | |
46 } | |
47 } | |
48 //Trace.formatln( "ResourceBundle default" ); | |
49 initialize( cast(String)data[0].data ); | |
54 } | 50 } |
55 public this( ImportData data ){ | 51 public this( ImportData data ){ |
56 initialize( cast(String)data.data ); | 52 initialize( cast(String)data.data ); |
57 } | 53 } |
58 public this( String data ){ | 54 public this( String data ){ |