Jump to content

Multi-Language System for Client


Recommended Posts

M2 Download Center

This is the hidden content, please
( Internal )

Hello to all here is a system I created just recently because I wanted to do it simply :)


It is only the first part of the system that allows to select the Local pack according to the IP address of the player automatically!
The next part will be available in a second tutorial.

System Description:


This system allows a player to be linked to a script hosted on your website, the web script will analyze the location of the player's IP and return the acronym of his Country (example: FR) according to the acronym the client Va This will pass from the client's locale.cfg and read the pack file corresponding to the acronym received seamlessly and quickly.

 

Step 1: Open the file Locale_inc.h and add y this line:

#define ENABLE_MULTILANGUE_SYSTEM


Then open your UserInterface.cpp file and locate the following line:


 

LocaleService_LoadConfig("locale.cfg");


And replace it with:

#ifdef ENABLE_MULTILANGUE_SYSTEM
    LocaleService_LoadMultilangue(M_VerifLangue());
#else
    LocaleService_LoadConfig("locale.cfg");
#endif

 


Then add the following method by replacing the web link with the one of your choice:

std::string M_VerifLangue(){ // Méthode vérifiant la langue
    string versionActuel = "fr";


    string url = "https://ping-hosting.com/langue.php";
    string destination = "langue.php";
    char buffer[MAX_LINE];


    dl = URLDownloadToFile(NULL, url.c_str(), destination.c_str(), NULL, NULL);


    if (dl == S_OK)
    {

        std::ifstream infile("langue.php");


        std::string line;
        while (std::getline(infile, line))
        {
            std::istringstream iss(line);
            int a, b;
            if (!(iss >> a >> b)) { break; }


        }
        infile.close();
        remove("langue.php");

        return line;
    }
    else if (dl == E_OUTOFMEMORY) // En cas de surcharge, ferme le lanceur.
    {

        exit(0);
    }
    else // Ferme le lanceur si aucun des cas n'a été franchis.
    {

        exit(0);
    }
    return "";
}

 


Step 2: Now open the file Locale.h and look for the following line:


 

void        LocaleService_LoadConfig(const char* fileName);

 

Add the following lines:

#ifdef ENABLE_MULTILANGUE_SYSTEM
void        LocaleService_LoadMultilangue(std::string langue);
#endif

 

Open your Locale.cpp now and add the following function:

#ifdef ENABLE_MULTILANGUE_SYSTEM
void LocaleService_LoadMultilangue(std::string langue)
{
    MULTI_LOCALE_REPORT_PORT = 10000;
    MULTI_LOCALE_CODE = 1252;
    strcpy(MULTI_LOCALE_NAME, langue.c_str());
    sprintf(MULTI_LOCALE_PATH, "locale/%s", MULTI_LOCALE_NAME);
}
#endif

 

Web Part:

Download the attached file in the article and upload it in your web hosting corresponding to the link you have chosen.

The GeoIP.dat file can be updated regularly by uploading it to the official GeoIP site.

Link of the file:

This is the hidden content, please

Creator of the system : Me

Source link of the System: Online-Game

The second part (for the Server) will be created soon, you can use another server part for complete it if you want.

Cordialy :)

 

 

  • Metin2 Dev 36
  • Eyes 1
  • Dislove 1
  • Confused 1
  • Good 19
  • Love 4
  • Love 25
Link to comment
Share on other sites

  • Management

I think this isn't going to work very well...

For example, we guys from Portugal, are spread around Europe, Portugal (of course) France, UK, Germany, Switzerland, Luxembourg, and Belgium, this are the main countries, if I have Portuguese, English, French, Germany translations on my client, it will get the languages of the IP address's, they maybe still prefer using their mother language, in this case Portuguese, is there a way to still use the system, but the user can choose which language to use?

Thanks for sharing...

raw

raw

Link to comment
Share on other sites

You can edit the system has you wish, remember, with the php script you can return some language like that:
 

if ($pays != "FR" && $pays != "DE" && $pays != "EN")
{
	$pays = "EN"; // Return English
}

Create if you want a little Gui with that system . But if you not happy make the system by your own hands :)

Link to comment
Share on other sites

  • 7 months later...
  • 3 weeks later...
  • 4 weeks later...

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.