Skip to content

Commit

Permalink
Merge pull request #66 from nsaiisasidhar/#50-Add-Italian
Browse files Browse the repository at this point in the history
Add Italian #50
  • Loading branch information
nicolas-raoul authored Mar 28, 2018
2 parents 755f23f + 79f2db8 commit d32c632
Show file tree
Hide file tree
Showing 2 changed files with 109 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.wikivoyage.listings.language.russian.Russian;
import org.wikivoyage.listings.language.french.French;
import org.wikivoyage.listings.language.espanol.Espanol;
import org.wikivoyage.listings.language.italian.Italian;

import java.util.LinkedList;
import java.util.List;
Expand All @@ -18,7 +19,8 @@ public class Languages {
new Russian(),
new French(),
new German(),
new Espanol()
new Espanol(),
new Italian()
};
private static Language defaultLanguage = languages[0];

Expand Down
106 changes: 106 additions & 0 deletions src/main/java/org/wikivoyage/listings/language/italian/Italian.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
package org.wikivoyage.listings.language.italian;

import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;

import org.wikivoyage.listings.entity.Listing;
import org.wikivoyage.listings.input.template.TemplateNode;
import org.wikivoyage.listings.input.template.TemplateToStringConverter;
import org.wikivoyage.listings.language.Language;
/*import org.wikivoyage.listings.language.es.template.DeadLinkTemplateToStringConverter;*/

/**
* The specificities of the Italian edition of Wikivoyage.
*/
public class Italian implements Language
{
@Override
public String getLanguageCode() {
return "it";
}

/**
* All listings that can be found in the Italian edition of Wikivoyage.
*/
@Override
public HashSet<String> getListingTemplates()
{
HashSet<String> listingTemplates = new HashSet<>();

listingTemplates.add("listing");
listingTemplates.add("see");
listingTemplates.add("do");
listingTemplates.add("buy");
listingTemplates.add("eat");
listingTemplates.add("drink");
listingTemplates.add("sleep");

return listingTemplates;
}

/**
* The name of the place, which is the only strictly required element.
*/
@Override
public String getNameElement() {
return "nome";
}

/**
* Convert listing template into a WikivoyagePOI object.
*/
@Override
public Listing parseListingTemplate(String article, TemplateNode template, String poiType) {
// Type
if (poiType==null) {
if (template.getNameLowercase().equals("listing")) {
if (template.hasArgument("tipo")) {
poiType = template.getArgument("tipo");
} else {
poiType = "listing";
}
} else {
poiType = template.getNameLowercase();
}
}

return new Listing(
article,
poiType,
template.getArgument("nome"),
template.getArgument("alt"),
template.getArgument("sito"),
template.getArgument("wikidata"),
template.getArgument("wikipedia"),
template.getArgument("indirizzo"),
template.getArgument("indicazioni"),
template.getArgument("tel"),
template.getArgument("numero verde"),
template.getArgument("email"),
template.getArgument("fax"),
template.getArgument("orari"),
template.getArgument("checkin"),
template.getArgument("checkout"),
template.getArgument("immagine"),
template.getArgument("prezzo"),
template.getArgument("lat"),
template.getArgument("long"),
"", // No hay un parámetro "Wi-Fi"
"", // No hay un parámetro "accesibilidad"
template.getArgument("lastedit"),
template.getArgument("descrizione"),
getLanguageCode()
);
}

@Override
public List<TemplateToStringConverter> getTemplateConverters() {
return new LinkedList<>();
}

@Override
public String getFlagElement() {
return "bandiera";
}
}

0 comments on commit d32c632

Please sign in to comment.