/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.
*/
/** Runs the makenbm task for each locale specified in the * global property locmakenbm.locales. * NOTE: Currently this runs makelnbm, since the new * functionality in that hasn't been merged into makenbm * yet. * * @author Jerry Huth (email: jerry@solidstep.com)
*/ publicclass LocMakeNBM extends Task {
// I couldn't get it to work unless I explicitly added the task def here. //
getProject().addTaskDefinition("makelnbm", MakeLNBM.class); //NOI18N
// Get a list of the locales for which localized files exist. //
stok = new StringTokenizer( locs, ",") ; //NOI18N while( stok.hasMoreTokens()) {
loc = stok.nextToken() ;
log("Checking if module has files in locale '"+loc+"'", Project.MSG_VERBOSE); if( hasFilesInLocale( loc)) {
build_locales.add( loc) ;
log("Module has files in locale '"+loc+"'", Project.MSG_VERBOSE);
} else {
log("Module has no files in locale '"+loc+"'", Project.MSG_VERBOSE);
}
}
// For each locale that we need to build an NBM for. //
ListIterator<String> iterator = build_locales.listIterator() ; while( iterator.hasNext()) {
// Build the NBM for this locale. //
buildNbm( iterator.next()) ;
}
}
/** Build the NBM for this locale. */ protectedvoid buildNbm( String locale) throws BuildException {
MakeLNBM makenbm ;
LinkedList<String> list = new LinkedList<>() ;
String includes = new String() ;
File licenseFile ; boolean first_time ; Delete del ;
// Delete the Info directory if desired. // if( deleteInfo) {
del = (Delete) getProject().createTask("delete"); //NOI18N
del.init() ;
del.setDir( new File( topDir.getAbsolutePath() + File.separator + "Info")) ; //NOI18N
del.execute() ;
del.setDir( new File( topDir.getAbsolutePath() + File.separator + "Info_" + //NOI18N
locale)) ;
del.execute() ;
} else {
// Move the Info_<locale> dir to Info. //
switchInfo( true, locale) ;
}
/** See if there are any files for the given locale. */ protectedboolean hasFilesInLocale( String loc) {
FileSet fs ; boolean ret = true ;
// Setup a fileset to find files in this locale. //
fs = new FileSet() ;
fs.setDir( topDir) ;
addLocalePatterns( fs, loc) ;
// See if there are any localized files for this locale. //
String[] inc_files = fs.getDirectoryScanner(getProject()).getIncludedFiles(); if( inc_files.length == 0) {
ret = false ;
}
return( ret) ;
}
/** Add the patterns to include the localized files for the given locale. */ protectedvoid addLocalePatterns( FileSet fs,
String loc) {
LinkedList<String> list = new LinkedList<>() ;
// Get the list of patterns for this locale. //
addLocalePatterns( list, loc) ;
for (String s: list) { // Add it to the includes list. //
fs.createInclude().setName(s) ;
}
}
protectedvoid addLocalePatterns( LinkedList<String> list,
String loc) { // String dir = new String() ;
String re;
// dir = mainDir ; // modified for clusterization // re = dir + "/**/*_" + loc + ".*" ; // pattern is: ${dir}/**/*_${locale}.* //NOI18N // list.add( new String( re)) ; // re = dir + "/**/" + loc + "/" ; // pattern is: ${dir}/${locale}/ //NOI18N // list.add( new String( re)) ;
re = "**/*_" + loc + ".*" ; // pattern is: ${dir}/**/*_${locale}.* //NOI18N
list.add(re) ;
re = "**/" + loc + "/" ; // pattern is: ${dir}/${locale}/ //NOI18N
list.add(re) ;
addLocIncludes( list, loc) ;
// For ja locale, include these other variants. // if( loc.equals( "ja")) { //NOI18N
addLocalePatterns( list, "ja_JP.PCK") ; //NOI18N
addLocalePatterns( list, "ja_JP.eucJP") ; //NOI18N
addLocalePatterns( list, "ja_JP.SJIS") ; //NOI18N
addLocalePatterns( list, "ja_JP.UTF-8") ; //NOI18N
addLocalePatterns( list, "ja_JP.UTF8") ; //NOI18N
}
}
// See if the file containing the srcdir is there. //
srcdirfile = new File( topDir.getAbsolutePath() + File.separator + "srcdir.properties") ; //NOI18N if( srcdirfile.exists()) {
srcdir = getSrcDir( srcdirfile) ;
} // if( srcdir == null) { // throw new BuildException( "ERROR: Could not get source dir from: " + srcdirfile.getPath()) ; // }
// Get the codename of this module. //
index = modInfo.indexOf( "/") ; //NOI18N if( index != -1) {
s = modInfo.substring( 0, index) ;
} else {
s = new String( modInfo) ;
}
// Convert to pathname and set the loc bundle. //
s = s.replace( '.', '/') ; //NOI18N
locdir = new File( getRelPath( srcdir + "/" + s, findLocBundle). //NOI18N
replace( '/', File.separatorChar)) ; //NOI18N return( getDefaultLocBundleFile( locdir, locale)) ;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.