Add translator to poyo

This commit is contained in:
2025-05-16 11:27:16 +02:00
parent 871f46b996
commit f83f59c05a
10 changed files with 424 additions and 410 deletions

View File

@@ -8,7 +8,7 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\PoyoLang.Dictionary\PoyoLang.Dictionary.csproj" />
<ProjectReference Include="..\PoyoLang.Translator\PoyoLang.Translator.csproj" />
</ItemGroup>
</Project>

View File

@@ -1,63 +1,14 @@
// See https://aka.ms/new-console-template for more information
using System.Text;
using PoyoLang.Dictionary;
using PoyoLang.Translator;
var dictionary = new Dictionary<string, string>();
Console.OutputEncoding = Encoding.UTF8;
var text = "Lorem ipsum dolor sit amet";
var text = "Immutable abstract representation of a span of text. For example, in an error diagnostic that reports a location, it could come from a parsed string, text from a tool editor buffer, etc.";
var output = new StringBuilder(text.Length);
var span = text.AsSpan();
NextLetter(ref span, output);
Console.Write(output.ToString());
void NextLetter(ref ReadOnlySpan<char> text, StringBuilder output)
{
if (text.Length > 0)
{
var isCaps = char.IsUpper(text[0]);
switch (text[0])
{
case 'a' or 'A':
if (text.Length > 1)
{
switch (text[1])
{
case 'm':
text = text[2..];
output.Append(isCaps ? "Payo" : "payo");
return;
}
}
text = text[1..];
output.Append(isCaps ? "Piyo" : "piyo");
return;
case 'b' or 'B':
text = text[1..];
output.Append(isCaps ? "Pïyo" : "pïyo");
return;
}
text = text[1..];
output.Append(text[0]);
}
}
var translator = new PoyoLangTranslator();
var translated = translator.TranslateToPoyo(text);
Console.WriteLine(translated);