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 8599187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:20:26+00:00 2026-06-12T01:20:26+00:00

I am not sure if I just have a bad structure for my code

  • 0

I am not sure if I just have a bad structure for my code or this is a problem not normally found, but I don’t even know how to start looking for a solution for my problem. I have my own simple translation script which is called like this:

<?php echo $Translate->text("Name"); ?>

It would return (and echo) a string with a keyword ‘Name’. The problem is, for several reasons (name: misstranslations, report, development, translation in situ), I might want to retrieve all strings’ keywords that are on a page. A simple page (example.com/campus/index.php) looks like this:

<h1> <?php echo $Translate->text(Campus); ?> </h1>

<p style="text-align:justify;">
  <?php echo $Translate->text(126); ?>
</p>

<p style="text-align:justify;">
  <?php echo $Translate->text(129); ?>
</p>

<a href="<?php $Link->create("campus/about"); ?>">
  <h2 class="bodymenu"><?php echo $Translate->text(About); ?> </h2>
</a>
<p style="text-align:justify;">
  <?php echo $Translate->text(146); ?>
</p>

<a href="<?php $Link->create("campus/learning_center"); ?>">
  <h2 class="bodymenu"><?php echo $Translate->text(Learning_center); ?> </h2>
</a>
<p style="text-align:justify;">
  <?php echo $Translate->text(147); ?>
</p>

<a href="<?php $Link->create("campus/residence"); ?>">
  <h2 class="bodymenu"><?php echo $Translate->text(Residence); ?> </h2>
</a>
<p style="text-align:justify;">
  <?php echo $Translate->text(128); ?>
</p>

And I would like to obtain in some situations: $Translations=array("Campus","126","129","About","146","Learning_center","147","Residence","128"); for further processing (EDIT) from another page.

In some cases there’s much more php logic mixed in the page, in some others it’s like this. There’s much more logic code and classes that it’s included automatically before and after every page. So, basically, I’d like to know (for this example but being able to extend it) how could I retrieve all the keywords.

I am thinking about 2 methods basically, but I don’t think either is optimal. First would be to parse the php code as is using regex. Since I know the bits that I’m looking for, I thing it would be possible. Second one is that, depending on a SESSION variable, I render the html and parse it, so the echo $Translate->text(Campus); would return something like <span id="Translation">Campus</span> and then parse only the html and retrieve all the ids. Can you think about any other way to retrieve the ids before I get on this?.

PS, I DON’T want to hardcode all the id’s in an array at the beginning or end of a page.

  • 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-06-12T01:20:27+00:00Added an answer on June 12, 2026 at 1:20 am

    Do not reinvent the wheel by implementing a translating system. The gettext extension is there for painless, on the fly, language switching.

    Basicly you write your site in a default language:

    <?php echo _("Name"); ?>
    

    Do not write <?php echo $Translate->text(147); ?>, noboby knows what that is. Write:

    <?php echo _("Learning Centre"); ?>

    For managing translations there is a choice of editors for Windows, Linux and Mac, POEdit for example.

    Switching to a different language is easy:

    public function SetDomain( $path )
    {
        define( 'DOMAIN', 'messages' );
        bindtextdomain( DOMAIN, $path );
        bind_textdomain_codeset( DOMAIN, "UTF-8" );
        textdomain( DOMAIN );
    }
    

    note: if you set short_open_tags to on you can write:

    <?= _("Name"); ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm just not too sure the proper way of doing this. I basically have
Not sure if I've just missed something but this doesn't work: $(this).children('td.threadtitle a').html('thread title');
I am not sure if this is possible, but I have a scenario where
I'm not sure if this is a bad way of building an application but
Not sure if im just being stupid or something but here goes i work
Not sure if yall can help this time, as I'm just using this particular
Not sure if I really am on the right forum, but if not, just
I'm not sure if it's just me, but whenever I open .txt files in
I am not sure if this is a bug or if I'm just missing
I'm not sure if this is a trivial questions but in a PHP class:

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.