1
bjarkekr
language file to new module
  • 2005/8/26 8:19

  • bjarkekr

  • Just popping in

  • Posts: 24

  • Since: 2005/8/10


Hi!

I have been working on a new module for myself, and now I wanted to add a language file..

this is what i did:
I made a language directory.
I made a directory in language, called danish.
I then used a file called main.php (copied from news module).
I deleted its contents, and build up my own content, the same way.

This works fine for the page the users see.. But it doesnt work for the admin area...

What do I do wrong?? How do I make a language file for the admin area?

thanks in advance.

2
Antoine
Re: language file to new module
  • 2005/8/26 8:55

  • Antoine

  • Friend of XOOPS

  • Posts: 112

  • Since: 2004/11/14


For the admin area you just add a file named admin.php instead of main.php. However, it often happens that you have to define a lot of constants twice that you have defined in main.php before. If you would like to have access to the main file from your admin pages I would add the following code to them:
if ( file_exists(XOOPS_ROOT_PATH."/modules/<your_module>/language/".$xoopsConfig['language']."/main.php") ) {
    include_once 
XOOPS_ROOT_PATH."/modules/<your_module>/language/".$xoopsConfig['language']."/main.php";
} else {
    include_once 
XOOPS_ROOT_PATH."/modules/<your_module>/language/english/main.php";
}

3
hyperpod
Re: language file to new module
  • 2005/8/26 8:58

  • hyperpod

  • Quite a regular

  • Posts: 359

  • Since: 2004/10/4


main.php is for the module lang point defines.
admin.php is for the Admin lang defines.
modinfo.php is for the xoops_version.php and preferences lang defines.
blocks.php is for the Block lang defines



Hope that helps...

You can look into most well crafted XOOPS modules and see this.

There are also some naming standards that are good to follow.
like _AM_MODULE_LANGVAR or something similar.

I believe this will ensure nothing eats something else.

AM means Admin
MI means modinfo
MB means blocks
MD means main

_MODULE_ should be something unique to identify your module short abbrev.


I hope this helps.
Daniel Hall / XOOPS Module Development & Theme Design
Free XOOPS Support > My Wish List

4
bjarkekr
Re: language file to new module
  • 2005/8/26 9:06

  • bjarkekr

  • Just popping in

  • Posts: 24

  • Since: 2005/8/10


thanks, that helped..

I actually made an admin.php file, and it didnt work...

But then I added this code to the header of the admin area:
if ( file_exists("../language/".$xoopsConfig['language']."/admin.php") ) {
include "../language/".$xoopsConfig['language']."/admin.php";
} else {
include "../language/english/admin.php";
}

and it worked..

Thanks for the naming standard too.. :) really nice

5
Antoine
Re: language file to new module
  • 2005/8/26 9:12

  • Antoine

  • Friend of XOOPS

  • Posts: 112

  • Since: 2004/11/14


Hmm sounds you aren't including cp_header.php then. cp_header contains:
// include the default language file for the admin interface
if ( file_exists"../language/" $xoopsConfig['language'] . "/admin.php" ) ) {
    include 
"../language/" $xoopsConfig['language'] . "/admin.php";
}
elseif ( 
file_exists"../language/english/admin.php" ) ) {
    include 
"../language/english/admin.php";

Which should do the trick.
Do you have something like
include '../../../include/cp_header.php';
at the start of your admin pages? .

6
bjarkekr
Re: language file to new module
  • 2005/8/26 9:36

  • bjarkekr

  • Just popping in

  • Posts: 24

  • Since: 2005/8/10


this is my headerfile:

<?
include( "../../../mainfile.php" );
include XOOPS_ROOT_PATH."/include/cp_functions.php";
if ( file_exists(XOOPS_ROOT_PATH."/modules/system/language/".$xoopsConfig['language']."/admin.php") ) {
include XOOPS_ROOT_PATH."/modules/system/language/".$xoopsConfig['language']."/admin.php";
} else {
include XOOPS_ROOT_PATH."/modules/system/language/english/admin.php";
}
include_once XOOPS_ROOT_PATH."/class/xoopsmodule.php";
include_once XOOPS_ROOT_PATH."/include/xoopscodes.php";
include_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php';
if ( file_exists("../language/".$xoopsConfig['language']."/admin.php") ) {
include "../language/".$xoopsConfig['language']."/admin.php";
} else {
include "../language/english/admin.php";
}
xoops_cp_header();
?>


So if you are right the language inclution code is writen twice now.. hmm... well it works..

How do I add a module to xoops.orgs download??

Its a simple job listing module, with FCK editor to write the text..

You can add a start date, and end date for when its showed on the page.. When end date is passed, its moved to "old jobs listing"... There is also a checkbox if the job should be showed at all...

You can add, edit and delete jobs.

I only have the danish translation now.

Login

Who's Online

80 user(s) are online (40 user(s) are browsing Support Forums)


Members: 0


Guests: 80


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Jul 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits