Index: /SRUAggregator/trunk/pom.xml
===================================================================
--- /SRUAggregator/trunk/pom.xml	(revision 6096)
+++ /SRUAggregator/trunk/pom.xml	(revision 6097)
@@ -8,5 +8,5 @@
 	<groupId>eu.clarin.sru.fcs</groupId>
 	<artifactId>Aggregator2</artifactId>
-	<version>2.0.0-beta-28</version>
+	<version>2.0.0-beta-29</version>
 	<name>FCS Aggregator</name>
 
Index: /SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/search/Result.java
===================================================================
--- /SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/search/Result.java	(revision 6096)
+++ /SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/search/Result.java	(revision 6097)
@@ -73,4 +73,5 @@
 
 	void addRecord(SRURecord record) {
+//		TODO(edima): use response.getNextRecordPosition()
 		endpointReturnedRecords.getAndIncrement();
 		if (record.isRecordSchema(ClarinFCSRecordData.RECORD_SCHEMA)) {
Index: /SRUAggregator/trunk/src/main/resources/assets/js/main.jsx
===================================================================
--- /SRUAggregator/trunk/src/main/resources/assets/js/main.jsx	(revision 6096)
+++ /SRUAggregator/trunk/src/main/resources/assets/js/main.jsx	(revision 6097)
@@ -3,5 +3,5 @@
 "use strict";
 
-var VERSION = "VERSION 2.0.0-beta-28";
+var VERSION = "VERSION 2.0.0-beta-29";
 var URLROOT = "/Aggregator-testing";
 
Index: /SRUAggregator/trunk/src/main/resources/assets/js/search.js
===================================================================
--- /SRUAggregator/trunk/src/main/resources/assets/js/search.js	(revision 6096)
+++ /SRUAggregator/trunk/src/main/resources/assets/js/search.js	(revision 6097)
@@ -297,8 +297,10 @@
 	},
 
-	getExportParams: function(corpusId, format) {
+	getExportParams: function(corpusId, format, filterLanguage) {
 		var params = corpusId ? {corpusId:corpusId}:{};
 		if (format) params.format = format;
-		if (this.state.languageFilter === 'byGuess' || this.state.languageFilter === 'byMetaAndGuess') {
+		if (filterLanguage) {
+			params.filterLanguage = filterLanguage;
+		} else if (this.state.languageFilter === 'byGuess' || this.state.languageFilter === 'byMetaAndGuess') {
 			params.filterLanguage = this.state.language[0];
 		}
@@ -307,10 +309,11 @@
 
 	getDownloadLink: function(corpusId, format) {
-		return 'rest/search/'+this.state.searchId+'/download?' + this.getExportParams(corpusId, format);
-	},
-
-	getToWeblichtLink: function(corpusId) {
-		var params = corpusId ? {corpusId:corpusId}:{};
-		return 'rest/search/'+this.state.searchId+'/toWeblicht?' + this.getExportParams(corpusId);
+		return 'rest/search/'+this.state.searchId+'/download?' + 
+			this.getExportParams(corpusId, format);
+	},
+
+	getToWeblichtLink: function(corpusId, forceLanguage) {
+		return 'rest/search/'+this.state.searchId+'/toWeblicht?' + 
+			this.getExportParams(corpusId, null, forceLanguage);
 	},
 
@@ -469,5 +472,5 @@
 										 	layers.map(function(l) { 
 												var cls = l.disabled ? 'disabled':'';
-												var handler = function() { if (!l.disabled) this.setLayer(l.id); };
+												var handler = function() { if (!l.disabled) this.setLayer(l.id); }.bind(this);
 												return React.createElement("li", {key: l.id, className: cls}, " ", React.createElement("a", {tabIndex: "-1", href: "#", 
 													onClick: handler}, " ", l.name, " "));
@@ -753,5 +756,5 @@
 	},
 
-	renderToWeblichtLinks: function(corpusId, error) {
+	renderToWeblichtLinks: function(corpusId, forceLanguage, error) {
 		return (
 			React.createElement("div", {className: "dropdown"}, 
@@ -765,5 +768,5 @@
 						error ? 
 							React.createElement("div", {className: "alert alert-danger", style: {margin:10, width:200}}, error) :
-							React.createElement("a", {href: this.props.getToWeblichtLink(corpusId), target: "_blank"}, " ", 
+							React.createElement("a", {href: this.props.getToWeblichtLink(corpusId, forceLanguage), target: "_blank"}, " ", 
 								"Send to Weblicht")
 						
@@ -834,7 +837,23 @@
 			return false;
 		}
-		var wlerror = null;
+
+		var forceLanguage = null, wlerror = null;
 		if (this.props.weblichtLanguages.indexOf(this.props.searchedLanguage[0]) < 0) {
-			wlerror = "Cannot use WebLicht: unsupported language";
+			// the search language is either AnyLanguage or unsupported 
+			if (this.props.searchedLanguage[0] === multipleLanguageCode) {
+				if (corpusHit.corpus.languages && corpusHit.corpus.languages.length === 1) {
+					forceLanguage = corpusHit.corpus.languages[0];
+				} else {
+					var langs = corpusHit.kwics.map(function(kwic) {return kwic.language;});
+					langs = _.uniq(langs.filter(function(l){ return l !== null; }));
+					console.log("languages:", langs);
+					if (langs.length === 1) {
+						forceLanguage = langs[0];
+					}
+				}
+			} 
+			if (!forceLanguage) {
+				wlerror = "Cannot use WebLicht: unsupported language ("+this.props.searchedLanguage[1]+")";
+			}
 		}
 		var corpus = corpusHit.corpus;
@@ -852,5 +871,5 @@
 									 this.renderDisplayKWIC(), 
 									React.createElement("div", {className: "inline"}, " ", this.renderDownloadLinks(corpusHit.corpus.id), " "), 
-									React.createElement("div", {className: "inline"}, " ", this.renderToWeblichtLinks(corpus.id, wlerror), " ")
+									React.createElement("div", {className: "inline"}, " ", this.renderToWeblichtLinks(corpus.id, forceLanguage, wlerror), " ")
 								)
 							), 
@@ -991,4 +1010,14 @@
 		return ret;
 	},
+
+	uniq: function(a) {
+		var r = [];
+		for (var i = 0; i < a.length; i++) {
+			if (r.indexOf(a[i]) < 0) {
+				r.push(a[i]);
+			}
+		}
+		return r;
+	},
 };
 
Index: /SRUAggregator/trunk/src/main/resources/assets/js/search.jsx
===================================================================
--- /SRUAggregator/trunk/src/main/resources/assets/js/search.jsx	(revision 6096)
+++ /SRUAggregator/trunk/src/main/resources/assets/js/search.jsx	(revision 6097)
@@ -297,8 +297,10 @@
 	},
 
-	getExportParams: function(corpusId, format) {
+	getExportParams: function(corpusId, format, filterLanguage) {
 		var params = corpusId ? {corpusId:corpusId}:{};
 		if (format) params.format = format;
-		if (this.state.languageFilter === 'byGuess' || this.state.languageFilter === 'byMetaAndGuess') {
+		if (filterLanguage) {
+			params.filterLanguage = filterLanguage;
+		} else if (this.state.languageFilter === 'byGuess' || this.state.languageFilter === 'byMetaAndGuess') {
 			params.filterLanguage = this.state.language[0];
 		}
@@ -307,10 +309,11 @@
 
 	getDownloadLink: function(corpusId, format) {
-		return 'rest/search/'+this.state.searchId+'/download?' + this.getExportParams(corpusId, format);
-	},
-
-	getToWeblichtLink: function(corpusId) {
-		var params = corpusId ? {corpusId:corpusId}:{};
-		return 'rest/search/'+this.state.searchId+'/toWeblicht?' + this.getExportParams(corpusId);
+		return 'rest/search/'+this.state.searchId+'/download?' + 
+			this.getExportParams(corpusId, format);
+	},
+
+	getToWeblichtLink: function(corpusId, forceLanguage) {
+		return 'rest/search/'+this.state.searchId+'/toWeblicht?' + 
+			this.getExportParams(corpusId, null, forceLanguage);
 	},
 
@@ -469,5 +472,5 @@
 										{ 	layers.map(function(l) { 
 												var cls = l.disabled ? 'disabled':'';
-												var handler = function() { if (!l.disabled) this.setLayer(l.id); };
+												var handler = function() { if (!l.disabled) this.setLayer(l.id); }.bind(this);
 												return <li key={l.id} className={cls}> <a tabIndex="-1" href="#" 
 													onClick={handler}> {l.name} </a></li>;
@@ -753,5 +756,5 @@
 	},
 
-	renderToWeblichtLinks: function(corpusId, error) {
+	renderToWeblichtLinks: function(corpusId, forceLanguage, error) {
 		return (
 			<div className="dropdown">
@@ -765,5 +768,5 @@
 						{error ? 
 							<div className="alert alert-danger" style={{margin:10, width:200}}>{error}</div> :
-							<a href={this.props.getToWeblichtLink(corpusId)} target="_blank">{" "} 
+							<a href={this.props.getToWeblichtLink(corpusId, forceLanguage)} target="_blank">{" "} 
 								Send to Weblicht</a>
 						}
@@ -834,7 +837,23 @@
 			return false;
 		}
-		var wlerror = null;
+
+		var forceLanguage = null, wlerror = null;
 		if (this.props.weblichtLanguages.indexOf(this.props.searchedLanguage[0]) < 0) {
-			wlerror = "Cannot use WebLicht: unsupported language";
+			// the search language is either AnyLanguage or unsupported 
+			if (this.props.searchedLanguage[0] === multipleLanguageCode) {
+				if (corpusHit.corpus.languages && corpusHit.corpus.languages.length === 1) {
+					forceLanguage = corpusHit.corpus.languages[0];
+				} else {
+					var langs = corpusHit.kwics.map(function(kwic) {return kwic.language;});
+					langs = _.uniq(langs.filter(function(l){ return l !== null; }));
+					console.log("languages:", langs);
+					if (langs.length === 1) {
+						forceLanguage = langs[0];
+					}
+				}
+			} 
+			if (!forceLanguage) {
+				wlerror = "Cannot use WebLicht: unsupported language ("+this.props.searchedLanguage[1]+")";
+			}
 		}
 		var corpus = corpusHit.corpus;
@@ -852,5 +871,5 @@
 									{ this.renderDisplayKWIC() }
 									<div className="inline"> {this.renderDownloadLinks(corpusHit.corpus.id)} </div>
-									<div className="inline"> {this.renderToWeblichtLinks(corpus.id, wlerror)} </div>
+									<div className="inline"> {this.renderToWeblichtLinks(corpus.id, forceLanguage, wlerror)} </div>
 								</div>
 							</div>
@@ -991,4 +1010,14 @@
 		return ret;
 	},
+
+	uniq: function(a) {
+		var r = [];
+		for (var i = 0; i < a.length; i++) {
+			if (r.indexOf(a[i]) < 0) {
+				r.push(a[i]);
+			}
+		}
+		return r;
+	},
 };
 
