Acubens
Old Penguin
Acubens Multi-Language System [LUA & PHP]
Hello otland this is a simple system what i was created for my project is not a big deal but it is very useful for international rpg servers
Step 1) Saving the function in lib/050-functions.lua
Step 2) Creating the column in your database
Step 3) Add constants variables in lib/000-constant.lua
You can define your custom languages with id.
How Works this function?
Example: If you want send Welcome message in the language of the player.
Register in news Accounts for Gesior Acc You need edit config.php, createaccount.php and OTS_Account.php
in config.php add the language config:
Under:
Add:
Under:
Add:
Under:
Add
in htdocs/pot/OTS_Account.php after:
add
Now you can use too in your web page to show the content in differents languages without make 2 websites or more.
Enjoy, dont forget rep me !
Hello otland this is a simple system what i was created for my project is not a big deal but it is very useful for international rpg servers
Step 1) Saving the function in lib/050-functions.lua
Lua:
-- By Acubens
-- For Otland.net
function getPlayerLanguage(cid)
local Lang = db.getResult("SELECT `language` FROM `accounts` WHERE `id` = " .. getPlayerAccountId(cid) .. " LIMIT 1")
if Lang:getID() ~= LUA_ERROR then
local langid = Lang:getDataInt("language")
Lang:free()
return langid
end
return LUA_ERROR
end
Step 2) Creating the column in your database
PHP:
ALTER TABLE `accounts` ADD `language` INT( 11 ) NOT NULL DEFAULT '0'
Step 3) Add constants variables in lib/000-constant.lua
Lua:
ENGLISH = 0
SPANISH = 1
PORTUGUES = 2
-- and etc..
You can define your custom languages with id.
How Works this function?
Example: If you want send Welcome message in the language of the player.
Lua:
function onLogin(cid)
local language = getPlayerLanguage(cid)
if language == ENGLISH then
doPlayerSendTextMessage(cid,22, "Welcome adventurer!")
elseif language == SPANISH then
doPlayerSendTextMessage(cid,22, "Bienvenido aventurero!")
elseif language == PORTUGUES then
doPlayerSendTextMessage(cid,22, "Bem-vindo aventureiro!")
end
return true
end
Register in news Accounts for Gesior Acc You need edit config.php, createaccount.php and OTS_Account.php
in config.php add the language config:
PHP:
//Language System by Acubens
$config['site']['languages'] = array(0 => 'English', 1 => 'Spanish', 2 => 'Portugues'); //and etc..
Under:
PHP:
<TR><TD width="150"><b>Email status:</b></TD><TD colspan="2"><b><div id="email_check">Please enter your e-mail.</div></b></TD></TR>';
Add:
PHP:
//Language System by Acubens
$main_content .= '<TR><TD width="150"><b>Idioma/Language:</b></TD><TD colspan="2"><b><select name="language">';
foreach($config['site']['languages'] as $language_id => $lang)
{
$main_content .= '<option value="'.$language_id.'">'.$lang.'</option>';
}
PHP:
$reg_country = trim($_POST['country']);
Add:
PHP:
$reg_language = trim($_POST['language']);
Under:
PHP:
$reg_account->setCustomField("flag", $reg_country);
Add
PHP:
$reg_account->setCustomField("language", $reg_language);
in htdocs/pot/OTS_Account.php after:
PHP:
public function getRLName()
{
if( !isset($this->data['rlname']) )
{
throw new E_OTS_NotLoaded();
}
return $this->data['rlname'];
}
PHP:
//Language System by Acubens
public function getPlayerLanguage() {
if( !isset($this->data['language']) )
{
throw new E_OTS_NotLoaded();
}
return $this->data['language'];
}
Now you can use too in your web page to show the content in differents languages without make 2 websites or more.
Enjoy, dont forget rep me !
Last edited: