Raised This Month: $32 Target: $400
 8% 

Translation issue


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Paaf
Member
Join Date: Dec 2010
Old 09-29-2019 , 15:56   Translation issue
Reply With Quote #1

Hello everyone,

I'm trying to use a translation file in my plugin but the issue is that, in-game, language is always changing for me.

So far, I have 2 languages written : "en" (default language) and "fr" (my language based on my location). During the game, I can get one phrase in french and the next one will be in english. Not always the same phrases in french nor in english, it can vary.

There is a piece of code I'm using but I don't think the problem is here :
Code:
public OnPluginStart()
{
LoadTranslations("plugin.phrases");
}
... Later in the code...
CPrintToChatAll("[PLUGIN] %t ","Annonce");
Based on this phrase file for example :

Quote:
"Annonce"
{

"en" "This is a Test "
"fr" "C'est un test"
}
I don't have this problem with other plugins.
Do you have any idea what can I do wrong here ?
Paaf is offline
foxhound27
AlliedModders Donor
Join Date: Sep 2019
Location: Argentina
Old 11-18-2019 , 01:50   Re: Translation issue
Reply With Quote #2

not sure but u can try with

char mylang[3];
GetLanguageInfo(GetClientLanguage(client), mylang, 3);

if(mylang=="fr") {

//print ur french text to user

}else if(mylang=="en"){

//print ur english text to user

}
foxhound27 is offline
Balimbanana
Member
Join Date: Jan 2017
Old 11-19-2019 , 00:34   Re: Translation issue
Reply With Quote #3

You could also try a for loop:
Code:
for (int i = 1;i<MaxClients+1;i++)
{
	if (IsValidEntity(i))
	{
		if (IsClientInGame(i))
		{
			PrintToChat(i,"%T","Annonce",i);
		}
	}
}
Although, I am not sure if you can do colors with just that, you might need a buffer on each loop that gets the current language then prints it using color text. Something like this:
Code:
for (int i = 1;i<MaxClients+1;i++)
{
	if (IsValidEntity(i))
	{
		if (IsClientInGame(i))
		{
			char translatebuf[128];
			Format(translatebuf,sizeof(translatebuf),"%T","Annonce",i);
			CPrintToChat(i,"%s",translatebuf);
		}
	}
}
Balimbanana is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 23:37.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode