Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[VIVO-1900] i18n: added empty check for getCountry, fixing bug with spanish label (es) #181

Merged
merged 3 commits into from
Aug 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,10 @@ protected void doTemplate(VitroRequest vreq, HttpServletResponse response,

templateDataModel.put("body", bodyString);

String lang = vreq.getLocale().getLanguage() + "-"+vreq.getLocale().getCountry();
String lang = vreq.getLocale().getLanguage();
if (!vreq.getLocale().getCountry().isEmpty()) {
lang += "-" + vreq.getLocale().getCountry();
}
templateDataModel.put("country", lang);

// Tell the template and any directives it uses that we're processing a page template.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ private String renderShortView(String individualUri, String vclassName) {
modelMap.put("individual",
IndividualTemplateModelBuilder.build(individual, vreq));
modelMap.put("vclass", vclassName);
String langCtx = vreq.getLocale().getLanguage() + "-"+vreq.getLocale().getCountry(); //UQAM-Linguistic-Management build the linguistic context
String langCtx = vreq.getLocale().getLanguage(); //UQAM-Linguistic-Management build the linguistic context
if (!vreq.getLocale().getCountry().isEmpty()) {
langCtx += "-" + vreq.getLocale().getCountry();
}
modelMap.put("langCtx", langCtx); // UQAM-Linguistic-Management add the linguistic context to map
ShortViewService svs = ShortViewServiceSetup.getService(ctx);
return svs.renderShortView(individual, ShortViewContext.BROWSE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,10 @@ public void addLiteralToForm(EditConfigurationVTwo editConfig, FieldVTwo field,
String rangeLang = field.getRangeLang(); //UQAM Default value
try {
if (_vreq != null ) {
rangeLang = _vreq.getLocale().getLanguage() + "-"+_vreq.getLocale().getCountry();
rangeLang = _vreq.getLocale().getLanguage();
if (!_vreq.getLocale().getCountry().isEmpty()) {
rangeLang += "-" + _vreq.getLocale().getCountry();
}
}

} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,10 @@ protected void subInValuesToN3(
*/

if (XSD.xstring.getURI().equals(aLiteratDT) || RDF.dtLangString.getURI().equals(aLiteratDT)) {
String lang = vreq.getLocale().getLanguage() + "-" + vreq.getLocale().getCountry();
String lang = vreq.getLocale().getLanguage();
if (!vreq.getLocale().getCountry().isEmpty()) {
lang += "-" + vreq.getLocale().getCountry();
}
newLiteral = ResourceFactory.createLangLiteral(aText, lang);
} else {
newLiteral = ResourceFactory.createTypedLiteral(aText, aLiteral.getDatatype());
Expand Down Expand Up @@ -304,11 +307,14 @@ protected AdditionsAndRetractions parseN3ToChange(
List<Model> retracts = new ArrayList<Model>();
if( requiredDels != null && optionalDels != null ){
String lingCxt=null;
//UQAM Taking into account the linguistic context in retract
try {
lingCxt = vreq.getLocale().getLanguage() + "-"+vreq.getLocale().getCountry();
} catch (Exception e) {
}
//UQAM Taking into account the linguistic context in retract
try {
lingCxt = vreq.getLocale().getLanguage();
if (!vreq.getLocale().getCountry().isEmpty()) {
lingCxt += "-" + vreq.getLocale().getCountry();
}
} catch (Exception e) {
}
retracts.addAll( parseN3ToRDF(requiredDels, REQUIRED, lingCxt) );
retracts.addAll( parseN3ToRDF(optionalDels, OPTIONAL, lingCxt) );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,10 @@ public FakeVivoPeopleDataGetter(VitroRequest vreq, String individualUri) {
this.individualUri = individualUri;
this.vreq = vreq;
this.ctx = vreq.getSession().getServletContext();
this.langCtx = vreq.getLocale().getLanguage() + "-"+vreq.getLocale().getCountry(); // UQAM-Optimization add the linguistic context
this.langCtx = vreq.getLocale().getLanguage(); // UQAM-Optimization add the linguistic context
if (!vreq.getLocale().getCountry().isEmpty()) {
this.langCtx += "-" + vreq.getLocale().getCountry();
}
}

@Override
Expand Down