collapse collapse
* User Info
 
 
Welcome, Guest. Please login or register.
* Search

* Board Stats
  • stats Total Members: 989
  • stats Total Posts: 18366
  • stats Total Topics: 2501
  • stats Total Categories: 7
  • stats Total Boards: 35
  • stats Most Online: 1144

Author Topic: Language Support  (Read 5549 times)

0 Members and 1 Guest are viewing this topic.

Offline Temar

  • Contributor
  • *******
  • Posts: 1140
  • Karma: +0/-0
    • AoFiles
Language Support
« on: January 25, 2009, 05:49:39 pm »
Making Bebot Support Other Languages

this is a module for TWC which i will be improving on for use by BeBot
i have added comments to it for planned changes
Code: [Select]
<?php
$languages 
= new languages($twc);

class 
languages
{
function __construct($twc)
{
$this -> twc $twc;
$this -> twc -> register_module("lang"$this);

// load english now to make sure everything has output
$this -> load("english"); // Load all required languages
}

function load($lang)
{
if(defined("ROOT"))
$root ROOT;
if(file_exists($root."languages/".$lang.".php"))
{
Require($root."languages/".$lang.".php");
$this -> langs[$lang] = $txt;
}
}

function get($txt$rep1=FALSE)
{
$user $this -> twc -> prefs["lang"]; // this will only be for tells
$main $this -> twc -> settings["lang"]; // this will be for gc
if($user != "default" && isset($this -> langs[$user][$txt]))
$return $this -> langs[$user][$txt];
elseif(isset($this -> langs[$main][$txt]))
$return $this -> langs[$main][$txt];
elseif(isset($this -> langs["english"][$txt]))
$return $this -> langs["english"][$txt];// always fall back to english if cant find
else
$return "Language text not found for \"$txt\""// hopefully should better be called
if($rep1)
$return str_ireplace("&rep1&"$rep1$return);// this need to support multi replacement , $rep1 will be $rep and will be an array
Return $return;
}
}
?>


as for the language file i think this format will be suitable

english_core.php
english_irc.php

this being <language>_<module>.php
ofc the module is mainly a referance so u know wats were, and also to make files names unique and not all in 1 big file

inside it will be like this

Code: [Select]
<?php

$txt
["reload ar"] = "Reload Page to See Access Request Form";

?>


the above should be stores as (if loaded from english_core.php)
$lang['english']['core']['reload ar'] = "Reload Page to See Access Request Form";

this can be called useing
$this -> lang('reload ar'); from a module that has defined it self as core
$this -> lang('reload ar', 'core'); from a module that has been definded as something else or not defined

Offline chek

  • BeBot Rookie
  • *
  • Posts: 5
  • Karma: +0/-0
Re: Language Support
« Reply #1 on: June 19, 2009, 09:52:09 pm »
Tell me pls what dirrectory?

Offline Temar

  • Contributor
  • *******
  • Posts: 1140
  • Karma: +0/-0
    • AoFiles
Re: Language Support
« Reply #2 on: June 22, 2009, 04:00:38 am »
this isnt complete it is still in the works
altho i havnt worked on it in awhile

 

* Recent Posts
Com bot module by bitnykk
[November 25, 2024, 05:36:11 pm ]


0.8.x updates for AO by bitnykk
[June 23, 2024, 03:19:47 pm ]


0.8.x updates for AoC by bitnykk
[June 23, 2024, 03:19:44 pm ]


[AoC] special char for items module by bitnykk
[February 09, 2024, 09:41:18 pm ]


BeBot still alive & kicking ! by bitnykk
[December 17, 2023, 12:58:44 am ]

* Who's Online
  • Dot Guests: 208
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.
* Forum Staff
bitnykk admin bitnykk
Administrator
Khalem admin Khalem
Administrator
WeZoN gmod WeZoN
Global Moderator
SimplePortal 2.3.7 © 2008-2024, SimplePortal