Preparing for the transition to REST API
This commit is contained in:
@ -32,29 +32,33 @@ public class Translation {
|
||||
this.jdbcTemplate = jdbcTemplate;
|
||||
}
|
||||
|
||||
public String trt(String text){
|
||||
String sql = """
|
||||
select
|
||||
translation
|
||||
from
|
||||
main._translations
|
||||
where
|
||||
del=false
|
||||
and language_id=:language_id
|
||||
and identifier=:identifier;
|
||||
""";
|
||||
MapSqlParameterSource parameters = new MapSqlParameterSource();
|
||||
parameters.addValue("language_id", language_id);
|
||||
parameters.addValue("identifier", text);
|
||||
List<String> ret = jdbcTemplate.query(sql, parameters, new tools.DBTools.JsonRowMapper());
|
||||
int i = 0;
|
||||
for (i = 0; i < ret.size(); i++) {
|
||||
JSONObject json = new JSONObject(ret.get(i));
|
||||
text = json.getString("translation");
|
||||
}
|
||||
if(i==0){
|
||||
text = text.replace("_", " ");
|
||||
public String trt(boolean translate,String text){
|
||||
if(translate) {
|
||||
String sql = """
|
||||
select
|
||||
translation
|
||||
from
|
||||
main._translations
|
||||
where
|
||||
del=false
|
||||
and language_id=:language_id
|
||||
and identifier=:identifier;
|
||||
""";
|
||||
MapSqlParameterSource parameters = new MapSqlParameterSource();
|
||||
parameters.addValue("language_id", language_id);
|
||||
parameters.addValue("identifier", text);
|
||||
List<String> ret = jdbcTemplate.query(sql, parameters, new tools.DBTools.JsonRowMapper());
|
||||
int i = 0;
|
||||
for (i = 0; i < ret.size(); i++) {
|
||||
JSONObject json = new JSONObject(ret.get(i));
|
||||
text = json.getString("translation");
|
||||
}
|
||||
if(i==0){
|
||||
text = text.replace("_", " ");
|
||||
}
|
||||
return text;
|
||||
}else {
|
||||
return text;
|
||||
}
|
||||
return text;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user