
com.antiaction.raptor.i18n.I18N Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of raptor-dbl Show documentation
Show all versions of raptor-dbl Show documentation
Raptor database layer implementation.
The newest version!
/*
* Created on 03/04/2010
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package com.antiaction.raptor.i18n;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public abstract class I18N {
public int translation_id;
public Map idstrMap = new HashMap();
public List idstrList = new ArrayList();
public Map> langIdMap = new HashMap>();
public abstract String getTranslated(int language_id, String text_idstring);
public abstract void flush_changes(Connection conn);
public abstract void setTranslated(Connection conn, int language_id, String text_idstring, String new_translated_text);
public String parameterize(String text, String[] parameters) {
if ( parameters == null || parameters.length == 0 ) {
return text;
}
else {
int idx = 0;
int pidx = text.indexOf( '%' );
char c;
if ( pidx >= 0 ) {
StringBuffer ptext = new StringBuffer();
while ( idx < text.length() ) {
ptext.append( text, idx, pidx );
idx = ++pidx;
if ( idx < text.length() ) {
c = text.charAt( idx++ );
if ( c >= '1' && c <= '9' ) {
pidx = c - '1';
if ( pidx >= 0 && pidx < parameters.length ) {
ptext.append( parameters[ pidx ] );
}
else {
ptext.append( '%' );
ptext.append( c );
}
}
else if ( c == '%' ) {
ptext.append( '%' );
}
else {
ptext.append( '%' );
ptext.append( c );
}
pidx = text.indexOf( '%', idx );
if ( pidx == -1 ) {
ptext.append( text.substring( idx, text.length() ) );
idx = text.length();
}
}
else {
ptext.append( '%' );
}
}
return ptext.toString();
}
else {
return text;
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy