Revision 6547

View differences:

trunk/libraries/libInternationalization/src-utils/org/gvsig/i18n/utils/Keys.java
46 46
				project.dictionaries = loadProjectFromSources(project);
47 47
			}
48 48
			else {
49
				// load the keys for each language from the property file
49 50
			 	project.dictionaries = loadProjectFromProperties(project);
51
			 	// add missing keys tp each language
52
			 	completeKeys(project);
50 53
			 }
51 54
		}
52 55
	}
......
157 160
		return dictionaries;
158 161
	}
159 162
	
163
	/**
164
	 * Reads the keys from all the languages, to make a unique list containing
165
	 * all the keys. 
166
	 */
167
	public void completeKeys(Project project) {
168
		/* The list of all the keys */
169
		HashSet keys = new HashSet();
170
		// always start with an empty HashMap when loading
171
		//HashMap dictionaries = new HashMap();		
172
		String lang;
173
		
174
		// calculate all the keys
175
		for (int currentLang=0; currentLang<config.languages.length; currentLang++) {
176
			lang = config.languages[currentLang];
177
			
178
			OrderedProperties currentDict = (OrderedProperties) project.dictionaries.get(lang);
179
			if (currentDict==null) {
180
				currentDict = new OrderedProperties();
181
				project.dictionaries.put(lang, currentDict);
182
			}
183
			else {
184
				Iterator keysIterator = currentDict.keySet().iterator();
185
				String key;
186
				// add missing keys
187
				while (keysIterator.hasNext()) {
188
					key = (String) keysIterator.next();
189
					keys.add(key);
190
				}	
191
			}
192
		}
193
		
194
		// add missing keys to each language
195
		for (int currentLang=0; currentLang<config.languages.length; currentLang++) {
196
			lang = config.languages[currentLang];
197
			
198
			OrderedProperties currentDict = (OrderedProperties) project.dictionaries.get(lang);
199
			Iterator keysIterator = keys.iterator();
200
			String key;
201
			// add missing keys
202
			while (keysIterator.hasNext()) {
203
				key = (String) keysIterator.next();
204
				if (!currentDict.containsKey(key)) {
205
					currentDict.put(key, "");
206
					System.out.println(project.dir+" -- Aviso -- clave a?adida: "+key);
207
				}
208
			}			
209
		}
210
	}
160 211
	
212
	
161 213
	private HashSet loadKeysFromSources(String directory, HashSet keys) {
162 214
		String key;
163 215
		File dir = new File(directory);

Also available in: Unified diff