Core/Chat: Improve ingame language translation
Port From (https://github.com/TrinityCore/TrinityCore/commit/086632d8710ebf3d36aba6a596bc2a9ab4a94fa8)
This commit is contained in:
@@ -376,6 +376,27 @@ namespace System
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool isLatin1Character(char wchar)
|
||||||
|
{
|
||||||
|
if (isBasicLatinCharacter(wchar))
|
||||||
|
return true;
|
||||||
|
if (wchar >= 0x00C0 && wchar <= 0x00D6) // LATIN CAPITAL LETTER A WITH GRAVE - LATIN CAPITAL LETTER O WITH DIAERESIS
|
||||||
|
return true;
|
||||||
|
if (wchar >= 0x00D8 && wchar <= 0x00DD) // LATIN CAPITAL LETTER O WITH STROKE - LATIN CAPITAL LETTER Y WITH ACUTE
|
||||||
|
return true;
|
||||||
|
if (wchar == 0x00DF) // LATIN SMALL LETTER SHARP S
|
||||||
|
return true;
|
||||||
|
if (wchar >= 0x00E0 && wchar <= 0x00F6) // LATIN SMALL LETTER A WITH GRAVE - LATIN SMALL LETTER O WITH DIAERESIS
|
||||||
|
return true;
|
||||||
|
if (wchar >= 0x00F8 && wchar <= 0x00FD) // LATIN SMALL LETTER O WITH STROKE - LATIN SMALL LETTER Y WITH ACUTE
|
||||||
|
return true;
|
||||||
|
if (wchar == 0x00FF) // LATIN SMALL LETTER Y WITH DIAERESIS
|
||||||
|
return true;
|
||||||
|
if (wchar == 0x0178) // LATIN CAPITAL LETTER Y WITH DIAERESIS
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static bool isBasicLatinCharacter(char wchar)
|
public static bool isBasicLatinCharacter(char wchar)
|
||||||
{
|
{
|
||||||
if (wchar >= 'a' && wchar <= 'z') // LATIN SMALL LETTER A - LATIN SMALL LETTER Z
|
if (wchar >= 'a' && wchar <= 'z') // LATIN SMALL LETTER A - LATIN SMALL LETTER Z
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ namespace Game.Chat
|
|||||||
if (!wordGroup.Empty())
|
if (!wordGroup.Empty())
|
||||||
{
|
{
|
||||||
uint wordHash = SStrHash(str, true);
|
uint wordHash = SStrHash(str, true);
|
||||||
byte idxInsideGroup = (byte)(wordHash % wordGroup.Count());
|
byte idxInsideGroup = (byte)(language * wordHash % wordGroup.Count());
|
||||||
|
|
||||||
string replacementWord = wordGroup[idxInsideGroup];
|
string replacementWord = wordGroup[idxInsideGroup];
|
||||||
|
|
||||||
@@ -125,7 +125,7 @@ namespace Game.Chat
|
|||||||
int length = Math.Min(str.Length, replacementWord.Length);
|
int length = Math.Min(str.Length, replacementWord.Length);
|
||||||
for (int i = 0; i < length; ++i)
|
for (int i = 0; i < length; ++i)
|
||||||
{
|
{
|
||||||
if (char.IsUpper(str[i]))
|
if (str[i] != '\'' && char.IsUpper(str[i]))
|
||||||
result += char.ToUpper(replacementWord[i]);
|
result += char.ToUpper(replacementWord[i]);
|
||||||
else
|
else
|
||||||
result += char.ToLower(replacementWord[i]);
|
result += char.ToLower(replacementWord[i]);
|
||||||
@@ -228,8 +228,8 @@ namespace Game.Chat
|
|||||||
var chars = text.ToCharArray();
|
var chars = text.ToCharArray();
|
||||||
for (var i = 0; i < text.Length; ++i)
|
for (var i = 0; i < text.Length; ++i)
|
||||||
{
|
{
|
||||||
var w = chars[i];
|
var w = text[i];
|
||||||
if (!Extensions.isExtendedLatinCharacter(w) && !char.IsNumber(w) && w <= 0xFF && w != '\\')
|
if (!Extensions.isLatin1Character(w) && !char.IsNumber(w) && w <= 0xFF && w != '\\')
|
||||||
chars[i] = ' ';
|
chars[i] = ' ';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user