Skip to content

Commit

Permalink
add work with multi names
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor authored and Victor committed Jan 31, 2023
1 parent 3816a8a commit c53264a
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions transliteration/src/main/java/transliteration/Transliteration.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ private String convertSymbol(final String symbol) {
}

int n = masLinks.length;
for (int i = 1; i < n; i++) {
int i;
for (i = 1; i < n; i++) {

String[] link = masLinks[i];

Expand All @@ -56,6 +57,11 @@ private String convertSymbol(final String symbol) {

}

if (i == n) {
firstSymbol = true;
result = "";
}

return result;
}

Expand Down Expand Up @@ -148,15 +154,26 @@ private String getTransLitLine(final String line) {
firstSymbol = true;

String lowerLine = line.toLowerCase();
String prepareLine = lowerLine.replace(masLinks[0][0], masLinks[0][1]);
String preparedLine = lowerLine.replace(masLinks[0][0], masLinks[0][1]);

resultLine.append(convertSymbol(prepareLine.charAt(0)));
resultLine.append(convertSymbol(preparedLine.charAt(0)));

firstSymbol = false;

int n = prepareLine.length();
int n = preparedLine.length();
for (int i = 1; i < n; i++) {
resultLine.append(convertSymbol(prepareLine.charAt(i)));

resultLine.append(convertSymbol(preparedLine.charAt(i)));

if (firstSymbol) {

i++;
if (i < n) {
resultLine.append(convertSymbol(preparedLine.charAt(i)));
}

firstSymbol = false;
}
}

return resultLine.toString();
Expand Down

0 comments on commit c53264a

Please sign in to comment.