Skip to content
This repository has been archived by the owner on Jul 18, 2024. It is now read-only.

Commit

Permalink
Joins suffixes that are separated during translation
Browse files Browse the repository at this point in the history
  • Loading branch information
Lawrr committed Dec 27, 2016
1 parent 434b2ef commit 4d8d722
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions JapaneseToRomajiFilenameConverter/Converter/TextToken.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,9 @@ private string FormatTranslation(string translatedText,

// Decapitalise particles
translatedText = TextTranslator.LowercaseParticles(translatedText, particles);

// Attach suffixes
translatedText = TextTranslator.attachSuffixes(translatedText);

// Trim and join
outText = Prefix + translatedText.Trim();
Expand Down
13 changes: 13 additions & 0 deletions JapaneseToRomajiFilenameConverter/Converter/TextTranslator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ public class TextTranslator {

private static char MapSplitChar = ':';

private static List<string> Suffixes = new List<string>() {
"Iru"
};

public static string GetTranslatorUrl(string text, string languagePair = LanguagePair) {
return string.Format(TranslatorUrl, text, languagePair);
}
Expand Down Expand Up @@ -98,5 +102,14 @@ public static bool IsTranslated(string text) {
return !text.Any(c => Unicode.IsJapanese(c.ToString()));
}

public static string attachSuffixes(string text) {
foreach (string suffix in Suffixes) {
text = Regex.Replace(text,
@"\s" + suffix + @"\b",
suffix.ToLower());
}

return text;
}
}
}

0 comments on commit 4d8d722

Please sign in to comment.