Skip to content

Commit

Permalink
Fixed Link generation bug
Browse files Browse the repository at this point in the history
  • Loading branch information
NickKvizhinadze committed Nov 16, 2020
1 parent b7ca8ad commit fa1d220
Showing 1 changed file with 63 additions and 1 deletion.
64 changes: 63 additions & 1 deletion DotNetHelpers/SlagGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,50 @@

namespace DotNetHelpers
{
/// <summary>
/// Generate Slags
/// </summary>
public static class SlagGenerator
{
#region Fields
private static readonly Dictionary<char, char> Dict = new Dictionary<char, char>
{
{'ა', 'a'},
{'ბ', 'b'},
{'გ', 'g'},
{'დ', 'd'},
{'ე', 'e'},
{'ვ', 'v'},
{'ზ', 'z'},
{'თ', 'T'},
{'ი', 'i'},
{'კ', 'k'},
{'ლ', 'l'},
{'მ', 'm'},
{'ნ', 'n'},
{'ო', 'o'},
{'პ', 'p'},
{'ჟ', 'J'},
{'რ', 'r'},
{'ს', 's'},
{'ტ', 't'},
{'უ', 'u'},
{'ფ', 'f'},
{'ქ', 'q'},
{'ღ', 'R'},
{'ყ', 'y'},
{'შ', 'S'},
{'ჩ', 'C'},
{'ც', 'c'},
{'ძ', 'Z'},
{'წ', 'w'},
{'ჭ', 'W'},
{'ხ', 'x'},
{'ჯ', 'j'},
{'ჰ', 'h'}
};


private static readonly List<string> PreventedChars = new List<string>
{
"#",
Expand Down Expand Up @@ -48,8 +89,29 @@ public static string GenerateLink(this string source)
source = PreventedChars.Aggregate(source, (current, c) => current.Replace(c, ""));
source = source.Replace(' ', '-');

return source.ToLower();
return Translate(source.ToLower());
}
#endregion

#region Private Methods
private static string Translate(string param)
{
var result = "";
foreach (var c in param)
{
if (Dict.ContainsKey(c))
{
result += Dict[c];
}
else
{
result += c;
}
}

return result;
}

#endregion
}
}

0 comments on commit fa1d220

Please sign in to comment.