/* LanguageTool, a natural language style checker 
 * Copyright (C) 2006 Daniel Naber (http://www.danielnaber.de)
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
 * USA
 */
package de.danielnaber.languagetool.dev;

import java.util.Properties;
import java.io.FileOutputStream;
import java.io.IOException;

import de.danielnaber.languagetool.Language;

/** Used for creating ooolocales.properties file that
 *  defines a property that is needed to build
 *  Linguistic.xcu. Run internally by the ant build.
 *  
 * @author Marcin Miłkowski
 *
 */
public class PrintLocales {


  public static void main(final String[] args) throws IOException{
    final PrintLocales prg = new PrintLocales();
    prg.run();
  }

  private void run() throws IOException { 
    String locales = "";
    for (final Language element : Language.LANGUAGES) {
      if (!element.equals(Language.DEMO)) {
        for (final String variant : element.getCountryVariants()) {
          if (!("").equals(locales)) {
            locales = locales + " "  + element.getShortName() + "-" + variant;
          } else {
            locales = element.getShortName() + "-" + variant;
          }
        }
      }
    }
    final Properties propLoc = new Properties();
    propLoc.setProperty("countryvariants", locales);
    propLoc.store(new FileOutputStream("ooolocales.properties"), "Locales");
  }
}

@@ -985,16 +985,37 @@
 ception;
+%0Aimport java.io.File;
 %0A%0Aimport
@@ -1881,24 +1881,174 @@
     %7D%0A    %7D%0A
+    //change attribute to writable as the property file is in the repo%0A    final File f = new File(%22ooolocales.properties%22);%0A    f.setWritable(true);%0A
     final Pr
@@ -2213,15 +2213,19 @@
 cales%22);
+    
 %0A  %7D%0A%7D%0A

fix a glitch in build tooling