~teemu-heinamaki/ubuntu/maverick/tuxguitar/merge-from-debian

« back to all changes in this revision

Viewing changes to TuxGuitar/src/org/herac/tuxguitar/gui/system/language/TGResourceBundle.java

  • Committer: Bazaar Package Importer
  • Author(s): Philippe Coval
  • Date: 2009-04-25 19:49:27 UTC
  • mfrom: (1.1.3 upstream) (2.1.7 jaunty)
  • Revision ID: james.westby@ubuntu.com-20090425194927-pblqed0zxp0pmyeq
Tags: 1.1-1
* New Upstream Release (Closes: #489859) (LP: #366476)
* Merged patch : tuxguitar_1.0.dak-1ubuntu1.patch
* debian/README.txt
  - suggests to install tuxguitar-jsa

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
import java.util.Locale;
7
7
import java.util.Properties;
8
8
 
 
9
import org.herac.tuxguitar.gui.util.TGFileUtils;
 
10
 
9
11
public class TGResourceBundle {
10
12
        
11
13
        private Locale locale;
28
30
                return this.properties.getProperty(key);
29
31
        }
30
32
        
31
 
        public static TGResourceBundle getBundle(String baseName, Locale locale,ClassLoader loader){
 
33
        public static TGResourceBundle getBundle(String baseName, Locale locale){
32
34
                Properties properties = new Properties();
33
35
                
34
36
                String bundleName = baseName.replace('.','/');
35
37
                String bundleExtension = ".properties";
36
38
                
37
39
                // load default
38
 
                TGResourceBundle.loadResources( (bundleName + bundleExtension ), properties, loader);
 
40
                TGResourceBundle.loadResources( (bundleName + bundleExtension ), properties);
39
41
                
40
42
                // load language
41
43
                bundleName += "_";
42
44
                if(locale.getLanguage() != null && locale.getLanguage().length() > 0){
43
45
                        bundleName += locale.getLanguage();
44
 
                        TGResourceBundle.loadResources( (bundleName + bundleExtension ), properties, loader);
 
46
                        TGResourceBundle.loadResources( (bundleName + bundleExtension ), properties);
45
47
                }
46
48
                
47
49
                // load country
48
50
                bundleName += "_";
49
51
                if(locale.getCountry() != null && locale.getCountry().length() > 0){
50
52
                        bundleName += locale.getCountry();
51
 
                        TGResourceBundle.loadResources( (bundleName + bundleExtension ), properties, loader);
 
53
                        TGResourceBundle.loadResources( (bundleName + bundleExtension ), properties);
52
54
                }
53
55
                
54
56
                // load variant
55
57
                bundleName += "_";
56
58
                if(locale.getVariant() != null && locale.getVariant().length() > 0){
57
59
                        bundleName += locale.getVariant();
58
 
                        TGResourceBundle.loadResources( (bundleName + bundleExtension ), properties, loader);
 
60
                        TGResourceBundle.loadResources( (bundleName + bundleExtension ), properties);
59
61
                }
60
62
                
61
63
                return new TGResourceBundle(locale, properties);
62
64
        }
63
65
        
64
 
        private static void loadResources(String name, Properties p, ClassLoader loader){
 
66
        private static void loadResources(String name, Properties p){
65
67
                try {
66
 
                        Enumeration enumeration = loader.getResources(name);
 
68
                        Enumeration enumeration = TGFileUtils.getResourceUrls(name);
67
69
                        while (enumeration.hasMoreElements()) {
68
70
                                URL url = (URL) enumeration.nextElement();
69
71
                                Properties properties = new Properties();