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

  • SEARCH
  • Home
  • 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 7631939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:29:17+00:00 2026-05-31T06:29:17+00:00

I have created my own l($text) function in php for a multi lingual website.

  • 0

I have created my own l($text) function in php for a multi lingual website. i use it like this in my documents :

echo '<h1>' . l('Title of the page') . '</h1';
echo '<p>' . l('Some text here...') . '</p>';

My question is, with a php script, how can i scan all my .php files to catch all this function usages and list all the arguments used into a mysql table?
the goal, of course, is to not forget any sentences in my traduction files.

I didn’t find anything on google or here, so if you have any ideas, or need some more information.

  • 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-31T06:29:19+00:00Added an answer on May 31, 2026 at 6:29 am

    i just finished, your help was usefull ! 🙂

    here is my ugly code for those who can be interested. it’s not beautifuly coded, but not made to be loaded 10000 times per day so…

    <?php
    // define a plain text document to see what appen on test
    header('Content-Type: text/plain; charset=UTF-8');
    
    $dossier = 'pages/'; // folder to scan
    $array_exclude = array('.', '..', '.DS_Store'); // system files to exclude
    $array_sentences_list = array();
    
    if(is_dir($dossier)) // verify if is a folder
    {
        if($dh = opendir($dossier)) // open folder
        {
            while(($file = readdir($dh)) !== false) // scan all files in the folder
            {
                if(!in_array($file, $array_exclude)) // exclude system files previously listed in array
                {
                    echo "\n".'######## ' . strtoupper($file) . ' ##########'."\n";
                    $file1 = file('pages/'.$file); // path to the current file
                    foreach($file1 AS $fileline)
                    {
                        // regex : not start with a to z characters or a (
                        // then catch sentences into l(' and ')
                        // and put results in a $matchs array
                        preg_match_all("#[^a-z\(]l\('(.+)'\)#U", $fileline, $matchs);
    
                        // fetch the associative array
                        foreach($matchs AS $match_this)
                        {
                            foreach($match_this AS $line)
                            {
                                // technique of "I do not want to break my head"
                                if(substr($line, 0, 3) != "l('" AND substr($line, 0, 4) != " l('" AND substr($line, 0, 4) != ".l('")
                                {
                                    // check if the sentence is not already listed
                                    if(!in_array($line, $array_sentences_list))
                                    {
                                        // if not, add it to the sentences list array and write it for fun !
                                        $array_sentences_list[] = $line;
                                        echo $line . "\n";
                                    }
                                }
                            }
                        }
                    }
                }
            }
            closedir($dh);
        }
    }
    ?>
    

    small precision : i do have to escape various cases as :
    -> CSS : background: url(‘image.jpg’);
    and
    -> jQuery : $(this).html(‘bla bla’);
    so here is why the regex starts with [^a-z(] 🙂

    it works very well now! just have to finish later with recording entries in a mysql table and ensure that i can load the script from time to time when there are changes on the site… keep the existing translation, overwrite the existing files etc… no problem with that.

    thanks a gain, this website is really helpful ! 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created my own Attached Property like this: public static class LabelExtension {
I have my own asp.net cookie created like this: var authTicket = new FormsAuthenticationTicket(
I Have this function, I would like to use the same function for 3
I have created one jQuery plugin to use in my own system. The problem:
I have created my own Tree implementation for various reasons and have come up
I've created a function to overlay text onto images, but I'm scratching my head
I have created a function that updates some values from a database that I
I have created my own custom ValidationAttribute : public class UrlValidationAttribute : ValidationAttribute {
I have a javascript function designed to dynamically append text to my document (and
I have create my own NSOpenGLView class, right now the data that i want

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.