/* * #%L * synat-portal-webapp Maven Webapp * %% * Copyright (C) 2010 - 2013 ICM, Warsaw University * %% * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * #L% */ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Locale; import java.util.Properties; import java.util.ResourceBundle; public class GenerateLabels { private static final String LABELS_PATH = "pl/edu/icm/synat/portal/ui/"; public static void main(final String[] args) throws IOException { final GenerateLabels starter = new GenerateLabels(); starter.generateLabels("labels", new Locale("zu")); starter.generateLabels("messages", new Locale("zu")); starter.generateLabels("disciplines", new Locale("zu")); } public void generateLabels(final String filename, final Locale locale) throws IOException { ResourceBundle res = ResourceBundle.getBundle(LABELS_PATH + filename); List lista = new ArrayList(res.keySet()); Properties labels = new Properties(); for (final String key : lista) { labels.setProperty(key, key); System.out.println(key); } File file = new File("src/main/resources/" + LABELS_PATH + filename + "_zu.properties"); if (!file.exists()) { file.createNewFile(); } FileOutputStream out = new FileOutputStream(file); labels.store(out, null); } }