Hello ison, the truth is, I do not understand much about programming, but I do understand Spanish and there is the possibility of adding this to the code, it will work for both languages of Spanish (Latin American and Spain)
We need plural form for indefite and definite articles
We need plural form for indefite and definite articles
Code Select
public class LanguageWorker_Spanish : LanguageWorker
{
public override string WithIndefiniteArticle(string str, Gender gender, bool plural = false, bool name = false)
{
//Names don't get articles
if( name )
return str;
if( plural )
return (gender == Gender.Female ? "unas " : "unos ") + str;
else
return (gender == Gender.Female ? "una " : "un ") + str;
}
public override string WithDefiniteArticle(string str, Gender gender, bool plural = false, bool name = false)
{
//Names don't get articles
if( name )
return str;
if( plural )
return (gender == Gender.Female ? "las " : "los ") + str;
else
return (gender == Gender.Female ? "la " : "el ") + str;
}
public override string OrdinalNumber(int number, Gender gender = Gender.None)
{
return number + ".º";
}
public override string Pluralize(string str, Gender gender, int count = -1)
{
if( str.NullOrEmpty() )
return str;
char last = str[str.Length - 1];
char oneBeforeLast = str.Length >= 2 ? str[str.Length - 2] : '\0';
if( IsVowel(last) )
{
if( str == "sí" )
return "síes";
else if( last == 'í' || last == 'ú' || last == 'Í' || last == 'Ú' )
return str + "es";
else
return str + 's';
}
else
{
if( (last == 'y' || last == 'Y') && IsVowel(oneBeforeLast) )
return str + "es";
else if( "lrndzjsxLRNDZJSX".IndexOf(last) >= 0 || (last == 'h' && oneBeforeLast == 'c') )
return str + "es";
else
return str + 's';
}
}
public bool IsVowel(char ch)
{
return "aeiouáéíóúAEIOUÁÉÍÓÚ".IndexOf(ch) >= 0;
}
}