sixcooler 10 years ago
commit 6b6ca63987

@ -53,7 +53,7 @@
<img src="env/grafics/idea.png" width="32" height="32" alt="idea" align="center"/>Speed up search results with this option! (use CACHEONLY or FALSE to switch off verification)<br/>
<input type="radio" name="search.verify" value="nocache" #(search.verify.nocache)#::checked="checked"#(/search.verify.nocache)# onclick="document.getElementById('search_verify_delete').disabled=false;document.getElementById('search_verify_delete').checked=true;"/> NOCACHE: no use of web cache, load all snippets online<br/>
<input type="radio" name="search.verify" value="iffresh" #(search.verify.iffresh)#::checked="checked"#(/search.verify.iffresh)# onclick="document.getElementById('search_verify_delete').disabled=false;document.getElementById('search_verify_delete').checked=true;"/> IFFRESH: use the cache if the cache exists and is fresh otherwise load online<br/>
<input type="radio" name="search.verify" value="ifexist" #(search.verify.ifexist)#::checked="checked"#(/search.verify.ifexist)# /> IFEXIST: use the cache if the cache exist or load online<br/>
<input type="radio" name="search.verify" value="ifexist" #(search.verify.ifexist)#::checked="checked"#(/search.verify.ifexist)# onclick="document.getElementById('search_verify_delete').disabled=false;document.getElementById('search_verify_delete').checked=true;"/> IFEXIST: use the cache if the cache exist or load online<br/>
<input type="checkbox" name="search.verify.delete" id="search_verify_delete" value="true" #(search.verify.delete)#::checked="checked"#(/search.verify.delete)# /> If verification fails, delete index reference<br/><br/>
<input type="radio" name="search.verify" value="cacheonly" #(search.verify.cacheonly)#::checked="checked"#(/search.verify.cacheonly)# onclick="document.getElementById('search_verify_delete').disabled=true;document.getElementById('search_verify_delete').checked=false;"/> CACHEONLY: never go online, use all content from cache. If no cache entry exist, consider content nevertheless as available and show result without snippet<br/>
<input type="radio" name="search.verify" value="false" #(search.verify.false)#::checked="checked"#(/search.verify.false)# onclick="document.getElementById('search_verify_delete').disabled=true;document.getElementById('search_verify_delete').checked=false;"/> FALSE: no link verification and not snippet generation: all search results are valid without verification

@ -174,7 +174,7 @@ XDtoU7vQ/wIAAP//AwBb7ktEXQ4nqQAAAABJRU5ErkJggg==" width="128" height="64" alt="K
Therefore we like to ask you: do you like YaCy? Will you use it again... if not, why? Is is possible that we change a bit to suit your needs?</p>
<p>Please send us feed-back about your experience with an<br/>
<a href="http://sayat.me/YaCy" target="_blank">anonymous message</a><br/>
or a</br>
or a<br/>
posting to our <a href="http://forum.yacy.de" target="_blank">web forums</a><br/>
or a<br/>
<a href="http://bugs.yacy.net" target="_blank">bug report</a>!</p>

@ -10,7 +10,7 @@
#(/heuristic)#
#(authorized)#::
#(bookmark)#::
<a href="#[bookmarklink]#" class="bookmarklink" title="recommend"><img width="11" height="11" src="env/grafics/empty.gif" title="bookmark" alt="bookmark" class="recommendIcon" /></a>
<a href="#[bookmarklink]#" class="bookmarklink" title="bookmark"><img width="11" height="11" src="env/grafics/empty.gif" title="bookmark" alt="bookmark" class="recommendIcon" /></a>
#(/bookmark)#
#(recommend)#
<img width="11" height="11" src="env/grafics/empty.gif" title="" alt="recommend" class="recommendIcon" />

@ -317,7 +317,7 @@ public class yacysearchitem {
final String license = URLLicense.aquireLicense(image.imageUrl); // this is just the license key to get the image forwarded through the YaCy thumbnail viewer, not an actual lawful license
//sb.loader.loadIfNotExistBackground(image.imageUrl, 1024 * 1024 * 10, null, ClientIdentification.yacyIntranetCrawlerAgent);
prop.putHTML("content_item_hrefCache", "/ViewImage." + ("gif".equals(imageUrlExt) ? "gif" : "png") + "?maxwidth=128&maxheight=128&isStatic=true&quadratic=&url=" + imageUrlstring);
prop.putHTML("content_item_hrefCache", "/ViewImage." + ("gif".equals(imageUrlExt) ? "gif" : "png") + "?maxwidth=128&maxheight=128&code="+license+"&isStatic=true&quadratic=&url=" + imageUrlstring);
prop.putHTML("content_item_href", imageUrlstring);
prop.putHTML("content_item_target", target);
prop.put("content_item_code", license);

@ -463,7 +463,7 @@ RWIs at Start:==RWIs au d&eacute;part:
RWIs now:==RWIs maintenant:
wordHash in Progress:==Mots-Hash en cours:
last wordHash with deleted URLs:==dernier mot-hash avec URLs supprim&eacute;es:
Number of deleted URLs in on this Hash:==Nombre d'URLs supprim&eacute;s sur ce hâchage:
Number of deleted URLs in on this Hash:==Nombre d'URLs supprim&eacute;s sur ce hachage:
UrldbCleaner - Clean up the database by deletion of blacklisted urls:==UrlDBCleaner - Nettoie la base de donn&eacute;es en supprimant les URLs en liste noire:
Start/Resume==D&eacute;part/Reprise
Stop==Arr&ecirc;t
@ -509,7 +509,7 @@ Word-Hash:</td>==Mot-Hash:</td>
#File: CrawlStartExpert.html
#---------------------------
Index Creation==Cr&eacute;er un index
Start Crawling Job:==Tâche de d&eacute;marrage du crawl:
Start Crawling Job:==T&acirc;che de d&eacute;marrage du crawl:
You can define URLs as start points for Web page crawling and start crawling here. \"Crawling\" means that YaCy will download the given website, extract all links in it and then download the content behind these links. This is repeated as long as specified under \"Crawling Depth\".==Vous pouvez d&eacute;finir les URLs de d&eacute;part et d&eacute;marrer le crawl ici. Crawler signifie que YaCy t&eacute;l&eacute;chargera les sites de d&eacute;part et extraira tous leurs liens ainsi que leur contenu. Cela sera r&eacute;p&eacute;t&eacute; jusqu'a ce que la \"profondeur de crawl\" soit atteinte.
#Attribut==Attribut
Value==Valeur
@ -764,8 +764,8 @@ Import Path:==Import-Pfad:
"Start Import"=="Demarrer l'importation"
Attention:==Attention:
Always do a backup of your source and destination database before starting to use this import function.==Toujours faire une sauvegarde de vos bases source et destination avant de lancer cette fonction d'importation.
Currently running jobs==Tâches actuellement en cours
Job Type==Type de tâche
Currently running jobs==T&acirc;ches actuellement en cours
Job Type==Type de t&acirc;che
>Path==>Chemin
Status==Etat
Elapsed<br />Time==Temps<br />&eacute;coul&eacute;
@ -852,7 +852,7 @@ and automatically excluded from indexing.==et exclus automatiquement de l'indexa
Set the proxy settings of your browser to the same port as given==Configurez les param&egrave;tres de proxy de votre brower avec le m&ecirc;me port que celui
on the 'Settings'-page in the 'Proxy and Administration Port' field.==du champ 'Port de proxy et d'administration' de la page de 'Configuration'.
\(5\) Index Monitor for Local Crawling.==(5) Moniteur d'index pour le crawl local
These web pages had been crawled by your own crawl task.==Cette page web a &eacute;t&eacute; crawl&eacute;e par votre propre tâche de crawl.
These web pages had been crawled by your own crawl task.==Cette page web a &eacute;t&eacute; crawl&eacute;e par votre propre t&acirc;che de crawl.
<em>Use Case:</em> start a crawl by setting a crawl start point on the 'Index Create' page.==<em>Cas d'utilisation:</em> Lancer un crawl en param&egrave;trant un point de d&eacute;part sur la page 'Cr&eacute;ation d'index'.
\(6\) Index Monitor for Global Crawling==(6) Moniteur d'index pour le crawl global
These pages had been indexed by your peer, but the crawl was initiated by a remote peer.==Ces pages ont &eacute;t&eacute; index&eacute;es par votre noeud, mais le crawl &eacute;tait initi&eacute; par un noeud distant.
@ -1095,7 +1095,7 @@ Attributes==Attributs
#File: PerformanceQueues_p.html
#---------------------------
Performance Settings of Queues and Processes==Param&egrave;tres de performance des files et des processus
Scheduled tasks overview and waiting time settings:==Aperçu des tâches programm&eacute;es et param&egrave;tres d'attente:
Scheduled tasks overview and waiting time settings:==Aperçu des t&acirc;ches programm&eacute;es et param&egrave;tres d'attente:
Queue Size==Taille de file
>Total==>Totale
Block Time==Temps de blocage
@ -1133,8 +1133,8 @@ Maximum number of Word Caches, high limit:==Nombre maximal de mots dans le cache
This is is the number of word indexes that shall be held in the==C'est le nombre d'index de mots qui doivent &ecirc;tre gard&eacute;s dans le
ram cache during indexing. When YaCy is shut down, this cache must be==cache m&eacute;moire pendant l'indexation. Quand YaCy est stopp&eacute;, ce cache doit
flushed to disc; this may last some minutes.==&ecirc;tre transf&eacute;r&eacute; sur disque; cela peut durer quelques minutes.
The low limit is valid for crawling tasks, the high limit is valid==La limite basse est valide pour les tâches de crawl, la limite haute est valide
for search and DHT transmission tasks.==pour les tâches de recherche et de transmission de DHT.
The low limit is valid for crawling tasks, the high limit is valid==La limite basse est valide pour les t&acirc;ches de crawl, la limite haute est valide
for search and DHT transmission tasks.==pour les t&acirc;ches de recherche et de transmission de DHT.
Enter New Cache Size==Entrer une nouvelle taille de cache
Thread pool settings:==Param&egrave;tres du pool de threads:
maximum Active==max. actif
@ -1201,7 +1201,7 @@ The Response Header database stores the HTTP heades that other servers send when
during proxy mode, when performing crawls or if it fetches pages for snippet generation.==durant le mode proxy en ex&eacute;cutant des crawl ou en parcourant les pages pour la g&eacute;n&eacute;ration d'extraits.
Increasing this cache will be most important for a fast proxy mode.==Augmenter ce cache est important pour avoir un mode proxy rapide.
'loaded' URLs==URLs charg&eacute;es
This is the database that holds the hash/url - relation and properties regarding the url like load date and server date.==C'est la base de donn&eacute;es qui maintient la relation hâchage/url et les propri&eacute;t&eacute;s concernant l'URL comme la date de chargement et la date du serveur.
This is the database that holds the hash/url - relation and properties regarding the url like load date and server date.==C'est la base de donn&eacute;es qui maintient la relation hachage/url et les propri&eacute;t&eacute;s concernant l'URL comme la date de chargement et la date du serveur.
This cache is very important for a fast search process.==Ce cache est tr&egrave;s important pour un processus de recherche rapide.
Increasing the cache size will result in more search results and less IO during DHT transfer.==Augmenter la taille du cache augmente le nombre de r&eacute;sultats de recherche et diminue le nombre d'E/S pendant le transfert de DHT.
'noticed' URLs==URLs 'remarqu&eacute;es'
@ -1672,7 +1672,7 @@ For community support, please visit our <a href="http://forum.yacy.de" target="_
"Restart"=="Red&ecute;marrer"
"Restart"=="Red&eacute;marrer"
"Shutdown"=="Arr&Ecirc;ter"
Public System Properties==Allgemeine Systemangaben
System version==Version du syst&egrave;me
@ -1806,15 +1806,15 @@ You don't have the correct access right to perform this task.==Vous n'avez pas l
Please log in.==Veuillez vous connecter.
You can now go back to the <a href="Settings_p.html">Settings</a> page if you want to make more changes.==Vous pouvez maintenant retourner sur la page des <a href="Settings_p.html">param&egrave;tres</a> si vous voulez effectuer d'autres modifications.
See you soon!==&Agrave; bient&ocirc;t!
Application will terminate after working off all scheduled tasks.=L'application se terminera apr&egrave;s avoir achev&eacute; toutes les taches programm&eacute;es.
Application will terminate after working off all scheduled tasks\.==L'application se terminera apr&egrave;s avoir achev&eacute; toutes les t&acirc;ches planifi&eacute;es.
Please send us feed-back!==Envoyez-nous vos commentaires!
We don't track YaCy users, YaCy does not send 'home-pings', we do not even know how many people use YaCy as their private search engine.==Nous ne tra&ccedil;ons pas les utilisateurs de YaCy, YaCy n'envoie pas de "home-pings", nous ne savons m&ecirc;me pas combien de gens utilisent YaCy comme moteur de recherche.
Therefore we like to ask you: do you like YaCy? Will you use it again... if not, why? Is is possible that we change a bit to suit your needs?==C'est pourquoi nous appr&eacute;cierions beaucoup que vous nous disiez ce que vous pensez de YaCy. Appr&eacute;ciez-vous YaCy? Allez-vous l'utiliser &agrave; nouveau... si non, pourquoi? Nous pouvons peut-&ecirc;tre modifier YaCy pour qu'il r&eacute;ponde &agrave; vos besoins.
Therefore we like to ask you: do you like YaCy\? Will you use it again\.\.\. if not, why\? Is is possible that we change a bit to suit your needs\?==C'est pourquoi nous aimerions beaucoup que vous nous disiez ce que vous pensez de YaCy. Appr&eacute;ciez-vous YaCy? Allez-vous l'utiliser &agrave; nouveau... si non, pourquoi? Nous pouvons peut-&ecirc;tre modifier YaCy pour qu'il r&eacute;ponde &agrave; vos besoins.
Please send us feed-back about your experience with an==Vous pouvez nous faire parvenir vos commentaires avec un
<a href="http://sayat.me/YaCy" target="_blank">anonymous message</a>==<a href="http://sayat.me/YaCy" target="_blank">message anonynme</a>
or a</br>==ou un<br/>
anonymous message==message anonyme
or a<br/>==ou un<br/>
posting to our <a href="http://forum.yacy.de" target="_blank">web forums</a><br/>==message sur nos <a href="http://forum.yacy.de" target="_blank">forums</a><br/>
<a href="http://bugs.yacy.net" target="_blank">bug report</a>!==<a href="http://bugs.yacy.net" target="_blank">rapport de bogue</a>!
bug report==rapport de bogue
<h2>Professional Support</h2>==<h2>Support professionnel</h2>
If you are a professional user and you would like to use YaCy in your company in combination with consulting services by YaCy specialists, please see==Si vous souhaitez utiliser YaCy dans votre entreprise en association avec un service de consultations d'expertise par des sp&eacute;cialistes de YaCy, veuillez consulter
Just a moment, please!==Juste un instant, s'il vous pla&icirc;t!
@ -2078,7 +2078,7 @@ YaCy Interactive Search==YaCy Recherche interactive
>Name==>Nom
>Size==>Taille
>Date==>Date
kiosk mode==Kiosque Mode
kiosk mode==Mode Kiosque
>Link==>Lien
#-----------------------------
@ -2110,6 +2110,38 @@ Map \(c\) by==Carte (c) fournie par
and contributors, CC-BY-SA==et ses contributeurs, CC-BY-SA
#-----------------------------
#File: yacysearchitem.html
#---------------------------
"recommend"=="recommander"
"bookmark"=="ajouter aux favoris"
"delete"=="supprimer"
#-----------------------------
#File: yacysearchtrailer.html
#---------------------------
Your search is done using peers in the YaCy P2P network\.==Recherche effectu&eacute;e gr&acirc;ce aux noeuds du r&eacute;seau P2P YaCy.
You can switch to 'Stealth Mode' which will switch off P2P\, giving you full privacy\. Expect less results then, because then only your own search index is used\.==Vous pouvez passer en 'Mode furtif' ce qui d&eacute;sactivera le r&eacute;seau pair &agrave; pair et vous offrira une privatisation compl&egrave;te. Cependant vous obtiendrez probablement moins de r&eacute;sultats car la recherche sera alors bas&eacute;e uniquement sur votre propre index.
"Privacy"=="Privé"
&nbsp;Peer-to-Peer&nbsp;==&nbsp;Pair&nbsp;&agrave;&nbsp;pair&nbsp;
Stealth&nbsp;Mode==Mode&nbsp;furtif
Your search is done using only your own peer, locally\.==La recherche est r&eacute;alis&eacute;e uniquement sur les donn&eacute;es locales de votre noeud.
You can switch to 'Peer-to-Peer Mode' which will cause that your search is done using the other peers in the YaCy network\.==Vous pouvez passer en mode 'Pair &agrave; pair' dans lequel votre recherche sera bas&eacute;e sur les autres noeuds du r&eacute;seau YaCy.
"Peer-to-Peer"==Pair&nbsp;&agrave;&nbsp;pair
Context Ranking==Classement contextuel
Sort by Date==Trier par date
Video==Vid&eacute;o
>Apps==>Applications
<h3>Location</h3>==<h3>Lieu</h3>
show search results for "#\[query\]#" on map==Montrer sur la carte les r&eacute;sultats pour "#[query]#"
click to expand facet==cliquer pour r&eacute;v&eacute;ler cet aspect
>Provider==>Site
>Filetype==>Type de fichier
>Language==>Langue
>Name Space==>Espace de noms
>Author==>Auteur
>Collection==>Collection
#-----------------------------
### Subdirectory env/templates ###
#File: env/templates/header.template
#---------------------------

@ -674,7 +674,6 @@ public class CrawlQueues {
if (CrawlQueues.log.isFine()) {
CrawlQueues.log.fine("problem loading " + request.url().toString() + ": " + e.getMessage());
}
e.printStackTrace();
error = "load error - " + e.getMessage();
}
@ -693,7 +692,6 @@ public class CrawlQueues {
}
} catch (final Exception e) {
CrawlQueues.this.errorURL.push(request.url(), request.depth(), profile, FailCategory.TEMPORARY_NETWORK_FAILURE, e.getMessage() + " - in worker", -1);
ConcurrentLog.logException(e);
request.setStatus("worker-exception", WorkflowJob.STATUS_FINISHED);
} finally {
request = null;

@ -52,6 +52,7 @@ import net.yacy.kelondro.util.FileUtils;
import net.yacy.kelondro.util.Formatter;
import net.yacy.search.SwitchboardConstants;
import net.yacy.server.serverSwitch;
import net.yacy.utils.translation.SourceFileFilter;
import java.util.*;
@ -126,6 +127,13 @@ public class Translator {
return translateFile(sourceFile, destFile, loadTranslationsLists(translationFile).get(sourceFile.getName()));
}
/**
* Translate sourceFile to destFile using translationList.
* @param sourceFile file to translate
* @param destFile file to write
* @param translationList map of translations
* @return true when destFile was sucessfully written, false otherwise
*/
public static boolean translateFile(final File sourceFile, final File destFile, final Map<String, String> translationList){
StringBuilder content = new StringBuilder();
@ -147,11 +155,11 @@ public class Translator {
}
}
content = new StringBuilder(translate(content.toString(), translationList));
String processedContent = translate(content.toString(), translationList);
BufferedWriter bw = null;
try{
bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(destFile),"UTF-8"));
bw.write(content.toString());
bw.write(processedContent);
bw.close();
}catch(final IOException e){
return false;
@ -172,38 +180,28 @@ public class Translator {
public static boolean translateFiles(final File sourceDir, final File destDir, final File baseDir, final Map<String, Map<String, String>> translationLists, final String extensions){
destDir.mkdirs();
final File[] sourceFiles = sourceDir.listFiles();
final List<String> exts = ListManager.string2vector(extensions);
boolean rightExtension;
final File[] sourceFiles = sourceDir.listFiles(new SourceFileFilter(exts));
String relativePath;
for (final File sourceFile : sourceFiles) {
rightExtension=false;
for (final String ext : exts) {
if (sourceFile.getName().endsWith(ext)) {
rightExtension=true;
break;
}
}
if (rightExtension) {
try {
relativePath=sourceFile.getAbsolutePath().substring(baseDir.getAbsolutePath().length()+1); //+1 to get the "/"
relativePath = relativePath.replace(File.separatorChar, '/');
} catch (final IndexOutOfBoundsException e) {
ConcurrentLog.severe("TRANSLATOR", "Error creating relative Path for "+sourceFile.getAbsolutePath());
relativePath = "wrong path"; //not in translationLists
}
if (translationLists.containsKey(relativePath)) {
ConcurrentLog.info("TRANSLATOR", "Translating file: "+ relativePath);
if(!translateFile(
sourceFile,
new File(destDir, sourceFile.getName().replace('/', File.separatorChar)),
translationLists.get(relativePath)))
{
ConcurrentLog.severe("TRANSLATOR", "File error while translating file "+relativePath);
}
//}else{
//serverLog.logInfo("TRANSLATOR", "No translation for file: "+relativePath);
try {
relativePath=sourceFile.getAbsolutePath().substring(baseDir.getAbsolutePath().length()+1); //+1 to get the "/"
relativePath = relativePath.replace(File.separatorChar, '/');
} catch (final IndexOutOfBoundsException e) {
ConcurrentLog.severe("TRANSLATOR", "Error creating relative Path for "+sourceFile.getAbsolutePath());
relativePath = "wrong path"; //not in translationLists
}
if (translationLists.containsKey(relativePath)) {
ConcurrentLog.info("TRANSLATOR", "Translating file: "+ relativePath);
if(!translateFile(
sourceFile,
new File(destDir, sourceFile.getName().replace('/', File.separatorChar)),
translationLists.get(relativePath)))
{
ConcurrentLog.severe("TRANSLATOR", "File error while translating file "+relativePath);
}
//}else{
//serverLog.logInfo("TRANSLATOR", "No translation for file: "+relativePath);
}
}
return true;

@ -460,6 +460,7 @@ public class YaCyDefaultServlet extends HttpServlet {
} catch (IllegalArgumentException iae) {
if (!response.isCommitted()) {
response.sendError(HttpServletResponse.SC_BAD_REQUEST, iae.getMessage());
return false;
}
throw iae;
}
@ -1075,9 +1076,9 @@ public class YaCyDefaultServlet extends HttpServlet {
filecontent = item.getInputStream();
files.put(new AbstractMap.SimpleEntry<String, byte[]>(item.getFieldName(), FileUtils.read(filecontent)));
} catch (IOException e) {
ConcurrentLog.logException(e);
ConcurrentLog.info("FILEHANDLER", e.getMessage());
} finally {
if (filecontent != null) try {filecontent.close();} catch (IOException e) {ConcurrentLog.logException(e);}
if (filecontent != null) try {filecontent.close();} catch (IOException e) {ConcurrentLog.info("FILEHANDLER", e.getMessage());}
}
}
}
@ -1108,7 +1109,7 @@ public class YaCyDefaultServlet extends HttpServlet {
for (int j = 0; j < t; j++) p[j].join();
}
} catch (Exception ex) {
ConcurrentLog.logException(ex);
ConcurrentLog.info("FILEHANDLER", ex.getMessage());
}
}

@ -34,6 +34,7 @@ import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.FilenameFilter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@ -44,6 +45,7 @@ import java.io.UnsupportedEncodingException;
import java.io.Writer;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@ -55,13 +57,13 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Pattern;
import java.util.zip.GZIPInputStream;
import org.mozilla.intl.chardet.nsDetector;
import org.mozilla.intl.chardet.nsPSMDetector;
import net.yacy.cora.document.encoding.UTF8;
import net.yacy.cora.storage.Files;
import net.yacy.cora.util.ConcurrentLog;
import org.mozilla.intl.chardet.nsDetector;
import org.mozilla.intl.chardet.nsPSMDetector;
public final class FileUtils {
private static final int DEFAULT_BUFFER_SIZE = 1024; // this is also the maximum chunk size
@ -668,6 +670,23 @@ public final class FileUtils {
public static ArrayList<File> getDirsRecursive(final File dir, final String notdir) {
return getDirsRecursive(dir, notdir, true);
}
/**
* @param sourceDir source directory. Must be not null.
* @param notdir name of dir to exlcude. Can be null
* @param fileNameFilter filter to apply on file names. Can be null.
* @return list of all files passing fileFilter under sourceDir including sub directories
*/
public static List<File> getFilesRecursive(final File sourceDir, final String notdir, final FilenameFilter fileNameFilter) {
List<File> dirList = getDirsRecursive(sourceDir,
notdir);
dirList.add(sourceDir);
List<File> files = new ArrayList<>();
for (final File dir : dirList) {
Collections.addAll(files, dir.listFiles(fileNameFilter));
}
return files;
}
/**
* Returns a List of all dirs and subdirs as File Objects Warning: untested

@ -0,0 +1,111 @@
// ListNonTranslatedFiles.java
// -------------------------------------
// part of YACY
// (C) by Michael Peter Christen; mc@yacy.net
// first published on http://www.anomic.de
// Frankfurt, Germany, 2004
//
// $LastChangedDate$
// $LastChangedRevision$
// $LastChangedBy$
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package net.yacy.utils.translation;
import java.io.File;
import java.io.FilenameFilter;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import net.yacy.cora.util.ConcurrentLog;
import net.yacy.data.ListManager;
import net.yacy.data.Translator;
import net.yacy.kelondro.util.FileUtils;
/**
* Util to help identifying non translated files.
*
* @author luc
*
*/
public class ListNonTranslatedFiles extends TranslatorUtil {
/**
* Print on standard output result of search
* @param nonTranslatedFiles list of non translated files
*/
private static void printResults(List<File> nonTranslatedFiles) {
System.out.println(nonTranslatedFiles.size() + " files are not translated.");
for(File file : nonTranslatedFiles) {
System.out.println(file);
}
}
/**
* List all files from srcDir directory which are not translated using
* specified locale file with specified extensions. If no argument is set,
* default values are used.
*
* @param args
* runtime arguments<br/>
* <ul>
* <li>args[0] : source dir path</li>
* <li>args[1] : translation file path</li>
* <li>args[2] : extensions (separated by commas)</li>
* </ul>
*/
public static void main(String args[]) {
File sourceDir = getSourceDir(args);
Path sourcePath = sourceDir.toPath();
File translationFile = getTranslationFile(args);
List<String> extensions = ListManager
.string2vector(getExtensions(args));
FilenameFilter fileFilter = new SourceFileFilter(extensions);
String excludedDir = "locale";
ConcurrentLog.info("ListNonTranslatedFiles", "Listing non translated "
+ extensions + " files from " + sourceDir + " using "
+ translationFile);
try {
Set<String> translatedRelativePaths = Translator.loadTranslationsLists(translationFile).keySet();
List<File> srcFiles = FileUtils.getFilesRecursive(sourceDir, excludedDir, fileFilter);
List<File> nonTranslatedFiles = new ArrayList<>();
for(File srcFile : srcFiles) {
Path relativeSrcFile = sourcePath.relativize(srcFile.toPath());
if(!translatedRelativePaths.contains(relativeSrcFile.toString())) {
nonTranslatedFiles.add(srcFile);
}
}
printResults(nonTranslatedFiles);
} finally {
ConcurrentLog.shutdown();
}
}
}

@ -0,0 +1,83 @@
// SourceFileFilter.java
// -------------------------------------
// part of YACY
// (C) by Michael Peter Christen; mc@yacy.net
// first published on http://www.anomic.de
// Frankfurt, Germany, 2004
//
// $LastChangedDate$
// $LastChangedRevision$
// $LastChangedBy$
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package net.yacy.utils.translation;
import java.io.File;
import java.io.FilenameFilter;
import java.util.ArrayList;
import java.util.List;
/**
* File filter for source files to translate
*
* @author luc
*
*/
public class SourceFileFilter implements FilenameFilter {
/** Extensions required to pass filter */
private List<String> extensions;
/**
* Contructor with extensions
*
* @param extensions
* extensions required. When this list is null or empty, filter
* let pass all files.
*/
public SourceFileFilter(List<String> extensions) {
if (extensions == null) {
this.extensions = new ArrayList<>();
} else {
this.extensions = new ArrayList<>(extensions);
}
}
/**
* @param file
* file to check
* @return true when file name ends with one of the extensions list or
* extensions list is empty
*/
@Override
public boolean accept(File dir, String name) {
boolean accepted = false;
if (name != null) {
if (extensions.size() == 0) {
accepted = true;
} else {
for (String ext : extensions) {
if (name.endsWith(ext)) {
accepted = true;
break;
}
}
}
}
return accepted;
}
}

@ -0,0 +1,100 @@
// TranslateAll.java
// -------------------------------------
// part of YACY
// (C) by Michael Peter Christen; mc@yacy.net
// first published on http://www.anomic.de
// Frankfurt, Germany, 2004
//
// $LastChangedDate$
// $LastChangedRevision$
// $LastChangedBy$
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package net.yacy.utils.translation;
import java.io.File;
import net.yacy.cora.util.ConcurrentLog;
import net.yacy.data.Translator;
/**
* Util to translate all files without launching full YaCy application.
*
* @author luc
*
*/
public class TranslateAll extends TranslatorUtil {
/**
* Translate all files from srcDir directory into dstDir directory using
* specified locale file with specified extensions. If no argument is set,
* default values are used.
*
* @param args
* runtime arguments<br/>
* <ul>
* <li>args[0] : source dir path</li>
* <li>args[1] : destination dir path</li>
* <li>args[2] : translation file path</li>
* <li>args[3] : extensions (separated by commas)</li>
* </ul>
*/
public static void main(String args[]) {
File sourceDir = getSourceDir(args);
File destDir = getDestDir(args);
File translationFile = getTranslationFile(args);
String extensions = getExtensions(args);
ConcurrentLog.info("TranslateAll", "Translating " + extensions
+ " files from " + sourceDir + " to " + destDir + " using "
+ translationFile);
try {
Translator.translateFilesRecursive(sourceDir, destDir,
translationFile, extensions, "locale");
} finally {
ConcurrentLog.shutdown();
}
}
/**
* @param args
* main parameters
* @return translation source dir from parameters or default
* @throws IllegalArgumentException
* when no parameters is set and default is not found
*/
protected static File getDestDir(String[] args) {
File destDir;
if (args.length > 1) {
destDir = new File(args[1]);
} else {
String tmpDir = System.getProperty("java.io.tmpdir");
if (tmpDir == null) {
throw new IllegalArgumentException(
"No destination dir specified, and default not found");
}
destDir = new File(tmpDir + File.separator
+ TranslateAll.class.getCanonicalName());
}
return destDir;
}
}

@ -0,0 +1,116 @@
// TranslateAll.java
// -------------------------------------
// part of YACY
// (C) by Michael Peter Christen; mc@yacy.net
// first published on http://www.anomic.de
// Frankfurt, Germany, 2004
//
// $LastChangedDate$
// $LastChangedRevision$
// $LastChangedBy$
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package net.yacy.utils.translation;
import java.io.File;
import java.util.Locale;
import net.yacy.yacy;
import net.yacy.data.Translator;
/**
* Base class for launching a {@link Translator} method without full YaCy
* application started.
*
* @author luc
*
*/
public abstract class TranslatorUtil {
/**
* @param args
* main parameters
* @return translation source dir from parameters or default
* (workingDir/htroot)
* @throws IllegalArgumentException
* when no parameters is set and default is not found
*/
protected static File getSourceDir(String[] args) {
File sourceDir;
if (args.length > 0) {
sourceDir = new File(args[0]);
} else {
String workingDir = System.getProperty("user.dir");
if (workingDir == null) {
throw new IllegalArgumentException(
"No translation file specified, and default not found");
}
sourceDir = new File(workingDir, "htroot");
if (!sourceDir.exists() && !sourceDir.isDirectory()) {
throw new IllegalArgumentException(
"No translation file specified, and default not found : "
+ sourceDir.getPath());
}
}
return sourceDir;
}
/**
* @param args
* main parameters
* @return translation file from parameters or default (base on current
* Locale)
* @throws IllegalArgumentException
* when no parameters is set and default is not found
*/
protected static File getTranslationFile(String[] args) {
File translationFile;
if (args.length > 2) {
translationFile = new File(args[2]);
} else {
String workingDir = System.getProperty("user.dir");
if (workingDir == null) {
throw new IllegalArgumentException(
"No translation file specified, and default not found");
}
translationFile = new File(workingDir, "locales" + File.separator
+ Locale.getDefault().getLanguage() + ".lng");
if (!translationFile.exists()) {
throw new IllegalArgumentException(
"No translation file specified, and default not found : "
+ translationFile.getPath());
}
}
return translationFile;
}
/**
* @param args
* main parameters
* @return extensions list from parameters or default (same as used in
* {@link yacy})
*/
protected static String getExtensions(String[] args) {
String extensions;
if (args.length > 3) {
extensions = args[3];
} else {
extensions = "html,template,inc";
}
return extensions;
}
}
Loading…
Cancel
Save