Jump to content

Recommended Posts

  • Honorable Member
Spoiler


#include "map"
enum Languages
{
	TR,
	EN,
	LANG_MAX,
	DEFAULT_LANG = TR, // change lang or use your multilang func example: GetLang()
};
auto Translate(string input, int lang)
{
	using namespace std;
	map<string, string> Langs[LANG_MAX];
	Langs[TR]["TESTSTRING"] = "[TR]Test multilang";
	Langs[EN]["TESTSTRING"] = "[EN]Test multilang";
   
	if (not(Langs[lang].count(input)) or lang >= LANG_MAX) {
		sys_err("Error in [%s], chat[%s]", __FUNCTION__, input.c_str());
		return "error";
	}
	/* test only
	auto Lang_Name = [](auto lang) -> string {
		return lang == TR ? "TR" : "EN";
	};
	for (auto exist_langs : {TR, EN})
		for (auto [inp,output] : Langs[exist_langs])
			cout << "Lang:[" << Lang_Name(exist_langs) << "] " << "input: " << inp << " output: " << output << endl;
	*/
			
	return Langs[lang][input].c_str();
}

 

Usage:

ChatPacket(CHAT_TYPE_INFO, Translate("TESTSTRING", DEFAULT_LANG));

 

  • Love 1

 

Link to comment
https://metin2.dev/topic/19720-example-of-mini-code-for-multilang/
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please use https://metin2.download/ when uploading files smaller than 100MB, otherwise the approval will take longer due to manual upload.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • 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.