Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6648195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:37:38+00:00 2026-05-26T00:37:38+00:00

Okay, so i got class file, in which i got function – var $text;

  • 0

Okay, so i got class file, in which i got function –

var $text;                     

public function languages()
{
  if (isset($_GET['lang']) && $_GET['lang'] != '')
  {
    $_SESSION['lang'] = $_GET['lang'];
  }
  switch($_SESSION['lang'])
  {
    case 'en_EN': require_once('language/lang.eng.php');break;
    case 'lv_LV': require_once('language/lang.lv.php');break;
    case 'ru_RU': require_once('language/lang.ru.php');break;
    default: require_once('language/lang.eng.php');
  }
  $this->text = $text;
}

public function translate($txt)
{
  if(isset($this->text[$txt]))
  {
    return $this->text[$txt];
  }
}

If i am translating via index.php like this – > echo $index->translate('search'); it translates ok, but if i am translating something in class file for example –

if ($country_rows > 0)
{
  $_SESSION['country'] = $_GET['country'];
}
else
{                                                      
  $_SESSION['country'] = $this->translate('all_countries');
}
}
if ($_SESSION['country'] == '')
{ 
  $_SESSION['country'] = $this->translate('all_countries');
}

it doesn’t show up.
In index.php header i got included –

require_once('class.index.php');
$index = new index;
$index->get_country();
$index->languages();

What could be the problem, and how can i fix it, so i can translate everything inside class file too? will appreciate your help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T00:37:38+00:00Added an answer on May 26, 2026 at 12:37 am

    1st guess:
    no session started?

    session_start();
    

    2nd guess:
    assuming that you use $this->translate() in another class, you should initiate the object first, in the following example I pass translate class to var $index;

    <?
    include_once('class.index.php');
    class myClass {
      var $index;
    
      public function __construct() {
        $index = new index();
        $index->get_country();
        $index->languages();
        $this->index = $index;
      }
    
      public function yourFunction() {
        echo $this->index->translate('all_countries');
        print_r($this->index);
      }
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay, this is the case: I got a generic base-class which I need to
Okay, so I got two classes. class a{ public: a(){}; void print(){cout << hello};
Okay, I've got this WCF service going. It has a public access, which is
Okay, I got this small program which tags (as in ID3v2.4 etc.) some music
Okay, I've got my normal app which is in portrait mode. I can force
Possible Duplicate: Reading and Writing Configuration Files Okay, I have a config file, which
I've got a base class: public abstract class StuffBase { public abstract void DoSomething();
I've got a view model like this: public class SignUpViewModel { [Required(ErrorMessage = Bitte
I've got problem here which I couldn't solve by myself. Everything was okay before,
Okay, so I've got a class where one of the attributes is a callback

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.