![JAR search and dependency download from the Maven repository](/logo.png)
org.apache.wiki.TranslationsCheck Maven / Gradle / Ivy
/*
* 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.
*/
package org.apache.wiki;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.TreeSet;
/**
* Simple utility that shows you a sorted list of property differences between
* the 'default en' and a given i18n file. It also warns if there are any duplicates.
*
* The first argument is the language, and it is mandatory.
* The second argument is the path. If the path is not defined, uses current path (.)
*
* For example (if you're compiling your classes to "classes"):
*
* java -cp classes TranslationsCheck fi
*
*/
public class TranslationsCheck {
private final static String[] LANGS = { "de", "en", "es", "fi", "fr", "it", "nl", "pt_BR", "ru", "zh_CN" };
private final static String SITE_I18N_ROW =
"
\n" +
" %s \n" +
" %d%% \n" +
" %d \n" +
" %d \n" +
" \n";
private final TreeSet< String > allProps = new TreeSet<>(); // sorted, no duplicates
private final TreeSet< String > duplProps = new TreeSet<>();
// Change these to your settings...
String base = ".";
String suffix;
public static void main( final String[] args ) throws IOException {
final TranslationsCheck translations = new TranslationsCheck();
if( args.length == 0 ) {
System.out.println( "Usage: java TranslationsCheck []" );
System.out.println( "Example: java TranslationsCheck nl [jspwiki-main/src/main/resources]" );
System.out.println( "To output site i18n info use java TranslationsCheck site []" );
return;
}
translations.suffix = args[ 0 ];
if( args.length >= 2 ) {
translations.base = args[ 1 ];
}
if( "site".equals( translations.suffix ) ) {
final StringBuilder site = new StringBuilder();
for( int i = 0; i < LANGS.length; i++ ) {
translations.suffix = LANGS[ i ];
site.append(translations.check(i));
}
site.append("\n" + // close table and formatting divs
"